【问题标题】:Must I use Android X?我必须使用 Android X 吗?
【发布时间】:2025-12-05 07:25:01
【问题描述】:

我正在编写一个 Android 应用程序并且我正在使用

    implementation 'com.android.support:appcompat-v7:28.0.0'

我尝试连接 Firebase,但它说使用 Android X。我必须使用它吗?我正在使用 3rd 方库,这在 Android X 上是否存在问题?如果我必须使用 Android X,我该如何安全地进行操作?

编辑:

我的 build.gradle :

implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.github.ybq:Android-SpinKit:1.4.0'
implementation 'de.hdodenhof:circleimageview:3.0.0'
implementation 'com.toptoche.searchablespinner:searchablespinnerlibrary:1.3.1'
implementation 'com.github.mukeshsolanki:android-otpview-pinview:2.0.3'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.google.firebase:firebase-messaging:17.3.4'

【问题讨论】:

  • 是的,你必须使用AndroidX
  • 您可以非常轻松地迁移到androidx。看看这个developer.android.com/jetpack/androidx/migrate
  • 您使用的是什么第三方库。如果他们使用的是旧的 android.support 库,那么你就不走运了。
  • 我将项目的 build.gradle 添加到我的问题@AngelKoh
  • @FatalError 你会遇到问题(等待库更新,或者你必须找到另一个使用 androidx 的等价物)。只需单独检查每个库的问题页面,看看他们是否有解决方案,例如对于 otpview -> github.com/mukeshsolanki/android-otpview-pinview/issues/60

标签: android android-support-library androidx


【解决方案1】:

是的,你必须使用 androidX

使用 Android Studio 3.2 及更高版本,您可以通过从菜单栏中选择 Refactor > Migrate to AndroidX 将现有项目迁移到 AndroidX。

重构命令使用两个标志。默认情况下,它们在你的 gradle.properties 文件中都设置为 true:

android.useAndroidX=true Android 插件使用适当的 AndroidX 库而不是支持库。 在 Android Studio 3.2 及更高版本中,您可以通过从菜单栏中选择 Refactor > Migrate to AndroidX 将现有项目迁移到 AndroidX。

重构命令使用两个标志。默认情况下,它们在您的 gradle.properties 文件中都设置为 true:

android.useAndroidX=true Android 插件使用适当的 AndroidX 库而不是支持库。 android.enableJetifier=true

【讨论】:

    【解决方案2】:

    不,它是一个选项,但如果您想使用新功能和新库以及 jetpack,则必须使用 android x。

    【讨论】:

      【解决方案3】:

      Jetpack 组件是 AndroidX 库的一部分。

      如果要使用 Jetpack 组件,必须使用 Androidx。

      对于设置 Androidx 或迁移,您可以点击此链接 https://developer.android.com/jetpack/androidx

      Android Jetpack 组件列表如下

      【讨论】:

        最近更新 更多