AGPBI: {"kind":"error","text":"Cannot fit requested classes in a single dex file (# methods: 67300 >

  • 错误信息
    
    
AGPBI: {"kind":"error","text":"Cannot fit requested classes in a single dex file (# methods: 67300 > 65536)","sources":[{}],"tool":"D8"}
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: 
The number of method references in a .dex file cannot exceed 64K.
  • 解决办法
    在项目中 加入这句代码 multiDexEnabled true   加入位置如下
android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.ms.liu"
        minSdkVersion 16
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

 

你可能感兴趣的:(编译问题)