【问题标题】:AndroidX migration using Jetifier tool converts support libraries to RC versions使用 Jetifier 工具的 AndroidX 迁移将支持库转换为 RC 版本
【发布时间】:2019-04-24 05:23:22
【问题描述】:

在迁移到 Android X 的过程中,tt 似乎 Jetifier 工具将一些 3rd 方库转换为 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 (*)

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

【问题讨论】:

    标签: android android-studio android-jetpack androidx android-jetifier


    【解决方案1】:

    嗯,挖了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 依赖可以解决这个问题(top 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 (*)
    

    【讨论】:

    • 您在jetifier-processor:1.0.0beta02 中错过了- → 应该是1.0.0-beta02 :)
    猜你喜欢
    • 2019-08-22
    • 2019-04-03
    • 2020-07-25
    • 2020-03-29
    • 2019-05-13
    • 1970-01-01
    • 2019-04-11
    • 2019-08-21
    • 1970-01-01
    相关资源
    最近更新 更多