Android support版本太多了
所以google出了一個Androidx來統合所有的support lib
以後只要用Androidx就可以不用匯入v7, v4等support lib了
但目前升級方式只能改了後一個一個替換
專案過舊的話升級起來就會非常麻煩
官網
升級步驟如下https://developer.android.com/jetpack/androidx/
1. 修改build.gradle內support系列換成androidx系列
implementation fileTree(include: [‘*.jar’], dir: ‘libs’)
implementation ‘androidx.appcompat:appcompat:1.0.2’
implementation ‘com.google.android.material:material:1.0.0’
implementation ‘androidx.recyclerview:recyclerview:1.0.0’
implementation ‘androidx.legacy:legacy-support-v4:1.0.0’
implementation ‘androidx.constraintlayout:constraintlayout:1.1.3’
testImplementation ‘junit:junit:4.12’
2. gradle.properties內添加
android.useAndroidX=true
android.enableJetifier=true
3. 將import換成androidx系列
ex: import androidx.appcompat.app.AppCompatActivity
4. 將Layout內的換成androidx系列
ex: androidx.constraintlayout.widget.ConstraintLayout (edited)