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

26,178

Solution 1

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.

Solution 2

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

Solution 3

  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.

Solution 4

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.

Share:
26,178
commandiron
Author by

commandiron

Android and Kotlin.

Updated on March 09, 2021

Comments

  • commandiron
    commandiron about 3 years

    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.

  • commandiron
    commandiron almost 4 years
    if i don't want to use androidx libraries, what can i do?
  • Inês Gomes
    Inês Gomes about 3 years
    Gave me this: Plugin doesn't support this project's cordova-android version. cordova-android: 9.1.0, failed version requirement: <9.0.0 Skipping 'cordova-plugin-androidx' for android
  • realtebo
    realtebo almost 2 years
    What's the purpose of "android.enableJetifier=true" ?