首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >迁移到Androidx后重复类androidx.multidex.MultiDex

迁移到Androidx后重复类androidx.multidex.MultiDex
EN

Stack Overflow用户
提问于 2019-08-29 17:46:30
回答 3查看 717关注 0票数 0

我已经将我的项目迁移到androidx。在迁移之后,我得到了以下错误。

代码语言:javascript
复制
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依赖项,

代码语言:javascript
复制
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'

}

EN

回答 3

Stack Overflow用户

发布于 2019-08-29 18:32:13

问题是您已经定义了两次约束布局依赖关系

实施'androidx.constraintlayout:constraintlayout:1.1.3‘

票数 2
EN

Stack Overflow用户

发布于 2019-08-29 17:52:29

问题是你有两个类名和包名相同的库。保留androidx版本并删除androidx support version.like this

代码语言:javascript
复制
  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属性中执行此操作

代码语言:javascript
复制
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

还可以添加模块应用程序

代码语言:javascript
复制
defaultConfig {
    applicationId "com.example.app"
    minSdkVersion 17
    targetSdkVersion 29
    multiDexEnabled true
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

}
票数 0
EN

Stack Overflow用户

发布于 2019-08-29 19:37:39

我已经通过从libs中删除jar文件修复了这个问题。Multidex jar文件存在于libs文件夹中,其依赖项也存在于gradle中。

因此,在删除jar文件之后,它可以完美地运行。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57707477

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档