com.android.builder.dexing.DexArchiveMergerException: 无法合并 dex
com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
在 Android Studio 3.6
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
maven { url 'https://maven.fabric.io/public' }
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'io.fabric.tools:gradle:1.25.4'
classpath "com.jaredsburrows:gradle-license-plugin:0.8.41"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
在 app/build.gradle:
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 17
targetSdkVersion 28
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
manifestPlaceholders = [
fabricApiKey: keystoreProperties['FabricApiKey'] != null
? keystoreProperties['FabricApiKey']
: ""
]
multiDexKeepFile file('multidex-keep.txt')
}
但是在构建时出现错误:
> Task :app:transformClassesWithMultidexlistForDebug
> Task :app:mergeDexDebug FAILED
java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:593)
at java.util.concurrent.ForkJoinTask.reportException(ForkJoinTask.java:677)
at java.util.concurrent.ForkJoinTask.join(ForkJoinTask.java:720)
改为
compilsdkVersion 29
minSdkVersion 15
targetSdkVersion 29
在 Android Studio 3.6
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
maven { url 'https://maven.fabric.io/public' }
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'io.fabric.tools:gradle:1.25.4'
classpath "com.jaredsburrows:gradle-license-plugin:0.8.41"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
在 app/build.gradle:
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 17
targetSdkVersion 28
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
manifestPlaceholders = [
fabricApiKey: keystoreProperties['FabricApiKey'] != null
? keystoreProperties['FabricApiKey']
: ""
]
multiDexKeepFile file('multidex-keep.txt')
}
但是在构建时出现错误:
> Task :app:transformClassesWithMultidexlistForDebug
> Task :app:mergeDexDebug FAILED
java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:593)
at java.util.concurrent.ForkJoinTask.reportException(ForkJoinTask.java:677)
at java.util.concurrent.ForkJoinTask.join(ForkJoinTask.java:720)
改为
compilsdkVersion 29
minSdkVersion 15
targetSdkVersion 29