意外的顶级异常:使用play-services lib的dex索引

时间:2016-05-08 06:44:54

标签: android android-build

我想在我的应用程序中使用谷歌地图,这是我的gradle代码:

    compile 'com.android.support:appcompat-v7:23.0.0'
compile files('libs/commons-net-3.3.jar')
compile files('libs/Parse-1.4.3.jar')
compile files('libs/universal-image-loader-1.8.4-with-sources.jar')
compile files('libs/org.apache.http.legacy.jar')
compile 'com.koushikdutta.ion:ion:2.1.6'
compile 'com.android.support:recyclerview-v7:23.0.0'
compile 'com.android.support:cardview-v7:23.0.0'
compile 'com.android.support:design:23.0.0'
compile 'com.soundcloud.android:android-crop:1.0.1@aar'
compile 'com.google.android.gms:play-services:7.8.0'

问题是在添加com.google.android.gms后:play-services:7.8.0,我无法再运行我的应用程序而且出现此错误:

:app:prepareComAndroidSupportAppcompatV72300Library UP-TO-DATE
:app:prepareComAndroidSupportCardviewV72300Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2300Library UP-TO-DATE
:app:prepareComAndroidSupportMediarouterV72220Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72300Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42300Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServices780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAds780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppinvite780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppstate780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBase780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesCast780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesDrive780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesFitness780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGames780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGcm780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesIdentity780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesLocation780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesMaps780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesNearby780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPanorama780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPlus780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesSafetynet780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesVision780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWallet780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWearable780Library UP-TO-DATE
:app:prepareComSoundcloudAndroidAndroidCrop101Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareDebugAndroidTestDependencies
:app:compileDebugAndroidTestAidl UP-TO-DATE
:app:processDebugAndroidTestManifest UP-TO-DATE
:app:compileDebugAndroidTestRenderscript UP-TO-DATE
:app:generateDebugAndroidTestBuildConfig UP-TO-DATE
:app:generateDebugAndroidTestAssets UP-TO-DATE
:app:mergeDebugAndroidTestAssets UP-TO-DATE
:app:generateDebugAndroidTestResValues UP-TO-DATE
:app:generateDebugAndroidTestResources UP-TO-DATE
:app:mergeDebugAndroidTestResources UP-TO-DATE
:app:processDebugAndroidTestResources UP-TO-DATE
:app:generateDebugAndroidTestSources UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:preDexDebug
:app:dexDebug
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:502)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
    at com.android.dx.command.dexer.Main.run(Main.java:277)
    at com.android.dx.command.dexer.Main.main(Main.java:245)
    at com.android.dx.command.Main.main(Main.java:106)
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'F:\sdk\bin\java.exe'' finished with non-zero exit value 2
你可以帮帮我吗?问题是什么 ?已经过了5个小时,我无法解决这个问题

谢谢

1 个答案:

答案 0 :(得分:0)

尝试使用

  multiDexEnabled true
build.gradle中的

defaultConfig {
applicationId 'pkg'
minSdkVersion 
targetSdkVersion 
versionCode 
versionName 

// Enable MultiDexing:  https://developer.android.com/tools/building/multidex.html
multiDexEnabled true
}