android - 将firebase添加到android时出现AndroidX依赖错误
问题描述
我正在开发一个 android 项目,当我尝试将 firebase 依赖项添加到项目后发生构建错误时。我曾尝试迁移到 appCompat,但没有成功。
This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled. Set this property to true in the gradle.properties file and retry.The following AndroidX dependencies are detected: androidx.versionedparcelable:versionedparcelable:1.0.0, androidx.fragment:fragment:1.0.0, androidx.slidingpanelayout:slidingpanelayout:1.0.0, androidx.core:core:1.0.0, androidx.customview:customview:1.0.0, androidx.swiperefreshlayout:swiperefreshlayout:1.0.0, androidx.interpolator:interpolator:1.0.0, androidx.loader:loader:1.0.0, androidx.drawerlayout:drawerlayout:1.0.0, androidx.viewpager:viewpager:1.0.0, androidx.collection:collection:1.0.0, androidx.localbroadcastmanager:localbroadcastmanager:1.0.0, androidx.lifecycle:lifecycle-common:2.0.0, androidx.arch.core:core-common:2.0.0, androidx.annotation:annotation:1.1.0, androidx.legacy:legacy-support-core-ui:1.0.0, androidx.lifecycle:lifecycle-livedata:2.0.0, androidx.lifecycle:lifecycle-viewmodel:2.0.0, androidx.lifecycle:lifecycle-livedata-core:2.0.0, androidx.arch.core:core-runtime:2.0.0, androidx.legacy:legacy-support-core-utils:1.0.0, androidx.documentfile:documentfile:1.0.0, androidx.cursoradapter:cursoradapter:1.0.0, androidx.lifecycle:lifecycle-runtime:2.0.0, androidx.coordinatorlayout:coordinatorlayout:1.0.0, androidx.asynclayoutinflater:asynclayoutinflater:1.0.0, androidx.print:print:1.0.0
未添加 firebase 的依赖项如下:
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:2.0.4'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
请帮助解决上述问题。
解决方案
android.useAndroidX=true
Android 插件使用适当的 AndroidX 库而不是支持库。
android.enableJetifier=true
Android 插件通过重写其二进制文件自动迁移现有的第三方库以使用 AndroidX
在gradle.properties文件中添加这两行。
然后清理项目并重建项目。
可能你的问题会得到解决。如果不让我知道。
您当前使用的基于 Android 的库应该迁移到 Androidx。
我建议您在 Androidx 中迁移您的项目。您很容易获得更多帖子如何将 android 迁移到 androidx 我的项目。
推荐阅读
- gradle - kotlin 的 Gradle 构建失败
- c# - 带有 SelectedValue 的 WPF 组合框表现得很奇怪
- javascript - Datatables 在 DataTables 创建函数之外只有 10 行可访问
- wpf - WPF Xaml 故事板在动态更改口音(Mahapps)后停止
- cmake - 根据生成构建文件时不可用的源文件在 CMake 中创建库
- r - 多个函数返回找不到对象的错误
- html - 如何向右移动和使用未使用的宽度空间?
- javascript - 将隐藏的 DIV 保存为画布图像
- android - 从内存中打开 PNG 文件并通过 TCP 套接字发送
- ios - RxSwift 中 Disposables.create() 的用途