本文介绍了NoClassDefFoundError的:使用谷歌播放服务时com.google.gson.GsonBuilder与微软Azure的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立这对于谷歌地图和移动服务(云存储),微软Azure使用谷歌播放服务的Andr​​oid应用程序。
当我只使用微软Azure库,我没有遇到任何问题,但是当谷歌插件库,发挥它给了我下面的错误。

I am building an android app which uses google play services for google maps and Microsoft azure for mobile services(cloud storage).When i use just Microsoft azure libraries i don't face any problems but when add google play libraries it gives me the following error.

错误

    FATAL EXCEPTION: main
                  java.lang.NoClassDefFoundError: com.google.gson.GsonBuilder
                  at com.microsoft.windowsazure.mobileservices.MobileServiceClient.createMobileServiceGsonBuilder(MobileServiceClient.java:192)
                  at com.microsoft.windowsazure.mobileservices.MobileServiceClient.<init>(MobileServiceClient.java:179)
                  at com.microsoft.windowsazure.mobileservices.MobileServiceClient.<init>(MobileServiceClient.java:158)
                  at com.example.jino.navigationplacepicker.ReviewPage.onCreate(ReviewPage.java:27)

这是库的依赖关系结构从我gradle这个

this is library dependency structure from my gradle

    dependencies {
                   compile fileTree(include: ['*.jar'], dir: 'libs')
                   testCompile 'junit:junit:4.12'
                   compile 'com.android.support:appcompat-v7:23.2.1'
                   compile 'com.android.support:design:23.2.1'
                   compile 'com.google.code.gson:gson:2.4'
                   compile files('libs/azuresdk-android-2.0.3/mobileservices/guava-17.0.jar')
                   compile files('libs/azuresdk-android-2.0.3/mobileservices/mobileservices-2.0.3.jar')
                   compile files('libs/azuresdk-android-2.0.3/mobileservices/mobileservices-2.0.3-javadoc.jar')
                   compile files('libs/azuresdk-android-2.0.3/mobileservices/mobileservices-2.0.3-sources.jar')
                   compile 'com.google.android.gms:play-services:8.4.0'
                   } 

希望你能帮助我。先谢谢了。

Hope you can help me out. Thanks in advance.

推荐答案

在包括编译com.google.android.gms:发挥服务:8.4.0 所有的播放服务包都包括在内。如果你只需要地图的播放服务,使用编译com.google.android.gms:发挥服务,地图:8.4.0 来代替。

When you include compile 'com.google.android.gms:play-services:8.4.0' all of the play services packages are included. If you only need maps from play services, use compile 'com.google.android.gms:play-services-maps:8.4.0' instead.

请参阅的播放服务模块列表。我目前正在测试的所有模块,看看哪些可能是罪魁祸首。请继续关注更新,如果你是好奇。

See here for a list of play services modules. I am currently testing all of the modules to see which might be the culprit. Stay tuned for an update if you are curious.

我目前不能确定到底是什么导致了这个问题。使用整个播放服务集合在我的大多数设备的工作原理,但没有任何我的Andr​​oid 4.4.4的设备。

I am currently unsure exactly what causes this problem. Using the entire play services collection works on most of my devices, but not any of my Android 4.4.4 devices.

更新:这个问题是更可能是由于使用的包,而不是特定的软件包不是与天青兼容的数字。可能与总的方法数超过64K(DEX64K错误)。

UPDATE: The issue is more likely due to number of packages used and not specific packages not being compatible with Azure. Probably related to the total method count exceeding 64K (DEX64K error).

继续使用特定的模块,并且你应该罚款。

Continue using specific modules and you should be fine.

这篇关于NoClassDefFoundError的:使用谷歌播放服务时com.google.gson.GsonBuilder与微软Azure的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 18:44