【问题标题】:Error:Execution failed for task ':app:transformClassesWithDexForDebug'. not solving错误:任务“:app:transformClassesWithDexForDebug”执行失败。不解决
【发布时间】:2016-03-16 08:28:59
【问题描述】:

我可能已经尝试了有关此问题的所有解决方案。 完整的错误是:错误:任务“执行失败”

':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()
    }
}

名称:模块:app >>

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')
}

请帮忙解决! :(

【问题讨论】:

  • 尝试将multiDexEnabled true 也放入Module:app..
  • 什么都没发生,先生。 @ShreeKrishna

标签: android android-studio library-project


【解决方案1】:

首先你应该添加

 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

的官方文档

【讨论】:

  • 对于测试用例从应用程序中删除multiDexEnabled true
  • Module:Rajawali省略multiDexEnabled true
  • 我已经从 module:app 和 module:rajawali 中删除了 multiDexEnabled true 但问题仍然存在! :(
  • IntelliJ 先生,请解决这个问题。 3天过去了,问题仍然没有解决:( :(
  • @IndranilDutta 好的。调用classpath 'com.android.tools.build:gradle:2.0.0-alpha2' 而不是.tools.build:gradle:1.5.0'
【解决方案2】:

选项 1 是添加 multiDexEnabled true 但是你告诉它根本不起作用,你现在可以尝试排除group group: 'com.android.support', module: 'multidex' 这意味着在编译中例如更改

compile project(':rajawalicardboard')

compile project(':rajawalicardboard'){
        exclude group: 'com.android.support', module: 'multidex'
    }

不要只尝试这个,如果只是上面的更改不起作用,请在 compile project(':lib_panorama_max') 中做同样的事情。也尝试删除compile 'com.android.support:multidex:1.0.1'

【讨论】:

  • 在完成所有这些操作后,会生成此错误:错误:(39, 0) Gradle DSL method not found: 'exclude()' 可能的原因:
    • 项目 'RajawaliCardboardExample-master'可能正在使用不包含该方法的 Gradle 版本。 Gradle 设置
    • 构建文件可能缺少 Gradle 插件。 应用 Gradle 插件
  • 先生,请 rly :( :(
  • @ShreeKrishna 你是真的。非常复杂的 Gradle
  • 实际上 rajawalicardboard 只是使用 cardboardviewer 查看 360 全景的功能。您也可以从 google play 中找到 cardboardviewer 的应用程序,lib_panorama_max 是 360 全景的库项目。两者都是从开源下载的库项目。问题是 lib_panorama 可以在 Eclipse 中工作,但 rajawalicardboard 只能在 android studio 中工作。这就是为什么对于项目开发,两个库项目需要一起工作。现在,我很无助。我和我的队长都很担心! :(
  • @IntelliJAmiya 兄弟,他似乎真的有麻烦了,如果你有时间看看他的项目,任何帮助都会非常感激......
猜你喜欢
  • 2016-02-16
  • 1970-01-01
  • 2023-03-22
  • 1970-01-01
  • 2017-09-01
  • 1970-01-01
  • 2016-02-28
  • 2016-09-26
相关资源
最近更新 更多