Android – 任务执行失败“:app:transformClassesWithMultidexlistForDebug'

当我尝试运行我非常简单的Android应用程序时,我得到以下输出:

信息:Gradle:执行任务:[:app:assembleDebug]

信息:Kotlin:Kotlin JPS插件已禁用信息:6/2/16,11:25 AM – 编译完成,1个错误,0个警告,6s 706ms

错误:Gradle:任务':app:transformClassesWithMultidexlistForDebug'的执行失败。 com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:进程'命令'/Library/Java/JavaVirtualMachines/jdk1.7.0_79。 jdk / Contents / Home / bin / java''以非零的退出值1结束

我原本没有使用multidex,我得到了与标准dex类似的错误。 这里是我没有multidex的原始输出:

信息:Gradle:执行任务:[:app:assembleDebug]

信息:Kotlin:Kotlin JPS插件已禁用信息:6/2/16,11:28 AM – 编译完成,1个错误和0个警告在7s 624ms

错误:Gradle:执行任务':app:transformClassesWithDexForDebug'失败。 com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:进程'命令'/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java''已完成非零出口值1

我想我已经尝试了所有可能的解决方案,没有任何工作。

这是我的应用程序级别build.gradle:

apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "24.0.0 rc4" defaultConfig { applicationId "com.example.XXX.testapplication" minSdkVersion 15 targetSdkVersion 23 versionCode 1 versionName "1.0" multiDexEnabled true } buildTypes { // debug { // minifyEnabled true // proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' // } release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } dexOptions { incremental = true; javaMaxHeapSize "4g" //preDexLibraries = false } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:multidex:1.0.1' compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:design:23.4.0' } 

我已经试过运行各种组合的评论和注释,你可以看到,无济于事。

我的“lib”文件夹中没有文件。

这是我的高级build.gradle:

 // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.5.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() } } task clean(type: Delete) { delete rootProject.buildDir } 

这里是我的AndroidManifest.xml:

 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.XXX.testapplication"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:name="android.support.multidex.MultiDexApplication" android:theme="@style/AppTheme"> <activity android:name=".MainActivity" android:label="@string/app_name" android:theme="@style/AppTheme.NoActionBar"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> </application> </manifest> 

如果您要集成multidex支持,那么您需要以一种忧虑的方式来做到这一点。 从这个链接

尝试进行以下更改:

将multiDexEnabled true添加到defaultConfig闭包中的gradle文件中。

在你的清单中,从支持库中添加MultiDexApplication类如下:`

 <application ... android:name="android.support.multidex.MultiDexApplication"> ... </application> 

`

还要注意的是,如果您的项目已经拥有一个Application类,那么重载一个名为attachBaseContext()的方法,并在该方法中调用:MultiDex.install(this)