错误:此项目使用AndroidX依赖项,但未启用'android.useAndroidX'属性。在gradle.prop中将此属性设置为true

时间:2020-05-31 11:22:39

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

我想使用Firebase远程配置库(com.google.firebase:firebase-config:19.1.4)。当我将其依赖项添加到应用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

我的应用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

请让我知道是否需要其他信息来了解实际问题。

NB:我是android世界的新手

2 个答案:

答案 0 :(得分:1)

android.useAndroidX=true

android.enableJetifier=true

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

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

答案 1 :(得分:0)

首先打开您的项目 gradle脚本>>,然后打开gradle.properties,最后粘贴这两行代码

android.useAndroidX=true

android.enableJetifier=true

enter image description here