错误:在 android studio 中执行任务 ':app:transformClassesWithDexForDebug' 失败 [英] Error:Execution failed for task ':app:transformClassesWithDexForDebug' in android studio

查看:28
本文介绍了错误:在 android studio 中执行任务 ':app:transformClassesWithDexForDebug' 失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将我的项目从 eclipse 转移到 Android Studio.在运行我的应用程序之一时,我收到以下错误.无法找到任何解决方案.我也启用了 multidex.

I am moving my projects from eclipse to Android Studio. While running one of my app I get the following error. Not able to find any solution. I have enabled multidex as well.

错误:任务执行失败':app:transformClassesWithDexForDebug'.com.android.build.api.transform.TransformException:java.lang.RuntimeException:com.android.ide.common.process.ProcessException:java.util.concurrent.ExecutionException:com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' 以非零退出值 1 结束

Error:Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1

我的 gradle 文件也在下面

also my gradle file is below

apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
    applicationId "com.myapp"
    minSdkVersion 9
    targetSdkVersion 21
    multiDexEnabled true
}buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard- android.txt'), 'proguard-project.txt', 'proguard-google-api-client.txt'
     }
   }
 }
 dependencies {
 compile 'com.android.support:support-v4:23.4.0'
 compile 'com.google.android.gms:play-services:+'
 compile 'com.google.http-client:google-http-client-gson:1.20.0'
compile 'com.google.code.gson:gson:2.1'
compile 'com.android.support:appcompat-v7:23.4.0'
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')
compile files('libs/android-support-v7-cardview.jar')
compile files('libs/android-support-v7-recyclerview.jar')
compile files('libs/commons-logging-1.1.1.jar')
compile 'com.google.api-client:google-api-client:1.18.0-rc'
compile 'com.google.api-client:google-api-client-android:1.18.0-rc'
compile 'com.google.api-client:google-api-client-appengine:1.18.0-rc'
compile 'com.google.http-client:google-http-client:1.18.0-rc'
compile 'com.google.http-client:google-http-client-android:1.18.0-rc'
compile 'com.google.http-client:google-http-client-appengine:1.18.0-rc'
compile 'com.google.oauth-client:google-oauth-client:1.18.0-rc'
compile 'com.google.oauth-client:google-oauth-client-appengine:1.18.0-rc'
compile files('libs/google-api-client-gson-1.18.0-rc.jar')
compile files('libs/google-api-client-jackson2-1.18.0-rc.jar')
compile files('libs/google-api-client-java6-1.18.0-rc.jar')
compile files('libs/google-api-client-servlet-1.18.0-rc.jar')
compile files('libs/google-http-client-jackson2-1.18.0-rc.jar')
compile files('libs/google-http-client-jdo-1.18.0-rc.jar')
compile files('libs/google-oauth-client-java6-1.18.0-rc.jar')
compile files('libs/google-oauth-client-jetty-1.18.0-rc.jar')
compile files('libs/google-oauth-client-servlet-1.18.0-rc.jar')
compile files('libs/GraphView-4.0.1.jar')
compile files('libs/httpclient-4.0.1.jar')
compile files('libs/httpcore-4.0.1.jar')
compile files('libs/jackson-core-2.1.3.jar')
compile files('libs/jetty-6.1.26.jar')
compile files('libs/jetty-util-6.1.26.jar')
compile files('libs/jsr305-1.3.9.jar')
compile files('libs/jxl.jar')
compile files('libs/mail.jar')
compile files('libs/transaction-api-1.1.jar')
 }

推荐答案

错误:任务执行失败':app:transformClassesWithDexForDebug'.com.android.build.api.transform.TransformException:java.lang.RuntimeException:com.android.ide.common.process.ProcessException:java.util.concurrent.ExecutionException:com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:处理'命令'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' 完成非零退出值 1

Error:Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1

由于很多原因,出现了上面的错误.所以我可以说明为什么会出现这个错误以及如何解决它.

The upper error occure due to lot of reason. So I can put why this error occure and how to solve it.

原因 1: 类文件名重复

解决方案:

当您将某些类文件重构为库项目时.那个时候你写了类文件的名字所以,仔细检查你没有任何重复的名字

when your refactoring of some of your class files to a library project. and that time you write name of class file So, double check that you do not have any duplicate names

原因 2:当你有很多缓存内存

解决方案:

有时如果您有很多缓存,则会出现此错误,因此请解决它.转到 File/Invalidate caches/Restart 然后选择 Invalidate and Restart 它将清理你的缓存.

Sometime if you have lot of cache memory then this error occure so solve it. go to File/Invalidate caches / Restart then select Invalidate and Restart it will clean your cache memory.

原因 3 : 当存在内部错误或使用测试版时切换回稳定版.

REASON 3 : When there is internal bug or used beta Version to Switch back to stable version.

解决方案:

解决方案很简单,转到 Build 菜单并单击 Clean Project,清理后单击 Rebuild Project.

Solution is just simple go to Build menu and click Clean Project and after cleaning click Rebuild Project.

原因 4 : 当系统内存不足时.

解决方案:

打开任务管理器并停止当时不常用的其他应用程序,以便释放空间并解决OutOfMemory.

open Task Manager and stop the other application which are not most used at that time so it will free the space and solve OutOfMemory.

原因 5: 问题是您的方法数已超过 65K.

REASON 5 : The problem is your method count has exceed from 65K.

解决方案:

打开你的项目 build.gradle 文件添加

open your Project build.gradle file add

defaultConfig {
        ...
        multiDexEnabled true
    }

并在依赖项中添加以下行.

and in dependencies add below line.

dependencies 
    {
       compile 'com.android.support:multidex:1.0.0'
    }

这篇关于错误:在 android studio 中执行任务 ':app:transformClassesWithDexForDebug' 失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆