Android编译错误——Duplicate class android.support.v4.os.ResultReceiver$1 found in modules jetified-and...

Execution failed for task ':launcher:checkReleaseDuplicateClasses'.
> 1 exception was raised by workers:
  java.lang.RuntimeException: Duplicate class android.support.v4.os.ResultReceiver found in modules jetified-androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and jetified-support-v4-compat.jar (support-v4-compat.jar)
  Duplicate class android.support.v4.os.ResultReceiver$1 found in modules jetified-androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and jetified-support-v4-compat.jar (support-v4-compat.jar)

Android项目导出报错,是因为v4和androidx不兼容的问题,网上有很多解决办法都是
在gradle.properties中添加以下内容

android.useAndroidX=true
android.enableJetifier=true

然后再Refactor -- Migrater to androidx
可是我的环境依然报错。

最后解决办法就是删除LIB下的support v4两个库,重新编译就好了。
截屏2021-03-23 上午12.17.17.png

你可能感兴趣的:(Android编译错误——Duplicate class android.support.v4.os.ResultReceiver$1 found in modules jetified-and...)