Android 任务';的执行失败:应用程序:TransformClasses with DexForDeBug';-格雷德尔依赖?

Android 任务';的执行失败:应用程序:TransformClasses with DexForDeBug';-格雷德尔依赖?,android,android-studio,Android,Android Studio,我不想开始一个与这个问题相关的新问题,因为我知道已经有一些问题了,但我仍然没有找到解决方案,我被卡住了 我当前收到错误信息: 错误:任务“:app:transformClassesWithDexForDebug”的执行失败 com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:org.gradle.process.internal.exeception:

我不想开始一个与这个问题相关的新问题,因为我知道已经有一些问题了,但我仍然没有找到解决方案,我被卡住了

我当前收到错误信息:

错误:任务“:app:transformClassesWithDexForDebug”的执行失败

com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:org.gradle.process.internal.exeception:process'command'/Library/Java/JavaVirtualMachines/jdk1.7.079.jdk/Contents/Home/bin/Java''以非零退出值2结束

这就是Gradle控制台所展示的

意外的顶级异常:com.android.dex.DexException:多个dex文件定义Lbolts/aggregateeexception;在 com.android.dx.merge.dexmmerge.readSortableTypes(dexmmerge.java:579) 在com.android.dx.merge.dexmerge.getSortedTypes上(dexmerge.java:535) 位于com.android.dx.merge.dexmerge.mergeClassDefs(dexmerge.java:517) 位于com.android.dx.merge.dexmerge.mergeDexes(dexmerge.java:164) com.android.dx.merge.dexmmerge.merge(dexmmerge.java:188)位于 com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504) 位于com.android.dx.command.dexer.Main.runMonoDex(Main.java:334) com.android.dx.command.dexer.Main.run(Main.java:277)位于 com.android.dx.command.dexer.Main.Main(Main.java:245)位于 com.android.dx.command.Main.Main(Main.java:106)

失败

失败:生成失败,出现异常

  • 错误:任务“:app:transformClassesWithDexForDebug”的执行失败

    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” 以非零退出值2结束

  • 尝试:使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获得更多日志输出

构建失败

这是我的身材。格雷德尔:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.andrewnwalker.mousetimes_california"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.parse.bolts:bolts-android:1.+'
    compile fileTree(dir: 'libs', include: ['Parse-*.jar'])
    compile files('libs/Parse-1.12.0.jar')
    compile files('libs/bolts-tasks-1.3.0.jar')
    compile files('libs/universal-image-loader-1.9.5.jar')
    compile files('libs/joda-time-2.9.1.jar')
}
我尝试过所有显而易见的事情,比如清洁、重建、打开/关闭。我还尝试删除一些依赖项,看看这是否会有所不同

据我所知,我没有改变任何事情,从什么时候起,它运行良好。我很确定我刚刚连续第二次运行了这个项目,出现了错误。不过我可能错了


有人有什么建议吗?

最近,我遇到了同样的问题,下面是我的解决方案,包括两个步骤:

  • 顶级毕业生:

    // 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:2.0.0-alpha3'
        classpath 'com.google.gms:google-services:2.0.0-alpha3'//for any google libs
       }
     }
    
    allprojects {
    repositories {
          jcenter()
        }
    }
    
  • 模块(应用程序)级别等级:

    apply plugin: 'com.android.application'
    
    android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    
    
    defaultConfig {
        applicationId "your_app_id"
        minSdkVersion 9
        targetSdkVersion 22
        // Enabling multidex support can also help (uncomment and test)
        //multiDexEnabled true
    }
    
    buildTypes {
        release {
            //minifyEnabled true
            //shrinkResources true
            proguardFiles 'proguard-project.txt'
        }
    }
    
    } 
    
    dependencies {
    //your dependencies
    }
    apply plugin: 'com.google.gms.google-services' **//Place this line at the end if you use any google service lib.**
    

  • 像这样更新你的顶级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:2.0.0-alpha3'
            classpath 'com.google.gms:google-services:2.0.0-alpha3'
    
            // 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
    }
    
    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.2"
    
        defaultConfig {
            // package name, target sdk and version code as per your code
            multiDexEnabled true
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
        dexOptions {
            incremental true
            javaMaxHeapSize "4g"
        }
    }
    
    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        // your libraries here
        compile 'com.google.android.gms:play-services:8.4.0'
        compile 'com.android.support:multidex:1.0.1'
    }
    
    apply plugin: 'com.google.gms.google-services'
    
    <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">
    
    像这样更新你的应用程序级别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:2.0.0-alpha3'
            classpath 'com.google.gms:google-services:2.0.0-alpha3'
    
            // 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
    }
    
    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.2"
    
        defaultConfig {
            // package name, target sdk and version code as per your code
            multiDexEnabled true
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
        dexOptions {
            incremental true
            javaMaxHeapSize "4g"
        }
    }
    
    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        // your libraries here
        compile 'com.google.android.gms:play-services:8.4.0'
        compile 'com.android.support:multidex:1.0.1'
    }
    
    apply plugin: 'com.google.gms.google-services'
    
    <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">
    
    然后像这样更新你的android清单文件

    // 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:2.0.0-alpha3'
            classpath 'com.google.gms:google-services:2.0.0-alpha3'
    
            // 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
    }
    
    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.2"
    
        defaultConfig {
            // package name, target sdk and version code as per your code
            multiDexEnabled true
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
        dexOptions {
            incremental true
            javaMaxHeapSize "4g"
        }
    }
    
    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        // your libraries here
        compile 'com.google.android.gms:play-services:8.4.0'
        compile 'com.android.support:multidex:1.0.1'
    }
    
    apply plugin: 'com.google.gms.google-services'
    
    <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">
    

    看看这是否有效。

    我尝试了一下您的建议(其中一些我已经尝试过了),但不幸的是,它没有改变任何东西。