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://issuetracker.google.com/issues/113224601.
The error message looks like this when running the Jetifier on certain libraries (one particular library keeps popping up for multiple users: org.eclipse.jdt.core
):
Failed to transform '/path/to/library/org.eclipse.jdt.core-3.10.0.jar' using Jetifier.
Reason: The type does not support '.' as package separator!
This issue has been fixed for a while in the Jetifier tool itself, but the fixed version has not been included in any Android Studio updates yet (even the latest canary build).
I can confirm that running the standalone Jetifier works in transforming the problematic libraries, but I have no idea how to get these transformed libraries into our project. Off the top of my head, I can think of two different ways to get this migration to AndroidX to work:
Run the standalone tool on each library and instruct Gradle to use those versions (I might need to tell the Gradle tasks not to run the Jetifier on them)
Instruct the Gradle tasks to use the standalone tool in place of the one shipped with Android Studio.
Any help getting either of the above suggested fixes to work would be greatly appreciated (or if there is another way, I'd love to know about it). The internals of the Android Gradle build system are incredibly complicated, and I really need some gurus' assistance to get past this roadblock.
This is a serious road block for us since we want to begin the process of migrating our app in parallel with our development. There are a lot of things we need to iron out with this migration, and being ready to "flip the switch" when the tool is finally updated would help keep our releases on track.
Thanks!
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