What Is Jetifier

What is Jetifier?

This year's Google I/O (18), Google has announced Jetpack which is set/collection of libraries to make developer's life easier.

Jetpack includes previously introduced Android architecture components (ViewModel, Room, Paging, LiveData etc.) as well as newly introduced architecture components like WorkManager, Navigation. Apart from this Jetpack also has other set of libraries like AndroidX, AndroidKTX etc.

AndroidX is new package structure for Android support libraries like support, databinding, design etc.

e.g. now on wards developers will use androidx.databinding. instead of android.databinding. while importing libraries in our projects

This enables Google to add SemVer or Semantic Versioning in there library packages. For developers, this means we don't have to use same support library version for all support libraries. Every support or better to say AndroidX library will maintain its own versioning.

Another advantages for developers is that we don't have to care about maintaining same version for all support library in our project.

About Jetifier, it converts all support package of dependency at build time.
As per official documentation of Jetifier

Jetifier tool migrates support-library-dependent libraries to rely on
the equivalent AndroidX packages instead. The tool lets you migrate an
individual library directly, instead of using the Android gradle
plugin bundled with Android Studio.

To use AndroidX in a project we have to set targetSdkVersion for our project to 28 and add following 2 lines in gradle.properties file.

android.useAndroidX=true

android.enableJetifier=true

I hope this will answer your query.

EDIT

This link has mapping of all support library component with their AndroidX counter part.

Also please refer This blog for detailed explanation about AndroidX

Android Crashlytics issue with JetPack Jetifier

Well I found the solution.

What you need to do is to upgrade your fabric version to 1.25.4 in your project level build.gradle file:

buildscript {
dependencies {
classpath 'com.google.gms:google-services:3.2.0'
classpath 'io.fabric.tools:gradle:1.25.4'
}
}

Avoid AndroidX Jetifier log spam

Filtering out terminal/command line:

To filter-out output in terminal/command line use grep or some equivalent. On unix system it would go something like this:

./gradlew build | grep -vE 'Transform'

Windows grep's equivalent is findstr, so the whole command would look like this:

./gradlew build | findstr /V "Transform" 

Filtering out logcat:

If you have too any logs in the logcat, one possible solution is to filter-out all Jetifier's logs using the Android Studio log filters. You can do advanced filtering by clicking on the dropdown at the top right corner of Logcat menu and choosing Edit Filter Configuration and specifying what to filter on.

Sample Image

In your case the filter should look something like this. This configuration will filter-out all messages with 'Transform' tag (I'm not sure whether Transform is a tag or just a part of a message).
Sample Image

Most likely you will want to create a more advanced configuration so that only logs from your package get to be displayed.

How can I fix jetifier error in AndroidStudio?

I had the same error and tried many ways from adding repositories to build.gradle to removing proxy settings and ... but didn't work, finally I found the solution.
First close Android Studio, then go to "C:\Users<User Name>" and delete the ".gradle" directory.
Open Android Studio and sync your project.

AndroidX Jetifier unable/failed to transform 3rd-party transitive dependency that still use Support Library

Turns out my current workaround was using this approach: https://github.com/bumptech/glide/issues/3080#issuecomment-495430590

Magical regex to turns a blacklist into a whiteliset

android.jetifier.blacklist=^(?!.*[\\\\/](com\\.github\\.bumptech\\.glide|com\\.clevertap\\.android|com\\.facebook\\.android|com\\.github\\.nikartm|com\\.github\\.PierfrancescoSoffritti|com\\.github\\.prolificinteractive)[\\\\/]).*$

If NoClassDef exceptions thrown, then I add the library package name into the android.jetifier.blacklist to whitelisted them.

In the above cases, I'm trying to whitelist:

  1. glide
  2. clevertap
  3. nikartm
  4. facebook-sdk
  5. YoutubeAndroidPlayer (v7) still not using v10
  6. prolificinteractive


Related Topics



Leave a reply



Submit