Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/381.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android-任务';的执行失败:app:TransformClasses与Debug的多索引列表';_Java_Android_Gradle - Fatal编程技术网

Java Android-任务';的执行失败:app:TransformClasses与Debug的多索引列表';

Java Android-任务';的执行失败:app:TransformClasses与Debug的多索引列表';,java,android,gradle,Java,Android,Gradle,当我尝试运行非常简单的android应用程序时,我得到以下输出: 信息:梯度:执行任务:[:app:assembleDebug] 信息:Kotlin:Kotlin JPS插件已禁用信息:6/2/16, 上午11:25-编译完成,6秒内出现1个错误和0个警告 706ms 错误:梯度:任务的执行失败 “:app:transformclasses with multi-dexlistfordebug”。 com.android.build.api.transform.TransformExceptio

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

信息:梯度:执行任务:[:app:assembleDebug]

信息:Kotlin:Kotlin JPS插件已禁用信息:6/2/16, 上午11:25-编译完成,6秒内出现1个错误和0个警告 706ms

错误:梯度:任务的执行失败 “:app:transformclasses with multi-dexlistfordebug”。 com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException:process'命令 “/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/Java” 以非零退出值1结束

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

信息:梯度:执行任务:[:app:assembleDebug]

信息:Kotlin:Kotlin JPS插件已禁用信息:6/2/16, 上午11:28-编译已完成,7秒内出现1个错误和0个警告 624ms

错误:梯度:任务的执行失败 “:app:transformClassesWithDexForDebug”。 com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:process'命令 “/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'
}
// 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
}
正如您所看到的,我尝试过使用注释行和未注释行的各种组合来运行,但没有效果

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

这是我的高级版本。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'
}
// 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>

如果您要集成多索引支持,则需要谨慎地进行。 由此

尝试执行以下更改:

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

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


...
`

另外请注意,如果您的项目已经有一个应用程序类,请重写名为attachBaseContext()的方法,并在该方法调用中:
MultiDex.install(此)

能否显示整个gradle输出,而不仅仅是错误?我该怎么做?对不起,我对这项技术很陌生。嗯,你从某处复制了那个错误,是吗?你也可以用上面的输出来回答你的问题。而且,你可能不需要多重索引。人们喜欢认为这是解决所有gradle错误的神奇方法,但事实并非如此。我创建了一个全新的项目,而且一切都正常。我之前测试的项目也是一个全新的项目,所以我不知道为什么它不起作用。不管怎样,哈哈,谢谢你的帮助!除了关于attachBaseContext()的部分外,我已经完成了所有这些。当我试图在扩展AppCompatActivity的MainActivity.java类中重写该方法时,它说@override标记是一个错误,因为它没有重写超类中的任何方法。@如果不将其放入Activity,则会将其放入扩展MultidexApplication的应用程序类中,正如我们所看到的,您不需要multidex,因为它不能解决问题而不是扩展应用程序,扩展multidex应用程序@cricket_007您是对的,一般来说,如果依赖项较少或没有依赖项,则不需要使用Multidex。