简体   繁体   中英

libGDX + com.google.android.gms:play-services:7.0.0 : android:dexDebug

I made a game with libgdx.

When I add the next line to gradle:

compile "com.google.android.gms:play-services:7.0.0"

It does sync correctly. But then I try to run my app and the next error emerges:

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 Services and Android Support Library are installed and updated.

You need to selectively add only the part of the Google Play Services that you actually need. See this for reference.

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

LibGDX is a fairly large library, have you either enabled multidex or tried to remove unused code?

To do so simply in build.gradle

`android {
   defaultConfig {
      ...
      multiDexEnabled = true
   }
}`

Try taking a look at this thread and see if any of these are of any aid to you if this was not the issue:

Unable to execute dex: method ID not in [0, 0xffff]: 65536

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM