This project uses AndroidX Dependencies,but the 'android.useAndroidX' property is not enabled

孤者浪人 提交于 2021-01-29 14:13:12

问题


I have updated my android build.gradle to latest version now i am getting an error.

I have searched answers regarding this here(stackover flow),but none work for me .

my build.gradle code is:--->

apply plugin: 'com.android.application'




android {
compileSdkVersion 29
buildToolsVersion "29.0.3"

defaultConfig {
    applicationId "com.parse.starter"
    minSdkVersion 16
    targetSdkVersion 29
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

}

when i click on "sync now" then the error appears as:--->

This project uses AndroidX Dependencies,but the 'android.useAndroidX' property is not enabled.

After searching some answers here(stackover flow) .i created a file 'gradle.property' from File>new>Files(named as gradle.property) and added codes on it as:--->

org.gradle.jvmargs=-Xmx2048m
android.useAndroidX=true
android.enableJetifier=true 

After doing this when i click again on "sync now".then again the same error appears (This project uses AndroidX Dependencies,but the 'android.useAndroidX' property is not enabled.)

I dont know how to fix this issue.

please Help

thankyou.


回答1:


Try this solution go to :

Refactor -> Refactor this -> Migrate to Androidx -> click migrate , then a pop up message will show up to ask you if you want to save a copy of the project by ticking that checkbox ( up to you ) --> then do refactor




回答2:


You might have migrated to android x manually

Try using built in migrator https://developer.android.com/jetpack/androidx/migrate

Just right click , then go to refractor> migrate to AndroidX



来源:https://stackoverflow.com/questions/62921341/this-project-uses-androidx-dependencies-but-the-android-useandroidx-property-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!