在AndroidX中,什么替代了appcompat-v7?

9

在将我的几个旧项目迁移到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是否有这些依赖的等效替代品?

4个回答

25

按照顺序使用:

implementation 'androidx.appcompat:appcompat:1.0.2'   
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
如果您想使用α/β版本:
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'com.google.android.material:material:1.1.0-alpha09'

发布版本的更多信息:


2

是的,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:转到重构 > 迁移至Android X

不要更改任何内容,工作室将自动更新所有内容。


2

新的Android设计库与androidx:

AppCompat:

implementation 'androidx.appcompat:appcompat:1.2.0'

CardView:
implementation 'androidx.cardview:cardview:1.0.0'

然而请注意,并非所有内容都以androidx开头。例如,旧的design dependency是:
implementation 'com.android.support:design:28.0.0'

抱歉,这是一个空的HTML块,没有任何内容。
implementation 'com.google.android.material:material:1.1.0'

Recyclerview:
implementation 'androidx.recyclerview:recyclerview:1.2.0'

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接