当前位置: 首页 > 知识库问答 >
问题:

Google Play服务:以非零退出值2完成

白坚壁
2023-03-14

由于gradle内部存在问题,我无法运行程序。我最近添加了依赖项:

compile 'com.google.android.gms:play-services:7.3.0'

我的项目。我在我的项目中使用它来绘制地图。但是当我运行这个项目时,我得到了这个错误:

Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72211Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42211Library UP-TO-DATE
:app:prepareComGithubShellSoftwareFab105Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServices730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAds730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppinvite730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppstate730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBase730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesCast730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesDrive730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesFitness730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGames730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGcm730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesIdentity730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesLocation730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesMaps730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesNearby730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPanorama730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPlus730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesSafetynet730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWallet730Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWearable730Library 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:compileDebugJava UP-TO-DATE
:app:preDexDebug UP-TO-DATE
: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: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)
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException:                             org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2
Information:BUILD FAILED
Information:Total time: 48.802 secs
Information:1 error
Information:0 warnings
Information:See complete output in console

我相信这是由于上面的编译行,但我需要它作为我的项目的一部分。我不完全确定在这里该做什么。

编辑:这是我的全部build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.aszend.android"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:22.1.1'
    compile 'com.android.support:appcompat-v7:22.1.1'
    compile files('libs/aws-android-sdk-autoscaling-2.2.1.jar')
    compile files('libs/aws-android-sdk-cloudwatch-2.2.1.jar')
    compile files('libs/aws-android-sdk-cognito-2.2.1.jar')
    compile files('libs/aws-android-sdk-core-2.2.1.jar')
    compile files('libs/aws-android-sdk-ddb-2.2.1.jar')
    compile files('libs/aws-android-sdk-ddb-mapper-2.2.1.jar')
    compile files('libs/aws-android-sdk-ec2-2.2.1.jar')
    compile files('libs/aws-android-sdk-elb-2.2.1.jar')
    compile files('libs/aws-android-sdk-kinesis-2.2.1.jar')
    compile files('libs/aws-android-sdk-lambda-2.2.1.jar')
    compile files('libs/aws-android-sdk-machinelearning-2.2.1.jar')
    compile files('libs/aws-android-sdk-mobilenalytics-2.2.1.jar')
    compile files('libs/aws-android-sdk-s3-2.2.1.jar')
    compile files('libs/aws-android-sdk-sdb-2.2.1.jar')
    compile files('libs/aws-android-sdk-ses-2.2.1.jar')
    compile files('libs/aws-android-sdk-sns-2.2.1.jar')
    compile files('libs/aws-android-sdk-sqs-2.2.1.jar')
    compile files('libs/Parse-1.9.1.jar')
    compile 'com.github.shell-software:fab:1.0.5'
    compile 'com.parse.bolts:bolts-android:1.2.0'
    compile 'com.google.android.gms:play-services:7.3.0'
}

感谢所有帮助

共有1个答案

艾和通
2023-03-14

看起来您的项目已超过 65536 个方法,从以下行的错误中可以看出:

com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

看到这个答案。基本上,您有很多导入的库,并且您的应用程序中的方法和所有导入的库的组合数量已经超过了限制。

这里有一件事你可以尝试,挑选你需要的Google Play服务的各个部分,而不是导入整个库。请参阅此处的文档。

因此,如果你只需要Google Play地图服务,请替换为:

compile 'com.google.android.gms:play-services:7.3.0'

有了这个:

compile 'com.google.android.gms:play-services-maps:7.3.0'

希望这能让你低于极限!

 类似资料:
  • 问题内容: 任何人都可以通过以下错误帮助我。当我清理项目时,它不会显示任何错误,但是每次我尝试运行时,都会收到此消息。 错误:任务’:app:dexDebug’的执行失败。 com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:进程’命令’C:\ Program Files

  • null 错误:任务“:app:dexdebug”执行失败。com.android.ide.common.Process.processException:org.gradle.Process.internal.execexception:进程“command”C:\program files\java\jdk1.7.0_25\bin\java.exe“已完成,退出值为非零2 我的分级文件: 编辑

  • 当我添加编译'org.apache.httpcomponents:httpmime:4.2.3'时,出现了此错误。找不到解决方案,我也尝试了多个dex文件true在默认配置部分。我还尝试创建另一个测试应用程序,运行成功。 错误:任务“:app:TransformClassesWithDexForDebug”执行失败。com.android.build.api.transform.transform

  • 所以我有一个我已经开发/测试了一段时间的应用程序,并且完全没有问题将其加载到我的手机上进行调试。有一天,它突然开始抛出并出错,不再让我运行模拟器。错误如下: com.ide.common.process.process异常: 组织.gradle.process.internal.exec异常: 处理“命令”C:\程序文件\Java\jdk1.7.0_75\bin\java.exe“以非零退出值 2