2016-04-22 73 views
1

我正在構建一個谷歌地圖和微軟Azure移動服務(雲存儲)使用谷歌播放服務的Android應用程序。 當我只使用Microsoft Azure庫時,我不會遇到任何問題,但是當添加谷歌播放庫時,它會給我以下錯誤。NoClassDefFoundError:com.google.gson.GsonBuilder當使用谷歌播放服務與微軟azure

錯誤

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這個

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' 
        } 

希望你能幫助我。提前致謝。

回答

1

如果包含compile 'com.google.android.gms:play-services:8.4.0',則包含所有播放服務包。如果您只需要播放服務的地圖,請改爲使用compile 'com.google.android.gms:play-services-maps:8.4.0'

有關播放服務模塊的列表,請參閱here。我目前正在測試所有的模塊,看看哪些可能是罪魁禍首。如果您好奇,請繼續關注更新。

我目前不確定是什麼原因導致此問題。使用整個播放服務集合可在我的大多數設備上使用,但不適用於我的任何Android 4.4.4設備。

更新:此問題更可能是由於使用的軟件包數量,而不是與Azure不兼容的特定軟件包。可能與總方法數超過64K(DEX64K錯誤)有關。

繼續使用特定的模塊,你應該沒問題。

+0

非常感謝你@Tim!我能夠解決這個問題。我只選擇了我需要的罐子。 –