Importing AndroidX (Jetpack) library into a non AndroidX App

Viewed 1214

I'm facing a problem with a library/app compatibility, and I cannot find the solution.

I have a library compiled with V28+ as shown:

/* Library graddle file targets to v28 with AndroidX support */
compileSdkVersion 28
buildToolsVersion '28.0.3'

It's compiled, and fully functional. Basically, this library contains a Fragment that is exported to the application. But, as Androidx compliant library, the fragment extends from

import androidx.fragment.app.Fragment;

So far so good, it is working fine here if I use this library into another AnrdoidX compiled App.

The issue is that I have an Application that targets SDK 27, with no AndroidX support:

/* Library gradle file targets to v27 with no AndroidX support */ 
compileSdkVersion 27
buildToolsVersion '28.0.3'

When I compile it, I got a bunch of errors (Class file for androidx.... not found), as this example (Here, I'm using the library's Fragment element into the App FragmentManager):

public class RadioFragment extends RadioPlayerFragment  {
   ^
    class file for androidx.fragment.app.Fragment not found
...

If I edit my gradle.properties file, and add the following lines:

android.useAndroidX=true
android.enableJetifier=true

Then I got, for example:

Execution failed for task ':app:processDebugResources'.

Android resource linking failed Output: /Users/anibal/Development/Proyectos/project/Git/project/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values-v28/values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found. /Users/anibal/Development/Proyectos/MovistarRadio/Git/project/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values-v28/values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found. /Users/anibal/Development/Proyectos/project/Git/project/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:1172: error: resource android:attr/fontVariationSettings not found. /Users/anibal/Development/Proyectos/project/Git/project/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:1173: error: resource android:attr/ttcIndex not found. error: failed linking references.

So, my question:

Is there a way to use an AndroidX (V28) compiled Library in a lower target app with no AndroidX support?

To change the old app to AndroidX is not an option at this point.

0 Answers
Related