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 versions.
Example ...
The library has a Dialog that I want to use with the api
Dialog.show(androidx.fragment.app.FragmentActivity activity);
However all my activities are using
android.support.v4.app.FragmentActivity
and the compiler does not like this.
Currently it is not an option to upgrade my project to latest version, so please no upgrade answers, unless this is the only solution.
Is there a way to resolve this incompatibility issue?
Thanks in advance.
AndroidX is a major improvement to the original Android Support Library, which is no longer maintained. androidx packages fully replace the Support Library by providing feature parity and new libraries.
So, if you want bug fixes or new features that would have previously gone into the Support Library, you need to migrate to AndroidX. Better package management. With AndroidX, you get standardized and independent versioning, as well as better standardized naming and more frequent releases.
Migrate an existing project using Android Studio With Android Studio 3.2 and higher, you can migrate an existing project to AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar. The refactor command makes use of two flags. By default, both of them are set to true in your gradle.
AndroidX is the open-source project that is introduced along with Android Jetpack. Basically, it is a major improvement to the original Android Support Library. Like the Support Library, AndroidX also ships separately from the Android OS and provides backwards-compatibility across Android releases.
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).
AndroidX[About]
support
-> Producer androidX
- not compatible. You should migrate your consumer to use AndroidX. Android Studio menu -> Refactor -> Migrate to AndroidX...
androidX
-> Producer support
- compatible.Consumer's gradle.properties
in addition to use androidX
should enable Jetifier
[About] which converts support
to androidX
android.useAndroidX=true
android.enableJetifier=true
[Mix AndroidX and support in a multi-module project]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With