java - 编译 Android 应用程序时出错 - 任务 :app:transformClassesWithDexForDebug 执行失败

标签 java android android-gradle-plugin build.gradle

在添加谷歌地图 Activity 之前,我的应用程序已正确编译。然后我得到这个错误

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-8-openjdk-amd64/bin/java'' finished with non-zero exit value 2

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.






Error:The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
:app:transformClassesWithDexForDebug FAILED
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-8-openjdk-amd64/bin/java'' finished with non-zero exit value 2

build.gradle

android {
    compileSdkVersion 24
    buildToolsVersion "23.0.3"
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "zupportdesk.desk.zupport.chatsystem"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'

    compile 'com.android.support:appcompat-v7:24.2.0'
    compile 'com.android.support:recyclerview-v7:24.2.0'
    compile 'com.android.support:design:24.2.0'
    compile 'com.android.support:cardview-v7:24.2.0'
    compile 'org.java-websocket:Java-WebSocket:1.3.0'
    compile 'com.google.android.gms:play-services:9.4.0'
    compile 'br.com.liveo:navigationdrawer-material:2.5.1'



    compile files('libs/gson-2.2.2.jar')
    compile files('libs/signalr-client-sdk-android.jar')
    compile files('libs/signalr-client-sdk.jar')

}

有人可以帮我解决这个问题吗? tnx

最佳答案

添加google map 后,方法和引用计数超过64K:

Error:The number of method references in a .dex file cannot exceed 64K.

这是一个大问题,每个大项目都会遇到这样的问题。但Google给出了解决方案:Configure Apps with Over 64K Methods .

希望这可以帮助你。

关于java - 编译 Android 应用程序时出错 - 任务 :app:transformClassesWithDexForDebug 执行失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39291735/

相关文章:

android-studio - Jetpack Compose 和 Hilt 冲突

android - gradle 忽略 FileNotFoundException 以加载属性文件

java - 使用 compose 创建 CompletableFutures 的链接列表

android - 如何在 Android 中删除对话框的标题

java - 我如何在Java中解析这些元素

javascript - 当应用程序在后台运行时,响应 native 电源按钮长按监听器

android - 在任务 ':app:kaptReleaseKotlin' 的执行失败中找不到错误

android - Gradle - 选择性模块编译(否则重用 jar)

java - Selenium sendkeys 不输入文本

java - java中如何获取泛型类的类型?