【问题标题】:What replaced appcompat-v7 in AndroidX在 AndroidX 中取代 appcompat-v7 的是什么
【发布时间】:2019-12-30 11:58:46
【问题描述】:
将我的几个旧项目迁移到 AndroidX 后,好像我的三个依赖项已被弃用:
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
我无法找到这些依赖项的替代品。
AndroidX 是否有这些依赖项的等价物?
【问题讨论】:
标签:
android
android-support-library
android-appcompat
androidx
material-components-android
【解决方案1】:
带有 androidx 的新 Android 设计库:
AppCompat:
implementation 'androidx.appcompat:appcompat:1.2.0'
CardViex:
implementation 'androidx.cardview:cardview:1.0.0'
但是要小心,因为一切都不是以 androidx 开头的。例如,旧的设计 依赖是:
implementation 'com.android.support:design:28.0.0'
材质:
implementation 'com.google.android.material:material:1.1.0'
回收站视图:
implementation 'androidx.recyclerview:recyclerview:1.2.0'
【解决方案2】:
按顺序使用:
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
如果您想使用 alpha/beta 版本:
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'com.google.android.material:material:1.1.0-alpha09'
有关版本的更多信息:
【解决方案3】:
是的,AndroidX 有新的依赖项。
在您的项目中使用以下实现
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.cardview:cardview:1.0.0'
代替
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
更多信息请参考以下链接:-
并确保在将项目迁移到 androidX 之前。
迁移项目的步骤(非常简单)
1 :如果不退出,则添加 gradle.properties 文件。并添加以下行
org.gradle.jvmargs=-Xmx1536M
2 : goto 重构 > 迁移到 Android X
并且不改变任何东西工作室会自动更新所有东西