使用 Jetifier 工具的 AndroidX 迁移将支持库转换为 RC 版本

AndroidX migration using Jetifier tool converts support libraries to RC versions

在迁移到 Android X 的过程中,tt 似乎 Jetifier 工具将一些第 3 方库转换为 RC 版本 (gradle-4.6)。

 |    +--- com.facebook.android:facebook-common:4.34.0
|    |    |    +--- com.facebook.android:facebook-core:4.34.0 (*)
|    |    |    +--- com.google.zxing:core:3.3.0
|    |    |    +--- androidx.legacy:legacy-support-v4:1.0.0-rc01
|    |    |    |    +--- androidx.core:core:1.0.0-rc01 -> 1.0.1 (*)
|    |    |    |    +--- androidx.media:media:1.0.0-rc01
|    |    |    |    |    +--- androidx.annotation:annotation:1.0.0-rc01 -> 1.0.0
|    |    |    |    |    +--- androidx.core:core:1.0.0-rc01 -> 1.0.1 (*)
|    |    |    |    |    \--- androidx.versionedparcelable:versionedparcelable:1.0.0-rc01 -> 1.0.0 (*)
|    |    |    |    +--- androidx.legacy:legacy-support-core-utils:1.0.0-rc01 -> 1.0.0 (*)
|    |    |    |    +--- androidx.legacy:legacy-support-core-ui:1.0.0-rc01 -> 1.0.0 (*)
|    |    |    |    \--- androidx.fragment:fragment:1.0.0-rc01 -> 1.0.0 (*)
|    |    |    +--- androidx.appcompat:appcompat:1.0.0-rc01 -> 1.0.2 (*)
|    |    |    +--- androidx.cardview:cardview:1.0.0-rc01 -> 1.0.0 (*)
|    |    |    \--- androidx.browser:browser:1.0.0-rc01
|    |    |         +--- androidx.core:core:1.0.0-rc01 -> 1.0.1 (*)
|    |    |         +--- androidx.annotation:annotation:1.0.0-rc01 -> 1.0.0
|    |    |         +--- androidx.interpolator:interpolator:1.0.0-rc01 -> 1.0.0 (*)
|    |    |         +--- androidx.collection:collection:1.0.0-rc01 -> 1.0.0 (*)
|    |    |         \--- androidx.legacy:legacy-support-core-ui:1.0.0-rc01 -> 1.0.0 (*)

有没有我可以强制只采用稳定(固定)版本的解决方案?

嗯,在jetifier源代码中挖掘后,似乎jetifier版本gradle-4.6是alpha10:

/gradle/m2repository/com/android/tools/build/jetifier/jetifier-processor/1.0.0-alpha10/jetifier-processor-1.0.0-alpha10.jar /gradle/m2repository/com/android/tools/build/jetifier/jetifier-core/1.0.0-alpha10/jetifier-core-1.0.0-alpha10.jar

这个包 jetifier 中的本地映射文件将一些支持库转换为 RC 版本。

添加更新的 jetifier 依赖关系解决了这个问题(顶部 build.gradle):

 classpath 'com.android.tools.build.jetifier:jetifier-core:1.0.0-beta02'
 classpath 'com.android.tools.build.jetifier:jetifier-processor:1.0.0-beta02'

下面是 facebook 依赖关系树的结果:

+--- com.facebook.android:facebook-common:4.34.0
|    |    |    +--- com.facebook.android:facebook-core:4.34.0 (*)
|    |    |    +--- com.google.zxing:core:3.3.0
|    |    |    +--- androidx.legacy:legacy-support-v4:1.0.0
|    |    |    |    +--- androidx.core:core:1.0.0 -> 1.0.1 (*)
|    |    |    |    +--- androidx.media:media:1.0.0
|    |    |    |    |    +--- androidx.annotation:annotation:1.0.0
|    |    |    |    |    +--- androidx.core:core:1.0.0 -> 1.0.1 (*)
|    |    |    |    |    \--- androidx.versionedparcelable:versionedparcelable:1.0.0 (*)
|    |    |    |    +--- androidx.legacy:legacy-support-core-utils:1.0.0 (*)
|    |    |    |    +--- androidx.legacy:legacy-support-core-ui:1.0.0 (*)
|    |    |    |    \--- androidx.fragment:fragment:1.0.0 (*)
|    |    |    +--- androidx.appcompat:appcompat:1.0.0 -> 1.0.2 (*)
|    |    |    +--- androidx.cardview:cardview:1.0.0 (*)
|    |    |    \--- androidx.browser:browser:1.0.0
|    |    |         +--- androidx.core:core:1.0.0 -> 1.0.1 (*)
|    |    |         +--- androidx.annotation:annotation:1.0.0
|    |    |         +--- androidx.interpolator:interpolator:1.0.0 (*)
|    |    |         +--- androidx.collection:collection:1.0.0 (*)
|    |    |         \--- androidx.legacy:legacy-support-core-ui:1.0.0 (*)