问题
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.
回答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).
回答2:
AndroidX[About]
- Consumer
support
-> ProducerandroidX
- not compatible.
You should migrate your consumer to use AndroidX. Android Studio menu -> Refactor -> Migrate to AndroidX...
- Consumer
androidX
-> Producersupport
- compatible.
Consumer's gradle.properties
in addition to use androidX
should enable Jetifier
[About] which convert support
to androidX
android.useAndroidX=true
android.enableJetifier=true
来源:https://stackoverflow.com/questions/55172932/android-x-backwards-compatibility