我已经将我的项目迁移到androidx。在迁移之后,我得到了以下错误。
Duplicate class androidx.multidex.MultiDex found in modules classes.jar
(androidx.multidex:multidex:2.0.1) and jetified-android-support-
multidex.jar (android-support-multidex.jar)
Duplicate class androidx.multidex.MultiDex$V14 found in modules
classes.jar (androidx.multidex:multidex:2.0.1) and jetified-android-
support-multidex.jar (android-support-multidex.jar)如何解决这个问题?
找到此链接但没有答案,Duplicate class MultiDex$V14.class
下面添加了Gradle依赖项,
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "com.google.android.gms:play-services-plus:$playServiceVersion"
implementation "com.google.android.gms:play-services-auth:$playServiceVersion"
implementation "com.google.android.gms:play-services-identity:$playServiceVersion"
// Retrofit & Rx java & Dagger
implementation "com.squareup.okhttp3:logging-interceptor:$retrofitLoggerVersion"
implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
implementation "com.jakewharton.retrofit:retrofit2-rxjava2-adapter:$rxJavaAdapterVersion"
implementation "io.reactivex.rxjava2:rxjava:$rxJavaVersion"
implementation "io.reactivex.rxjava2:rxandroid:$rxAndroidVersion"
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
annotationProcessor "com.google.dagger:dagger-compiler:$daggerVersion"
implementation "com.google.dagger:dagger:$daggerVersion"
// Google services
implementation "com.google.android.gms:play-services-places:$playServiceVersion"
implementation "com.google.android.gms:play-services-location:$playServiceVersion"
implementation "com.google.android.gms:play-services-maps:$playServiceVersion"
implementation "com.google.firebase:firebase-core:$playServiceVersion"
implementation "com.google.firebase:firebase-config:$playServiceVersion"
implementation "com.google.firebase:firebase-messaging:17.3.4"
implementation "com.google.firebase:firebase-appindexing:17.1.0"
// Design libraries
implementation 'androidx.appcompat:appcompat:1.0.0'
// compile 'com.android.support:transition:26.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.browser:browser:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
annotationProcessor 'androidx.annotation:annotation:1.0.0'
implementation 'com.caverock:androidsvg:1.2.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'}
发布于 2019-08-29 18:32:13
问题是您已经定义了两次约束布局依赖关系
实施'androidx.constraintlayout:constraintlayout:1.1.3‘
发布于 2019-08-29 17:52:29
问题是你有两个类名和包名相同的库。保留androidx版本并删除androidx support version.like this
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0-beta01'
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.legacy:legacy-preference-v14:1.0.0'并在gradle属性中执行此操作
android.enableJetifier=true
org.gradle.jvmargs=-Xmx4096M -Dkotlin.daemon.jvm.options\="-
Xmx4096M" \
-XX\:MaxPermSize\=256m -XX\:+HeapDumpOnOutOfMemoryError -
Dfile.encoding\=UTF-8
org.gradle.daemon=true
org.gradle.configureondemand=true
android.useAndroidX=true
org.gradle.parallel=true还可以添加模块应用程序
defaultConfig {
applicationId "com.example.app"
minSdkVersion 17
targetSdkVersion 29
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}发布于 2019-08-29 19:37:39
我已经通过从libs中删除jar文件修复了这个问题。Multidex jar文件存在于libs文件夹中,其依赖项也存在于gradle中。
因此,在删除jar文件之后,它可以完美地运行。
https://stackoverflow.com/questions/57707477
复制相似问题