【问题标题】:ERROR: This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled. Set this property to true in the gradle.prop错误:此项目使用 AndroidX 依赖项,但未启用“android.useAndroidX”属性。在 gradle.prop 中将此属性设置为 true
【发布时间】:2020-09-18 18:19:42
【问题描述】:

我想使用 firebase 远程配置库(com.google.firebase:firebase-config:19.1.4)。当我将其依赖项添加到 app gradle 中时,出现以下错误。

    ERROR: 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
Affected Modules: app

我的app gradle如下:

android {
compileSdkVersion 27
defaultConfig {
    applicationId "in.co.gramafone.client"
    minSdkVersion 16
    targetSdkVersion 27
    versionCode 19
    versionName "1.1.1"
    vectorDrawables.useSupportLibrary = true
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
}
...
}

我广泛使用 android 支持库(com.android.support:appcompat-v7:27.1.1)。所以,如果我通过下面的行来解决这个问题来启用 androidX,还有很多其他库冲突正在报告(如果这些错误是必要的,我可以发布)

android.useAndroidX=true
android.enableJetifier=true

如果需要任何其他信息来了解实际问题,请告诉我。

注意:我是安卓世界的新手

【问题讨论】:

  • 我想你把build.gradlegradle.properties 弄错了。 gradle.properties 是您项目中的另一个文件。
  • 我被这条消息弄糊涂了,因为我在我的项目中找不到一个完全名为“gradle.properites”的文件。但是,我从另一个项目中复制了该文件,而它恰好已经有了这些值。

标签: android-studio gradle android-support-library androidx firebase-remote-config


【解决方案1】:

首先打开你的项目gradle scripts>>然后打开gradle.properties 最后粘贴这两行代码

android.useAndroidX=true

android.enableJetifier=true

【讨论】:

  • 谢谢!我找了几个小时。希望我能给你更多的支持!
【解决方案2】:
android.useAndroidX=true

android.enableJetifier=true

您需要将这些添加到 Gradle 脚本文件夹中的 gradle.properties 文件中。

我不是 100% 确定,但这应该可行。

【讨论】:

  • 在Temp/gradleOut的项目文件夹下找到文件
猜你喜欢
  • 1970-01-01
  • 2012-02-23
  • 2010-11-09
  • 2014-06-10
  • 1970-01-01
  • 2020-12-29
  • 2019-10-26
  • 2020-06-15
  • 1970-01-01
相关资源
最近更新 更多