Could not set unknown property 'useAndroidX

2020-07-02 08:58发布

问题:

I want to add a library that i've found on github but it required androidx.I found out that i should put these:

android.useAndroidX=true
android.enableJetifier=true

here

defaultConfig {
    applicationId "com.kolydas.greeksinbrno"
    minSdkVersion 19
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    android.useAndroidX=true
    android.enableJetifier=true

}

But i got this error

Could not set unknown property 'useAndroidX' for object of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension.

回答1:

Those two properties need to be defined in a gradle.properties file at the root of your project, not in your build.gradle.