Cordova, Android, deprecated Gradle features, incompatibility

Viewed 64

Yes, I am aware of this thread: Cordova - Android - Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0

Its "solution" does not work for me! Hence the reason I'm posting here.

I am getting a "Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0" error message when I try "cordova build android" on my Cordova Android project.

My current config:

Cordova:  11.0.0
Gradle:   7.5.1 (it was 6.8.3 before I upgraded per the advice of the thread I linked)
Java:     11.0.16-amzn (I have tried several others, both v8.x and 11.x)
Computer: Mac mini (M1, 2020)
OS:       macOS Monterey (version 12.1)

BTW, I am using the export CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip trick in my .zshrc file to force Cordova to use Gradle version 7.5.1, otherwise it downloads and installs Gradle 7.1.1 when I run "cordova build android" (and that also fails with this same stupid "Deprecated Gradle features..." error).

I have been searching for HOURS now with no luck. I still get that stupid "Deprecated Gradle features.." error message, no matter what I try.

It tells me to use '--warning-mode all' to "show the individual deprecation warnings and determine if they come from your own scripts or plugins" but when I try "cordova build android --warning-mode all" it gives me an error message: "The platform 'all' does not appear to have been added to this project.

So I have two questions:

  1. does anyone know how to make this stupid thing build? What version of Gradle do I need? Is there something else I need to upgrade to make it work? Why is this happening all of the sudden? I've built many apps before with zero problems, and I've changed literally nothing on my system, yet somehow this app is giving me this error.

  2. if not, does anyone know how to make cordova build with "--warning-mode all" so I can at least see what specific thing is causing this "deprecated" error?

Thanks

2 Answers

This is a warning and not an error; can be ignored unless building with Gradle 8.0. And even if, --warning-mode all has no meaning unless you'd provide the relevant console output. Most often the cause are outdated Gradle plugins. For Gradle 8.0 there might be a new version of Cordova.

./gradlew :assembleDebug --warning-mode all

One can also define --warning-mode all for run configurations (GUI).

enter image description here

So when you see this, what do you think is causing the problem, hmmm? The "Build Failed" message occurs IMMEDIATELY after the Gradle message. So you'd assume that Gradle is causing the problem, no?

APPARENTLY NOT!!!

cordova build android --verbose gives me MANY more error messages -- including the one that actually fixed the problem. The cordova-plugin-barcodescanner plugin I was using is supposed to require some code added to config.xml:

<config-file target="AndroidManifest.xml" parent="/*" mode="merge">
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />
</config-file>

But apparently that is repeated somewhere else because the ACTUAL error that was stopping the build was Element uses-feature#android.hardware.camera at AndroidManifest.xml:39:5-85 duplicated with element declared at AndroidManifest.xml:35:5-60

Once I removed that code from the config.xml file, it finally builds successfully.

Good Lord, how ridiculous!!

Related