Skip to content Skip to sidebar Skip to footer

Android X Backwards Compatibility

I have Android App that uses support library versions 27.1.2. I want to consume a library written using Android X (api 28). There are few issues with name spacing of the library ve

Solution 1:

This is not possible. To use any library that depends on AndroidX, your project must migrate your whole project to AndroidX.

Note that the reverse is supported - you can use libraries built with Support Library in projects that use AndroidX (that's the purpose of the android.enableJetifier=true flag).

Solution 2:

AndroidX

  • Consumer support -> Producer androidX - not compatible.

You should migrate your consumer to use AndroidX. Android Studio menu -> Refactor -> Migrate to AndroidX...

  • Consumer androidX -> Producer support - compatible.

Consumer's gradle.properties in addition to use androidX should enable Jetifier which converts support to androidX

android.useAndroidX=trueandroid.enableJetifier=true

[Mix AndroidX and support in a multi-module project]

Solution 3:

There is a way

Jetifier tool migrates support-library-dependent libraries to rely on the equivalent AndroidX packages instead. But when you put -r flag, it makes him to the exactly reverse process.

From developer.android.com

If you pass the -r flag, the utility runs in reverse mode. In this mode, the utility converts AndroidX APIs to the support library equivalents, instead of the other way around. Reverse mode is useful, for example, if you are developing libraries that use AndroidX APIs, but also need to distribute versions that use the support library.

Anyway, I will suggest to use it only in a very critical needs.

Post a Comment for "Android X Backwards Compatibility"