Disabling Jetifier - sergei-lapin/pimp-my-gradle-recipes GitHub Wiki

So, you're up to disabling Jetifier in your project?

Well, I have a guide for you, that, hopefully, will er... guide you through this tough process.

First thing you'll need on that tricky path is CanIDropJetifier Gradle plugin applied to your root project's build.gradle file as following:

plugins {
  id "com.github.plnice.canidropjetifier" version "0.5"
}

After that you can run it's specific task with following command

./gradlew -Pandroid.enableJetifier=false canIDropJetifier

Hopefully, at that point, you'll get a permission from that plugin to remove Jetifier (android.enableJetifier=true) from your gradle.properties and you're done with it. If it's not the case, then follow along

  1. Download jetifier-standalone tool
  2. Download dependencies from CanIDropJetifier report that require jetifying
  3. Jetify the .aar files according to jetifier-standalone documentation, preserving the original artifact name
  4. Modify library .pom file according to artifact mappings in order for it to request correct dependencies during dependency resolution stage
  5. Put modified library artifact along with modified .pom file to the same path on your Nexus/Artifactory/Maven Local as it was with it's original source (e.g. for me.relex:circleindicator:1.3.2 dependency path would be me/relex/circleindicator/1.3.2)
  6. Specify where to resolve the jetified dependencies in your gradle scripts (via placing your repository above other alternatives/via specifying exclusive content for your repository)
  7. And you're almost done, now you can remove this android.enableJetifier=true line from your gradle.properties file
  8. The only thing that is left is to perform regression testing of your app, because there is such thing as fatJar dependencies

Dealing with fatJar dependencies

fatJar libraries are called so because they are not declaring any dependencies in their .pom files and rather packing all of them during their assembling process. So, such libraries can't be spotted by CanIDropJetifier plugin and though they require manual jetification they won't appear on plugins task output. The only way to spot them is during regression testing of your app after performing operations mentioned above, you might get runtime crashes saying that some class, android.support.v7.widget.Toolbar, for example, is missing on the runtime classpath, and by the stacktrace you could identify the library that is using legacy classes, perform steps 3, 5, 6 with it and now you're done disabling jetifier for your project. Congratulations!