如何在 AndroidX 上使用该库?

How to use the library on AndroidX?

我写了一个支持AndroidX的库。 如果我还不想将我的项目迁移到 AndroidX,我该如何使用这个库进行迁移?

许多支持 AndroidX 的流行库都说 "If you wish to use this library now, migrate to AndroidX or use old versions"。所以我认为您不能将 AndroidX 库用于非 AndroidX 项目。

支持库和 AndroidX 的包名不同 space。将来,AndroidX 库中的新更改将不会在支持库中提供。

将项目迁移到AndroidX或将库降级为支持库。

更新

正如 mlyko 的评论所述,jetifier 具有反向模式:

https://developer.android.com/studio/command-line/jetifier#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.

我没试过,但看起来很有希望。

您可以在反向模式下尝试 jetifier-standalone,为构建提供支持库。因此,您将拥有 2 个版本的库 - androidx 和支持 lib。