错误:任务“:app:transformClassesWithDexForDebug"执行

时间:2023-02-14
本文介绍了错误:任务“:app:transformClassesWithDexForDebug"执行失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误

错误:任务 ':app:transformClassesWithDexForDebug' 执行失败.com.android.build.transform.api.TransformException:com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:进程'命令'/usr/lib/jvm/java-8-oracle/bin/java'' 以非零退出值 1 结束

Error:Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.build.transform.api.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-8-oracle/bin/java'' finished with non-zero exit value 1

我的应用 gradle 文件:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"
    defaultConfig {
        applicationId 'Hidden application ID'
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    lintOptions {
        disable 'InvalidPackage'
    }
    packagingOptions {
        exclude 'META-INF/services/javax.annotation.processing.Processor'
    }
    productFlavors {
    }
}

repositories {
    mavenCentral()
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:cardview-v7:23.1.1'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'
    compile 'com.google.android.gms:play-services:8.1.0'
    compile 'com.facebook.android:facebook-android-sdk:4.7.0'
    compile 'com.googlecode.libphonenumber:libphonenumber:7.2.1'
    compile 'com.getbase:floatingactionbutton:1.10.1'
    compile 'com.android.support:preference-v7:23.1.1'
}

在调试时,如果我将 minifyEnabled 设置为 true,那么它会编译.但是,我无法调试我的应用程序.

While debugging, if I set minifyEnabled to true, then it compiles. However, then I cannot debug my application.

我检查了另一个问题:任务执行失败:app:transformClassesWithDexForDebug' 在为 Android 实施 Google 登录时,但只有一个答案,不幸的是,实施它并不能解决问题.

I checked this other question: Execution failed for task ':app:transformClassesWithDexForDebug' while implementing Google sign in for Android, but there is only one answer and implementing it does not resolve the issue unfortunately.

AFAIK,错误是由于添加了太多 Gradle 依赖项引起的,但我可能错了(我真的希望是错的,因为所有这些包都非常重要!).

AFAIK, the error is caused due to addition of too many Gradle dependencies, but I may be wrong (I really hope to be wrong because all these packages are really important!).

请帮我解决这个错误.非常感谢!

Please help me to resolve this error. Much thanks!

推荐答案

只需更正 Google play 服务依赖项:

Just correct Google play services dependencies:

您的项目中包含所有播放服务.只添加你想要的.

You are including all play services in your project. Only add those you want.

例如,如果您只使用地图和 g+ 登录,则更改

For example , if you are using only maps and g+ signin, than change

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

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

来自文档:

在 6.5 之前的 Google Play 服务版本中,您必须编译整个 API 包到您的应用程序中.在某些情况下,这样做会使在您的应用程序中保持方法的数量变得更加困难(包括65,536 下的框架 API、库方法和您自己的代码)限制.

In versions of Google Play services prior to 6.5, you had to compile the entire package of APIs into your app. In some cases, doing so made it more difficult to keep the number of methods in your app (including framework APIs, library methods, and your own code) under the 65,536 limit.

从 6.5 版开始,您可以选择性地编译 Google Play服务 API 到您的应用程序中.例如,仅包含 GoogleFit 和 Android Wear API,在您的build.gradle 文件:
使用这些行编译 'com.google.android.gms:play-services:8.3.0'
:

From version 6.5, you can instead selectively compile Google Play service APIs into your app. For example, to include only the Google Fit and Android Wear APIs, replace the following line in your build.gradle file:
compile 'com.google.android.gms:play-services:8.3.0'
with these lines:

编译'com.google.android.gms:play-services-fitness:8.3.0'
编译'com.google.android.gms:play-services-wearable:8.3.0'

compile 'com.google.android.gms:play-services-fitness:8.3.0'
compile 'com.google.android.gms:play-services-wearable:8.3.0'

可在此处找到完整列表.

这篇关于错误:任务“:app:transformClassesWithDexForDebug"执行失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

上一篇:无法解决:com.google.firebase:firebase-core:11.2.0 下一篇:清单合并失败:uses-sdk:minSdkVersion 14

相关文章

最新文章