AndroidX 迁移 - androidx.legacy:legacy-support-v4 或 androidx.appcompat:appcompat
AndroidX migration - androidx.legacy:legacy-support-v4 or androidx.appcompat:appcompat
我尝试将其中一个旧项目迁移到 AndroidX,方法是使用 Android Studio/ Refactor/ Migrate to AndroidX...
但是,对于某些库项目,当我浏览它们的 build.gradle
时,我注意到 Android Studio 正在将行从
implementation 'com.android.support:support-v4:28.0.0'
到
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
我原以为迁移的行应该是
implementation 'androidx.appcompat:appcompat:1.0.0'
请问为什么会这样? androidx.legacy:legacy-support-v4:1.0.0
和 androidx.appcompat:appcompat:1.0.0
我都试过了。他们都编译和执行得很好。
但是,哪个是正确的?图书馆正在使用 androidx.viewpager.widget.ViewPager
.
class androidx.viewpager.widget.ViewPager
包含在androidx.viewpager:viewpager:1.0.0
您可以在 doc:
中找到有关库映射的信息
com.android.support:support-v4 -> androidx.legacy:legacy-support-v4
com.android.support:appcompat-v7 -> androidx.appcompat:appcompat
androidx.viewpager:viewpager
库也是 transitive dependency 的:
androidx.legacy:legacy-support-v4
-- androidx.legacy:legacy-support-core-ui
-- -- androidx.viewpager:viewpager
我尝试将其中一个旧项目迁移到 AndroidX,方法是使用 Android Studio/ Refactor/ Migrate to AndroidX...
但是,对于某些库项目,当我浏览它们的 build.gradle
时,我注意到 Android Studio 正在将行从
implementation 'com.android.support:support-v4:28.0.0'
到
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
我原以为迁移的行应该是
implementation 'androidx.appcompat:appcompat:1.0.0'
请问为什么会这样? androidx.legacy:legacy-support-v4:1.0.0
和 androidx.appcompat:appcompat:1.0.0
我都试过了。他们都编译和执行得很好。
但是,哪个是正确的?图书馆正在使用 androidx.viewpager.widget.ViewPager
.
class androidx.viewpager.widget.ViewPager
包含在androidx.viewpager:viewpager:1.0.0
您可以在 doc:
中找到有关库映射的信息com.android.support:support-v4 -> androidx.legacy:legacy-support-v4
com.android.support:appcompat-v7 -> androidx.appcompat:appcompat
androidx.viewpager:viewpager
库也是 transitive dependency 的:
androidx.legacy:legacy-support-v4
-- androidx.legacy:legacy-support-core-ui
-- -- androidx.viewpager:viewpager