Android X backwards compatibility

2020-02-28 22:14发布

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.

2条回答
2楼-- · 2020-02-28 22:30

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).

查看更多
神经病院院长
3楼-- · 2020-02-28 22:38

AndroidX[About]

  • 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[About] which convert support to androidX

android.useAndroidX=true
android.enableJetifier=true
查看更多
登录 后发表回答