【问题标题】:Android build project error trying to build apps > 65K (65536) methodsAndroid 构建项目错误尝试构建应用程序 > 65K (65536) 方法
【发布时间】:2015-06-16 17:31:48
【问题描述】:

我在 build.gradle 中添加了这两个新的依赖项

compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:design:22.2.0'

现在,我无法构建我的项目,因为我遇到了一个错误。我找到了有关错误的信息,并且我找到的解决方案说我必须添加...

compile 'com.parse.bolts:bolts-android:1.+'

致我的 app.gradle。我已经添加了同步 gradle 和 OK 结果,但是当我要构建我的 Android 项目时,它对我不起作用。因此,我实际的 build.gradle 是...

buildscript {
repositories {
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
}

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"

defaultConfig {
    applicationId "demo31.mobiltool"
    minSdkVersion 15
    targetSdkVersion 22
    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:appcompat-v7:22.2.0'
compile 'com.android.support:design:22.2.0'

compile 'com.parse.bolts:bolts-android:1.+'

compile 'com.android.support:support-v4:22.2.0'
compile 'com.google.android.gms:play-services:6+'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile('com.twitter.sdk.android:twitter:1.5.1@aar') {
    transitive = true;
}
compile 'com.google.apis:google-api-services-urlshortener:v1-rev41-1.20.0'
}

当我尝试构建我的 Android 项目时,我遇到了这些错误......

Information:Gradle tasks [:app:assembleDebug]
Warning:Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
     In case of problem, please repackage it with jarjar to change the class packages
Warning:Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for release as it may be conflicting with the internal version provided by Android.
     In case of problem, please repackage it with jarjar to change the class packages
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72220Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2220Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42220Library UP-TO-DATE
:app:prepareComDigitsSdkAndroidDigits150Library UP-TO-DATE
:app:prepareComFacebookAndroidFacebookAndroidSdk400Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServices6587Library UP-TO-DATE
:app:prepareComTwitterCobaltPerformanceMetrics020Library UP-TO-DATE
:app:prepareComTwitterSdkAndroidTweetComposer074Library UP-TO-DATE
:app:prepareComTwitterSdkAndroidTweetUi120Library UP-TO-DATE
:app:prepareComTwitterSdkAndroidTwitter151Library UP-TO-DATE
:app:prepareComTwitterSdkAndroidTwitterCore134Library UP-TO-DATE
:app:prepareIoFabricSdkAndroidFabric131Library 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:fabricGenerateResourcesDebug
:app:processDebugResources
:app:generateDebugSources
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJava UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources 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 '/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' finished with non-zero exit value 2**

我做错了什么?为了正确构建我的项目,我需要添加、删除或修改什么?

【问题讨论】:

    标签: android android-studio gradle build android-gradle-plugin


    【解决方案1】:

    您需要减小大小或仅包含应用程序所需的导入。您正在达到 65536 个方法的 dex 限制。

    这里是链接Building Apps with Over 65K Methods,它可能会有所帮助。

    【讨论】:

    • 有效!!! @Ramandeep Nanda 你救了我的命!!!!非常感谢您的出色帮助!!!
    猜你喜欢
    • 2018-08-20
    • 1970-01-01
    • 1970-01-01
    • 2018-08-12
    • 2019-04-23
    • 1970-01-01
    • 1970-01-01
    • 2012-12-09
    • 1970-01-01
    相关资源
    最近更新 更多