java - Android - 任务 ':app:transformClassesWithMultidexlistForDebug' 执行失败

标签 java android gradle

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

Information:Gradle: Executing tasks: [:app:assembleDebug]

Information:Kotlin: Kotlin JPS plugin is disabled Information:6/2/16, 11:25 AM - Compilation completed with 1 error and 0 warnings in 6s 706ms

Error:Gradle: Execution failed for task ':app:transformClassesWithMultidexlistForDebug'. com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

我最初没有使用 multidex,但我在使用标准 dex 时遇到了类似的错误。这是我在没有 multidex 的情况下得到的原始输出:

Information:Gradle: Executing tasks: [:app:assembleDebug]

Information:Kotlin: Kotlin JPS plugin is disabled Information:6/2/16, 11:28 AM - Compilation completed with 1 error and 0 warnings in 7s 624ms

Error:Gradle: Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java'' finished with non-zero exit value 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 支持,那么您需要以谨慎的方式进行。 从这个link

尝试进行以下更改:

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

在您的 list 中,从支持库中添加 MultiDexApplication 类,如下所示:`

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

`

另请注意,如果您的项目已经有一个 Application 类,请覆盖名为 attachBaseContext() 的方法,并在该方法调用中: MultiDex.install(这个)

关于java - Android - 任务 ':app:transformClassesWithMultidexlistForDebug' 执行失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37595804/

相关文章:

android - 在 ListView 中更改所选项目的线性布局背景

android - android studio Gradle同步失败:不知道如何为org.gradle.tooling.internal.gradle建立模型

android-studio - 强制刷新文件

java - MissingResourceException : Can't find bundle for base name resources. controls.controls_res,语言环境

java - 如果线程停止在 Java 中如此尴尬,Eclipse 如何设法如此快速地停止线程?

java - 自执行 jar 和外部属性文件

java - 2个jpanel但不知道如何控制它们

java - 如何获取调用监听器方法的按钮

java - startsWith() 返回意外值

android - 在 xml android 中无法访问自定义 View 属性