How do I use the standalone Jetifier to migrate to AndroidX?

后端 未结 2 1596
孤城傲影
孤城傲影 2021-02-06 15:29

The Jetifier tool is used as part of the AndroidX migration tool bundled with Android Studio. There is an issue with the tool, however, that is outlined here: https://issuetra

相关标签:
2条回答
  • 2021-02-06 16:12

    Actually, from that same thread that I linked, there's a workaround:

    Sorry jetifier beta01 was not binary compatible with alpha10.

    Please try:

    buildscript {
        dependencies {
            classpath 'com.android.tools.build.jetifier:jetifier-processor:1.0.0-beta02'
        }
    }
    

    So, I guess now you can specify the newest version of the Jetifier in your buildscript.

    I really should have scrolled all the way to the bottom of that thread before posting this, but now hopefully this workaround is more visible to people.

    UPDATE

    It seems this workaround does not work with DataBinding enabled. It looks like the new Jetifier tool is trying to run on the old version:

    Failed to transform '/path/to/library/jetifier-core-1.0.0-alpha10.jar' using Jetifier. Reason: The given artifact contains a string literal with a package reference 'android/support/v4' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx.

    UPDATE 2 (20 Nov 2018):

    There is a workaround to the issue of Jetifier trying to Jetify itself being released in AGP 3.3.0-rc01 and 3.4.0-alpha04. The devs are adding the ability to blacklist libraries from being Jetified. In your gradle.properties file, add a comma-separated list of Regular Expressions to match what files you don't want the Jetifier to touch. For example:

    android.jetifier.blacklist = doNot.*\\.jar

    Would exclude /path/to/doNotJetify.jar

    0 讨论(0)
  • 2021-02-06 16:35

    I´m a bite late to the party, but I think there is only one fast option to solve that issue:

    Go to Google Archives, Agree save and terms and download Android Studio 3.3 Beta 2 - this is the latest version before the problem occurs. You also have to downgrade your build.gradle to

    classpath 'com.android.tools.build:gradle:3.3.0-beta02'

    using gradle-4.10.2-all should be no problem.

    Perhaps the problem will be fixed with the next beta or canary release, but for now this was the only option that worked out for me.

    0 讨论(0)
提交回复
热议问题