尝试生成apk时,android studio中的livesata $ 1.class重复输入错误

SKY*_*SKY 5 java android

我真的不知道造成这个错误的原因以及如何解决它

我的所有依赖:

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.google.firebase:firebase-firestore:11.8.0'
implementation 'com.firebaseui:firebase-ui-firestore:3.2.1'
implementation 'com.google.firebase:firebase-crash:11.8.0'
implementation 'com.google.firebase:firebase-storage:11.8.0'
implementation ('com.facebook.android:facebook-android-sdk:4.31.0'){exclude group: 'com.android.support'}
implementation'com.github.bumptech.glide:glide:4.6.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
compile 'com.android.support:cardview-v7:27.1.0'
compile 'com.android.support:recyclerview-v7:27.1.0'

compile 'com.airbnb.android:lottie:2.3.0'
compile 'com.squareup.picasso:picasso:2.5.2'

compile 'com.theartofdev.edmodo:android-image-cropper:2.6.0'
compile 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.android.support:design:27.1.0'
compile 'com.android.support:multidex:1.0.3'
Run Code Online (Sandbox Code Playgroud)

一切都很好,但更新到27.1.0后

它会在生成apk时导致错误

错误:任务':app:transformClassesWithJarMergingForRelease'的执行失败.

com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:android/arch/lifecycle/LiveData $ 1.class

Non*_*hoi 3

这可能是由于依赖项的版本不匹配而发生的。我检查了它的依赖树:

android.arch.lifecycle:extensions:1.0.0
Run Code Online (Sandbox Code Playgroud)

android.arch.lifecycle:livedata-core:1.1.0
Run Code Online (Sandbox Code Playgroud)

查看不匹配的情况1.0.0&1.1.0

根据您的情况尝试更新:

implementation 'com.firebaseui:firebase-ui-firestore:3.2.1'
Run Code Online (Sandbox Code Playgroud)

到:

implementation 'com.firebaseui:firebase-ui-firestore:3.2.2'
Run Code Online (Sandbox Code Playgroud)

这应该有望解决版本问题。

并注意,compile不推荐使用它implementation来代替所有依赖项。

更新:

gradlew your_app_name:dependencies您可以随时通过Windows 中的命令检查依赖关系树