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

后端 未结 14 1888
被撕碎了的回忆
被撕碎了的回忆 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:09
         defaultConfig {
    
        minSdkVersion 16
        targetSdkVersion 25  
    
        multiDexEnabled true
    }
    

    Just set this in your app's build.gradle file

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

    I restart Android Studio (2.0) when I have this problem. Then it works. No edit in gradle files or turn off instant run required.

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

    attempt to set or access a value of type java.lang.Object using a local variable of type int

    Seems like in some place ProGuard optimizes variable allocation, but does it incorrectly.

    Try to disable this optimization by adding the line below in your proguard-rules.pro:

    -optimizations !code/allocation/variable

    0 讨论(0)
  • 2020-12-25 12:17
     android {
        compileSdkVersion 23
        buildToolsVersion "24.0.0"
    
        defaultConfig {
            ...
            minSdkVersion 14
            targetSdkVersion 23
            ...
    
            // Enabling multidex support.
            multiDexEnabled true
        }
        ... }
    
        dependencies {   compile 'com.android.support:multidex:1.0.0' }
    
        repositories {
        mavenCentral() }
    
    
        <application    ...
        android:largeHeap="true"
        android:supportsRtl="true"
        android:name="android.support.multidex.MultiDexApplication"> </application>
    
    0 讨论(0)
  • 2020-12-25 12:21

    This works for me,

    1. In build.gradle, put your current android version as example 3.0.1

      dependencies { classpath 'com.android.tools.build:gradle:3.0.1'}

    2. In gradle-wrapper.properties, change your gradle version as example gradle-4.4 distributionUrl=https://services.gradle.org/distributions/gradle-4.4-all.zip

    I hope this can help!

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

    The accepted answer might work, but I'll share what fixed this with me. It was due to the maximum number of methods being reached after the addition of an additional library dependency.

    See this guide here to fix, skip down to Configuring Your App for Multidex with Gradle section to get to the point.

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