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

Viewed 31871

This is my 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.fragment:fragment:1.0.0,
androidx.versionedparcelable:versionedparcelable:1.0.0, 
androidx.slidingpanelayout:slidingpanelayout:1.0.0
...

How can i solve this problem? i delete all androidx libraries from my gradle files and my imported libraries from classes. i dont want to use androidx.

4 Answers

The easiest way to do it in a Cordova project is to open your config.xml file and add the following inside the <platform name="android"> tag.

    <preference name="AndroidXEnabled" value="true" />

That way, if you ever remove and re-add the Android platform, you won't have to go back into the gradle.properties and manually edit it. (Besides, my gradle.properties seems to be overwritten every time I type "cordova build android" so editing it directly doesn't work for me anyway.)

Best of luck.

first Open your Project gradle scripts>> then open gradle.properties And Finally paste this two line code

android.useAndroidX=true

android.enableJetifier=true

enter image description here

  1. Add plugin to enable AndroidX in the project install following,

cordova plugin add cordova-plugin-androidx

  1. Add plugin to patch existing plugin source that uses the Android Support Library to use AndroidX

cordova plugin add cordova-plugin-androidx-adapter

Then build your app.

The Android Gradle plugin provides the following global flags that you can set in your gradle.properties file:

android.useAndroidX: When set to true, this flag indicates that you want to start using AndroidX from now on.

If the flag is absent, Android Studio behaves as if the flag were set to false.

Therefore use this plugin android.useAndroidX=true in gradle.properties and sync project.

This should solve your problem.

Related