简体   繁体   中英

How to use both Androidx libraries and support libraries in one project?

androidx 和 com.android.support 我想在一个项目中同时使用这两个 lib 因为我们使用的是一个使用 androidx 的 sdk 而我的 sdk 不使用 androidx 怎么办如何在一个项目中使用它?

You can enable Jetifier on your project, which will basically exchange the Android Support Library dependencies in your project dependencies with AndroidX -ones. (eg Your Lottie dependencies will be changed from Support to AnroidX)

From the Android Studio Documentation ( https://developer.android.com/studio/preview/features/ ):

The Android Gradle plugin provides the following global flags that you can set in your gradle.properties file:

  • android.useAndroidX: When set to true, this flag indicates that you want to start using AndroidX from now on. If the flag is absent, Android Studio behaves as if the flag were set to false.
  • android.enableJetifier: When set to true, this flag indicates that you want to have tool support (from the Android Gradle plugin) to automatically convert existing third-party libraries as if they were written for AndroidX. If the flag is absent, Android Studio behaves as if the flag were set to false.

Precondition for Jetifier:

  • you have to use at least Android Studio 3.2

To enable jetifier, add those two lines to your gradle.properties file:

android.useAndroidX=true
android.enableJetifier=true

Finally, please check the release notes of AndroidX, because jetifier has still some problems with some libraries (eg Dagger Android): https://developer.android.com/topic/libraries/support-library/androidx-rn

Answer Credit: Christopher https://stackoverflow.com/a/52034414/9932194

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM