Error:Error converting bytecode to dex: Multiple dex files define

前端 未结 1 1232
悲哀的现实
悲哀的现实 2020-12-21 05:12

i got this issues can u help me:

Error:Error converting bytecode to dex:

Cause: com.android.dex.DexException: Multiple dex files define Lco

1条回答
  •  囚心锁ツ
    2020-12-21 06:04

    If your minSdkVersion is set to 21 or higher, all you need to do is set multiDexEnabled to true in your app-level build.gradle file, as shown 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 app-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'
    }
    

    Create an Application class like this:

    public class MyApplication extends MultiDexApplication {
      @Override
      protected void attachBaseContext(Context base) {
         super.attachBaseContext(base);
         MultiDex.install(this);
      }
    }
    

    Add this application class in Manifest.

    
    
        
            ...
        
    
    

    You can also check this link:

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

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