简体   繁体   中英

Jetifier not working when library uses android component and app uses androidx component

I have an app where I am using AncdroidX components. Jetifier is enabled

android.enableJetifier=true
android.useAndroidX=true

Now i am adding a third party library which uses android libraries instead of AndroidX (com.android.support).

Library dependencies

implementation "com.android.support:appcompat-v7:28.0.0"

App Dependenciews

implementation "androidx.appcompat:appcompat:1.0.0"

I am getting build error for the third party library

error: package android.support.v7.widget does not exist
    public final android.support.v7.widget.Toolbar toolbarFragment;
                                          ^

When I checked dependencies, it is showing as

+--- com.android.databinding:baseLibrary:3.1.4 -> androidx.databinding:databinding-common:3.2.1
+--- androidx.appcompat:appcompat:1.0.0-rc01 -> 1.0.0 (*)
+--- com.google.android.material:material:1.0.0-rc01 -> 1.0.0 (*)

Actually the app is generating the binding classes and Jetifier fails to migrate the code in generated classes. To solve this problem, the library provider needs to put

android.databinding.enableV2=true

in their gradle.properties file.

From Android Documentation

Binding classes for library modules are compiled and packaged into the corresponding Android Archive (AAR) file. App modules that depend on those library modules no longer need to regenerate the binding classes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM