Android - transform Classes With Dex For Debug

假装没事ソ 提交于 2019-12-28 03:01:28

问题


My project was working fine until I added the Facebook dependency. I've started getting this error. I've read many question, the problem seems to be related to MultiDex. But none of the solutions worked for me

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: 
com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command 
'/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' finished with non-zero exit value 1

Even after I remove what I've added, it still show and also gradle seems to be taking a lot of time while building than usual

Here is my build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

defaultConfig {
    applicationId "net.ciblo.spectrodraft"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    multiDexEnabled true

}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

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

repositories {
    mavenCentral()
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }

}
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:cardview-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.daimajia.easing:library:1.0.1@aar'
compile 'com.daimajia.androidanimations:library:1.1.3@aar'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.pnikosis:materialish-progress:1.5'
compile 'com.nineoldandroids:library:2.4.+'
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
compile 'com.android.support:support-v4:23.2.1'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'

}

回答1:


Adding the following code to build.gradle app module solved my problem

android{
    defaultConfig {

        // Enabling multidex support.
        multiDexEnabled true
    }


    dexOptions {
        javaMaxHeapSize "4g"
    }
}
dependencies {
    //...
    compile 'com.android.support:multidex:1.0.0'
}



回答2:


you can selectively compile Google Play service APIs into your app. For example, to include only the Google Fit and Android Wear APIs, replace the following line in your build.gradle file:

 compile 'com.google.android.gms:play-services:8.4.0'

with these lines:

compile 'com.google.android.gms:play-services-fitness:8.4.0'
compile 'com.google.android.gms:play-services-wearable:8.4.0'

==> to keep the number of methods in your app (including framework APIs, library methods, and your own code) under the 65,536 limit.




回答3:


Adding the following in build.gradle fixed the issue for me,

android {
//...

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
//...
}



回答4:


This horrendous recurring issue hit me again recently. The gradle build stalls permanently at app:transformClassesWithDexForDebug, just running for hours and never completing. This time I fixed it by removing all references to 'fabric', a new layer of Crashlytics being pushed on us.

//apply plugin: 'io.fabric'   //REMOVE
//classpath 'io.fabric.tools:gradle:1.26.1'  //REMOVE


来源:https://stackoverflow.com/questions/36237253/android-transform-classes-with-dex-for-debug

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!