介绍
大家对Android Support Libray都不陌生,不过谷歌官方已经停止更新,原因是版本管理有些乱,开发中也经常会碰到各种compat 而且原来越多,所以谷歌开始规范支持包。
Google推出了androidx来取代Support,所以以后Support肯定慢慢会被淘汰的
官方地址 androidx
迁移到AndroidX
- 如果是新建项目,可以再创建项目是勾选
- Use androidx.* artifacts
2. 借助 Android Studio 3.2 及更高版本,您可以通过从菜单栏中依次选择 Refactor > Migrate to AndroidX,快速迁移现有项目以使用 AndroidX。
替换前:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
替换后:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
}