androidandroid-support-libraryandroidxandroid-jetifier

enableJetifier not working for library project


My new kotlin project use androidx by default, with android.useAndroidX=true & android.enableJetifier=true configured in root project's gradle.properties. But it also depends on a module library which is using support.v4 libraries.

Shouldn't Jetifier automatically transform those dependencies into androidx? Why am I still get this error:

error: package android.support.v4.content does not exist
import android.support.v4.content.ContextCompat;

error: cannot find symbol
   @DrawableRes int resId,
                                              ^
  symbol:   class DrawableRes
  location: class BitmapUtil

error: package android.support.annotation does not exist
import android.support.annotation.ColorRes;

error: cannot find symbol
    public static GDWrapper rect(@ColorRes int colorId, float... radii) {
                                  ^
  symbol:   class ColorRes
  location: class XmlDrawableUtil

Solution

  • Jetifier only applies to dependencies from maven (i.e., a line in your dependencies block of your build.gradle file); it does not apply to other modules in your project.

    Every module in your project needs to move to AndroidX at the same time.