Android studio 2.0 gradle transformClassesWithDexForDebug fails when using button “run”

后端 未结 14 1895
被撕碎了的回忆
被撕碎了的回忆 2020-12-25 11:21

I have a problem after migration from android studio 1.5 to 2.0

In one of my project (only one) i can\'t use android studio run button,

because then, build

相关标签:
14条回答
  • 2020-12-25 12:00

    None of the above worked for me, but this developer.android.come guide worked out for me:

    https://developer.android.com/studio/build/multidex.html

    It says the following:

    If your minSdkVersion is set to 21 or higher, all you need to do is set multiDexEnabled to true in your module-level build.gradle file, as enter code hereshown here:

    android {
        defaultConfig {
            ...
            minSdkVersion 21 
            targetSdkVersion 25
            multiDexEnabled true
        }
        ...
    }
    

    However, if your minSdkVersion is set to 20 or lower, then you must use the multidex support library as follows:

    Modify the module-level build.gradle file to enable multidex and add the multidex library as a dependency, as shown here:

    android {
        defaultConfig {
            ...
            minSdkVersion 15 
            targetSdkVersion 25
            multiDexEnabled true
        }
        ...
    }
    
    dependencies {
      compile 'com.android.support:multidex:1.0.1'
    }
    
    0 讨论(0)
  • 2020-12-25 12:04

    for few weeks i was trying to solve this problem.

    Now I have found workaround for that. If someone face the same problem, turning off instant Run in Android Studio settings will help.

    I know that it is not a solution but it is the best thing for now.

    cheers Wojtek

    0 讨论(0)
  • 2020-12-25 12:08

    For me adding this line (or commenting out because it is written there in the 13th line) in gradle.properties worked:

    org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
    

    Also I turned off Instant run (Android Studio 2.1.2).

    0 讨论(0)
  • 2020-12-25 12:08

    Refactoring the library helped me resolving this issue. This must have helped in removing duplicate classes from the library or from the app module.

    0 讨论(0)
  • 2020-12-25 12:09

    All it took to fix this issue for me was to add the following lines to the build.gradle file for the mobile app:

    ...

    android {

        ...
    
        // Enabling multidex support.
        multiDexEnabled true
    }
    
    dexOptions {
        javaMaxHeapSize "4g"
    }
    
    ...
    

    }

    dependencies {

    ...
    
    compile 'com.android.support:multidex:1.0.0'
    
    ...
    

    }

    0 讨论(0)
  • 2020-12-25 12:09

    I discovered many solutions but I solved this issue by adding:

    Sol 1: In build.gradle:

    defaultConfig {
        multiDexEnabled true
    }
    

    Clean your project and rebuild.

    Sol 2: If still you have issue in local.properties add,

    org.gradle.jvmargs=-XX\:MaxHeapSize\=512m -Xmx512m
    

    Sol 3 Still, You have issue add below mentioned dependency:

    compile 'com.android.support:multidex:1.0.1'
    

    Anyone solution will definitely work for you. Otherwise add all 3 in your application.

    0 讨论(0)
提交回复
热议问题