android 迁移到 androidx后 android.support.v4.content.FileProvider找不到程序报错

android.support.v4.content.FileProvider弃用,

现在修改为 androidx.core.content.FileProvider

迁移到androidx踩坑

1.首先,andorid studio的版本,需要下载至少3.2以上版本的。

下载链接:Android Studio 3.2 正式版发布! - OSCHINA

2.项目的compileSdkVersion 和 targetSdkVersion至少为28以上,引androidx的包

    implementation'androidx.appcompat:appcompat:1.0.0'

    implementation'androidx.recyclerview:recyclerview:1.0.0'

    implementation'androidx.constraintlayout:constraintlayout:1.1.2'

3. andorid studio 3.0 以上版本的引用包都切换为  implementation

    诸如此类  implementation fileTree(include: ['*.jar'],dir:'libs')

    test 切换为 testImplementation

4.app下的gradle配置添加 如下部分   

    android{

        compileOptions {

            sourceCompatibility JavaVersion.VERSION_1_8  

            targetCompatibility JavaVersion.VERSION_1_8

        }

    }

5.gradle.properties中添加配置

    android.enableJetifier=true #表示第三方库迁移到androidx

    android.useAndroidX=true #设置使用androidx

6.我此时的gradle版本为    classpath'com.android.tools.build:gradle:3.2.0'

7.此时最基本的配置就可以了,点击菜单栏的 Refactor 选择  Migrate to Androidx  

8.项目构建中。。。。一直构建中

9.此时,各种报错,兄弟们此时一定要有耐心,一个一个报错的修改。人生。。。。。。

10.此时项目中所有之前用到support v4 v7的包全部都需要换

     野路子:   全局搜索support关键字  把引用包的部分  全部换成类似下面的androidx的包

        androidx.recyclerview.widget.LinearLayoutManager;

        androidx.recyclerview.widget.RecyclerView;

    布局也全部都要搜索support关键字,替换成androidx的引用

11.还有一些需要特殊注意的,就是三方库可能因为迁移而暴露出来的错误,就需要针对具体情况进行修改了。



作者:C老王
链接:https://www.jianshu.com/p/e23918a906b5
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值