android - 错误:Execution failed for task ':app:transformClassesWithDexForDebug' .没有解决

标签 android android-studio library-project

我可能已经尝试过关于这个问题的所有解决方案。 完整的错误是:Error:Execution failed for task "

':app:transformClassesWithDexForDebug'.
> 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

" 我正在发布我的 build.gradle 脚本: 脚本名称:RajawaliCardBoardExample-master

// 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()
    }
}

名称:模块:应用>>

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.2'
    dexOptions {
        incremental true
        javaMaxHeapSize "4g"
        jumboMode = true
    }

    defaultConfig {
        applicationId "com.eje_c.rajawalicardboard"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':rajawalicardboard')
    compile project(':lib_panorama_max')
    compile 'com.android.support:multidex:1.0.1'
}

名称:模块:lib_panorama_max >>

apply plugin: 'java'

task nativeLibsToJar(type: Zip, description: 'create a jar archive of the native libs') {
    destinationDir file("$buildDir/native-libs")
    baseName 'native-libs'
    extension 'jar'
    from fileTree(dir: 'libs', include: '**/*.so')
    into 'lib/'
}

tasks.withType(JavaCompile) {
    compileTask -> compileTask.dependsOn(nativeLibsToJar)
        options.encoding = "UTF-8"
        options.debug = true
        options.debugOptions.debugLevel = "source,lines,vars"
        options.encoding = "UTF-8"
}


dependencies {
    compile files('libs/commons-httpclient-3.1.jar')
    compile files('libs/android.jar')
    compile fileTree(dir: 'build/native-libs', include: ['*.jar'])
}

名称:模块:Rajawali >>

apply plugin: 'com.android.library'

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.2'
    dexOptions {
        incremental true
        javaMaxHeapSize "2048M"
        jumboMode = true
    }
    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

名称:模块:rajawalicardboard >>

apply plugin: 'com.android.library'


android {
    compileSdkVersion 23
    buildToolsVersion '23.0.2'
    dexOptions {
        incremental true
        javaMaxHeapSize "2048M"
        jumboMode = true
    }

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')

    compile project(':rajawali')
}

请帮忙整理一下! :(

最佳答案

首先你应该添加

 defaultConfig
 {

    // Enabling multidex support.
       multiDexEnabled true
 }

打开 Module:app 。你在这里缺少 multiDexEnabled true

defaultConfig {
    applicationId "com.eje_c.rajawalicardboard"
    minSdkVersion 16
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    multiDexEnabled true

}

阅读有关的官方文档MultiDex

关于android - 错误:Execution failed for task ':app:transformClassesWithDexForDebug' .没有解决,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36030290/

相关文章:

android - 如何将库项目添加到 android 项目?

android - 如何在不使用新图像的情况下减小Android单选按钮上显示的图像大小

android - 通过android内置相机拍摄图像,但不保存

java - Android 单击小部件时启动新 Activity

java - Android Studio 中 Marvel API key 的使用

java - 如何将 Android 库项目转换为外部 JAR?

Android JUNIT 测试卡住了

安卓 2.3 : Read-Only file system stuck

android - "Error:(2) Error retrieving parent for item No resource found that matches the given name ' android :TextAppearance. Material.Widget.Button.Inverse'

android - 开源 Android 库?可重用 View 、 View 组、适配器等?