美文网首页
support转androidx 遇到的坑

support转androidx 遇到的坑

作者: 晓晓桑 | 来源:发表于2019-08-01 18:35 被阅读0次

为什么要转成androidx呢?因为报错:

Caused by: java.lang.RuntimeException: Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0]

怎么转呢

image.png

注意一定要备份哦

遇到的问题

  • 自动没转成androidx包的,要手动转。
  • 第一个参数改成 Lazy<FragmentManager.FragmentLifecycleCallbacks> 类型的即可
(FragmentActivity) activity).getSupportFragmentManager().registerFragmentLifecycleCallbacks(@NonNull FragmentLifecycleCallbacks cb,
            boolean recursive)
  • 包名全改成功,但是clean之后,rebuild的时候,那些build里面的文件包名竟然没改。发现原因:Glide 中的注解不兼容AndroidX
    解决:
 //图片加载——Glide
implementation "com.github.bumptech.glide:glide:4.8.0
annotationProcessor "com.github.bumptech.glide:compiler:4.8.0

兼容androidx
implementation "com.android.support:support-annotations:28.0.0-alpha3"
annotationProcessor "com.android.support:support-annotations:28.0.0-alpha3"
  • butterknife设置到9.0.0以后
  • 如果发现layout报错,把控件改成anroidx包下的就阔以啦。
    到此完美转换。

相关文章

网友评论

      本文标题:support转androidx 遇到的坑

      本文链接:https://www.haomeiwen.com/subject/qmbcdctx.html