I am getting the following error while trying to build my android app:
Task :app:mergeDebugResources FAILED
FAILURE: Build failed with an exception.
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.slidingpanelayout:slidingpanelayout:1.0.0, androidx.fragment:fragment: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.0.0, androidx.lifecycle:lifecycle-livedata:2.0.0, androidx.legacy:legacy-support-core-ui:1.0.0, androidx.lifecycle:lifecycle-viewmodel:2.0.0, androidx.lifecycle:lifecycle-livedata-core:2.0.0, androidx.legacy:legacy-support-v4:1.0.0, androidx.media:media:1.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
I modified the project's gradle.properties file and set "android.userAndroidX" to true. But everytime I try to build again it goes back to false automatically. Is there any chance that gradle.properties is being overwritten by any other task during the build?
Thanks!
This Cordova/Phonegap plugin enables AndroidX in a Cordova project (AndroidX is the successor to the Android Support Library). This plugin is useful if your project contains plugins which have migrated to AndroidX or if you otherwise want to enable AndroidX in your Cordova Android platform project.
Presumably you are using cordova-android@8
(type cordova platform ls
to find the platform versions in your project).
So you have 2 options:
Update to cordova-android@9
which implicitly supports AndroidX:
cordova platform rm android && cordova platform add android@9
In your config.xml add the following line:
<preference name="AndroidXEnabled" value="true" />
More details here: cordova documentation
Add cordova-plugin-androidx to your Cordova project, which persistently sets the native AndroidX flags for cordova-android@8
:
cordova plugin add cordova-plugin-androidx
If after adding one of these your project still fails to build, it may be because it contains Cordova plugins whose native Android code references the legacy Android Support Library (to which AndroidX is the successor). To resolve this, you can add cordova-plugin-androidx-adapter to your project which will dynamically patch the source code of those plugins to migrate them to AndroidX:
cordova plugin add cordova-plugin-androidx-adapter
In your config.xml add the following line:
<preference name="AndroidXEnabled" value="true" />
More details here: cordova documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With