将Android Studio更新为当前版本后,在清理并重建项目后出现以下错误:
java.lang.RuntimeException:java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException:无法合并 dex ...造成原因:java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException:无法合并 右旋 java.util.concurrent.ForkJoinTask $ AdaptedCallable.exec(ForkJoinTask.java:1431) 在java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) 在 java.util.concurrent.ForkJoinPool $ WorkQueue.runTask(ForkJoinPool.java:1056) 在 java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) 在 java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) 引起原因:com.android.builder.dexing.DexArchiveMergerException: 无法在以下位置合并dex com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:72) 在 com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:36) 在 java.util.concurrent.ForkJoinTask $ AdaptedCallable.exec(ForkJoinTask.java:1424) ... 4更多原因:com.android.dex.DexException:多个dex 文件定义 Landroid / support / design / widget / CoordinatorLayout $ Behavior;在 com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:661) 在com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:616) 在com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:598) 在com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)处 com.android.dx.merge.DexMerger.merge(DexMerger.java:198)位于 com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:61) ...还有6个
该应用程序/内部版本以前可用。
应用gradle文件如下所示:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 26
useLibrary 'org.apache.http.legacy'
defaultConfig {
multiDexEnabled true
applicationId 'com.foo.bar'
minSdkVersion 22
targetSdkVersion 23
versionCode 7
versionName "2.1.2"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
implementation "android.arch.lifecycle:extensions:1.1.1"
annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
implementation 'com.github.GrenderG:Toasty:1.2.5'
implementation 'com.jakewharton:butterknife:8.1.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.1.0'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-moshi:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.basgeekball:awesome-validation:2.0'
implementation 'com.github.apl-devs:appintro:v4.2.2'
implementation 'com.github.KyleBanks:animated-line-graph-view:v1.0.1'
// constraint layout
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
// country code picker phone numbers
implementation 'com.hbb20:ccp:2.2.2'
// firebase
implementation "com.google.android.gms:play-services-base:15.0.1"
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.3.0'
implementation group: 'com.pubnub', name: 'pubnub-gson', version: '4.18.0'
implementation 'io.pristine:libjingle:9694@aar'
implementation project(':pnwebrtc')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
apply plugin: 'com.google.gms.google-services'
repositories {
mavenCentral()
}
答案 0 :(得分:0)
您的应用程序类别如何?如果没有,则需要创建一个并将其名称放在清单文件中,因为代码应该像这样
AndroidManifest.xml
./gradlew assembleMyBuild --stacktrace
,您的应用程序类别将是:
<application
android:name="ApplicationName"
...
>
答案 1 :(得分:0)
它抱怨:
多个dex文件定义了Landroid / support / design / widget / CoordinatorLayout $ Behavior
因此,请替换为:
implemention "com.basgeekball:awesome-validation:2.0"
与此:
implemention ("com.basgeekball:awesome-validation:2.0") {
exclude group: "com.android.support.constraint", module: "constraint-layout"
}
在GitHub上也看到它也使用ConstraintLayout
。