新建工程,导入旧的module,出现Android Studio duplicate entry xx.class

站长公众号

前言

这个是导入SystemUI时出现的,记录一下,方便自己查阅。

好记性不如烂笔头

正文

导入旧的module后出现:

Cause: duplicate entry: androidx/core/R$attr.class

更多日志

Execution failed for task ':SystemUI:compileReleaseJavaWithJavac'.
> Could not resolve all files for configuration ':SystemUI:releaseCompileClasspath'.
   > Failed to transform android-support-v13_classes.jar to match attributes {artifactType=android-classes-jar, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
      > Execution failed for JetifyTransform: E:\AndroidAllApp\libs\android-support-v13_classes.jar.
         > Failed to transform 'E:\AndroidAllApp\libs\android-support-v13_classes.jar' using Jetifier. Reason: ZipException, message: duplicate entry: androidx/core/R$attr.class. (Run with --stacktrace for more details.)
   > Failed to transform android-support-v4_classes.jar to match attributes {artifactType=android-classes-jar, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
      > Execution failed for JetifyTransform: E:\AndroidAllApp\libs\android-support-v4_classes.jar.
         > Failed to transform 'E:\AndroidAllApp\libs\android-support-v4_classes.jar' using Jetifier. Reason: ZipException, message: duplicate entry: androidx/core/R$attr.class. (Run with --stacktrace for more details.)
   > Failed to transform SettingsLib_classes.jar to match attributes {artifactType=android-classes-jar, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
      > Execution failed for JetifyTransform: E:\AndroidAllApp\libs\SettingsLib_classes.jar.
         > Failed to transform 'E:\AndroidAllApp\libs\SettingsLib_classes.jar' using Jetifier. Reason: ZipException, message: duplicate entry: androidx/core/R$anim.class. (Run with --stacktrace for more details.)

解决方式

细心的你或许会发现,上面三个jar出现一样的错误信息:

   > Failed to transform xxx.jar to match attributes {artifactType=android-classes-jar, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
      > Execution failed for JetifyTransform: E:\AndroidAllApp\libs\xxx.jar.

经过查询和验证,发现新版本的Android Studio( 我的V4.1.2)在创建工程时有默认配置,第三方库自动转换使用AndroidX

具体看gradle.properties中的

#gradle.properties

# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

把[android.enableJetifier=true] 这句去掉就可以ok了。

PS: 本文有试过《Android Studio duplicate entry: xx.class 相关问题的处理方法》中的方法,但没有效果,不同的情况可能不同。如果我的解决不了的你问题,你可以看看文末的文章。

参考文章

  1. Android Studio duplicate entry: xx.class 相关问题的处理方法

站长公众号
版权声明:125la.com站长 发表于 2021年10月3日 上午8:08 。
转载请注明: 新建工程,导入旧的module,出现Android Studio duplicate entry xx.class | 125啦读书导航

相关文章

站长公众号

暂无评论

暂无评论...