android.support迁移到androidx

Google 2018 IO 大会推出了 Android新的扩展库 AndroidX(Android 9.0),用于替换原来的 Android扩展库,将原来的android.替换成androidx.;只有包名和Maven工件名受到影响,原来的类名,方法名和字段名不会更改。官方早就推荐将support库迁移到androidx,因为后续support库不会再做更新。
迁移时只需要3.2版本及以上的android studio,在菜单refactor中点击migrate to androidx即可,该向导会提示需要做的更新。其中包括gradle版本至少3.2以上,compileSdkVersion 版本28以上。
1、常用依赖库对比

Old build artifact    AndroidX build artifact
com.android.support:appcompat-v7:28.0.2    androidx.appcompat:appcompat:1.0.0
com.android.support:design:28.0.2    com.google.android.material:material:1.0.0
com.android.support:support-v4:28.0.2    androidx.legacy:legacy-support-v4:1.0.0
com.android.support:recyclerview-v7:28.0.2    androidx.recyclerview:recyclerview:1.0.0
com.android.support.constraint:constraint-layout:1.1.2    androidx.constraintlayout:constraintlayout:1.1.2
2、常用支持库类对比

Support Library class    AndroidX class
android.support.v4.app.Fragment    androidx.fragment.app.Fragment
android.support.v4.app.FragmentActivity    androidx.fragment.app.FragmentActivity
android.support.v7.app.AppCompatActivity    androidx.appcompat.app.AppCompatActivity
android.support.v7.app.ActionBar    androidx.appcompat.app.ActionBar
android.support.v7.widget.RecyclerView    androidx.recyclerview.widget.RecyclerView
————————————————
 

官方文档:迁移到 AndroidX  |  Android 开发者  |  Android Developers

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值