我用libgdx做了一个游戏。
当我将下一行添加到gradle时:
compile "com.google.android.gms:play-services:7.0.0"
它确实正确同步。但后来我尝试运行我的应用程序并出现下一个错误:
Error:Execution failed for task ':android:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\[...]\Android\sdk2\build-tools\21.1.2\dx.bat --dex --no-optimize --output C:\[...]\android\build\intermediates\dex\debug --input-list=C:\[...]\android\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)
at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277)
at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
安装并更新了Google Play服务和Android支持库。
答案 0 :(得分:5)
您需要有选择地仅添加您实际需要的部分Google Play服务。请参阅此内容以供参考。
https://developer.android.com/google/play-services/setup.html#Setup
Google Play services API Description in build.gradle
Google+ com.google.android.gms:play-services-plus:7.0.0
Google Account Login com.google.android.gms:play-services-identity:7.0.0
Google Actions, Base Client Library com.google.android.gms:play-services-base:7.0.0
Google App Indexing com.google.android.gms:play-services-appindexing:7.0.0
Google Analytics com.google.android.gms:play-services-analytics:7.0.0
Google Cast com.google.android.gms:play-services-cast:7.0.0
Google Cloud Messaging com.google.android.gms:play-services-gcm:7.0.0
Google Drive com.google.android.gms:play-services-drive:7.0.0
Google Fit com.google.android.gms:play-services-fitness:7.0.0
Google Location, Activity Recognition, and Places com.google.android.gms:play-services-location:7.0.0
Google Maps com.google.android.gms:play-services-maps:7.0.0
Google Mobile Ads com.google.android.gms:play-services-ads:7.0.0
Google Nearby com.google.android.gms:play-services-nearby:7.0.0
Google Panorama Viewer com.google.android.gms:play-services-panorama:7.0.0
Google Play Game services com.google.android.gms:play-services-games:7.0.0
SafetyNet com.google.android.gms:play-services-safetynet:7.0.0
Google Wallet com.google.android.gms:play-services-wallet:7.0.0
Android Wear com.google.android.gms:play-services-wearable:7.0.0
答案 1 :(得分:1)
LibGDX
是一个相当大的库,您是已启用multidex
还是尝试删除未使用的代码?
只需在build.gradle中执行此操作
`android {
defaultConfig {
...
multiDexEnabled = true
}
}`
如果这不是问题,请尝试查看此主题并查看是否有任何帮助对您有所帮助: