How to update jdk for android cordova build

Reproduce? You have the error log(s).

I’m one of the back end engineers for VoltBuilder and I’m hoping I can help here. First, I’m sorry for the prior miscommunication. Our focus is on support, and I can promise you that no one was intentionally trolling you. I can see how it might have seemed that way, and we’ll make sure it doesn’t happen again.

VoltBuilder only currently supports JDK 8, and up to Android SDK 30. This is not a limitation of our system, but of Cordova’s Android support. We’re expecting to see the v11 release of cordova-android any day here, and we’ll quickly test and upgrade our build servers to support SDK 31 and 32 at that time. We also expect to start supporting JDK 11 at that time.

I believe part of the issue here is that Cordova itself doesn’t support SDK 31, and I would suggest you downgrade, or wait for that support to become official. We unfortunately can’t control when they choose to release this support, but we expect it’ll be soon.

The gradle version, and all the gradle build scripts are autogenerated, by Cordova, not by our system. When we see problems with gradle, they tend to indicate an incompatibility with either the project’s source code, or one of the plugins. In this case, based on your comments, I suspect it’s a problem with the project itself. The fix you linked for changing the build.gradle file looks like it might work - but would require patching cordova-android to apply the fix.

We do have access to logs, but some issues (like this one) require a deeper understanding of the project structure. It would be helpful if you could share your project with us so we can understand what’s gone wrong here, and hopefully do a better job of supporting you in the future.

I’m certain we can get your project building, but if you’d not happy with the situation, we will also provide a refund. Please let me know what you’d like to do and how I can help.

– James

You can help by reading the exchange in its entirety before answering. It was already mentioned in the post that the build using SDK 31 was failing because it was looking for JDK 11 after George mentioned multiple times, a plugin was causing the error. You could have looked in three (3) places to see that sdk 30 is being used:

  1. The post chain
  2. The error log
  3. The link w/ the suggested solution.

But somehow it was missed. Either you decided to answer without reading what was wrote or there was a problem comprehending what was written.

The log error is pretty clear as to source of the error:

The minCompileSdk (31) specified in a
dependency’s AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module’s compileSdkVersion (android-30)

It’s possible you missed this part of my response, so I’ll quote it here again:

There’s been a fair amount of back and forth here, and I understand you are frustrated. I assure you that I’m reading and attempting to understand why your project isn’t building. The linked solution suggests that the “error is being caused because one of your dependencies is internally using WorkManager 2.7.0-beta01 … (which needs API 31).” We need to find that dependency and fix that - or submit a patch to cordova-android. Those are the two options I see here.

If I’ve missed something, please let me know, but I simply don’t see any other way to resolve this issue.

Another option would be to upgrade to using Capacitor, which would allow you to modify build scripts. We’re currently running a beta and would be happy to allow you take part.

Actually, I didn’t miss it but I did catch when you wrote:

I believe part of the issue here is that Cordova itself doesn’t support SDK 31, and I would suggest you downgrade…

I also caught:

VoltBuilder only currently supports JDK 8, and up to Android SDK 30

So, as mentioned in the post, after repeatedly mentioning that it was plugin issue and correcting George that no, it was the build looking for JDK 11 since SDK 31 was being used. Only after downgrading to SDK 30, did the gradle error that’s looking for a work manager for sdk 31 and above occur.

So, as mentioned in the last post, the error is pretty clear, the build is compiling using sdk 31 while the target sdk is 30 and hence, a work manager that’s dependent on sdk 31 is invoked in Gradle.

.

Our team noticed you submitted the project again and we had some time to analyze it. The plugin that’s causing the problem is cordova-admob-sdklibs - if you remove it, your project builds without errors. This plugin pulls in maven packages including com.google.android.gms:play-services-ads. You’ll notice that this plugin retrieves the latest version - in this case, 21.0.0. However this pulls in an incompatible version of work-runtime as a transitive dependency (via play-services-ads-lite).

We believe (but haven’t had an opportunity to test) that if you explicitly specify the version of 20.4.0, you’ll pull in a lower version of work-runtime (2.1.0) which should work with JDK 8.

At this point you have some options:

  1. Find a maintained plugin that specifies the SDK version explicity.
  2. Modify the existing plugin to specify explicit versions rather than the latest version of the SDKs.
  3. Wait for Cordova’s (and our) impending release of cordova-android 11 with support for SDK 31/32 and JDK 11.
  4. Submit a patch to the cordova-android project, though I doubt it would be accepted.
  5. Switch to Capacitor, where gradle build files can be manipulated directly.

Honestly, I would opt for finding a different plugin to include your admob SDKs - it’s generally best to explicitly specify an SDK version. That would be your quickest solution.

Here’s are some snippets from the voltbuilder error log that was generated prior to your reply:

Beginning processing of action stack for android project…
Installing Android library: com.google.android.gms:play-services-ads:20.4.0

plugin name=“cordova-admob-sdklibs” spec=“~2.1.6”
variable name=“PLAY_SERVICES_VERSION” value=“20.4.0” />
</plugin

package.json:

— Start of Cordova JSON Snippet —

“cordova-admob-sdklibs”: {
“PLAY_SERVICES_VERSION”: “20.4.0”
},
“admob-plus-cordova”: {
“APP_ID_ANDROID”: “ca-app-pub-xxxxxx”,
“PLAY_SERVICES_VERSION”: “20.4.0”
},

— End of Cordova JSON Snippet —

That version was already specified and installed, per the error log

Give version 19.4.0 a try. That’s the last version that doesn’t have a dependency on work-runtime.

The same error occurred. We also tried replacing the trouble plugin “cordova-admob-sdklibs” wtih cordova-admob-sdk and cordova-admob-sdk-updated but the following errors were returned:

A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
Duplicate class com.google.android.gms.common.api.zza found in modules jetified-play-services-base-11.0.4-runtime (com.google.android.gms:play-services-base:11.0.4) and jetified-play-services-basement-17.6.0-runtime (com.google.android.gms:play-services-basement:17.6.0)
Duplicate class com.google.android.gms.common.api.zzb found in modules jetified-play-services-base-11.0.4-runtime (com.google.android.gms:play-services-base:11.0.4) and jetified-play-services-basement-17.6.0-runtime (com.google.android.gms:play-services-basement:17.6.0)
Duplicate class com.google.android.gms.common.internal.zzaa found in modules jetified-play-services-base-11.0.4-runtime (com.google.android.gms:play-services-base:11.0.4) and jetified-play-services-basement-17.6.0-runtime (com.google.android.gms:play-services-basement:17.6.0)
Duplicate class com.google.android.gms.common.internal.zzab found in modules jetified-play-services-base-11.0.4-runtime (com.google.android.gms:play-services-base:11.0.4) and jetified-play-services-basement-17.6.0-runtime (com.google.android.gms:play-services-basement:17.6.0)
Duplicate class com.google.android.gms.common.internal.zzac found in modules jetified-play-services-base-11.0.4-runtime (com.google.android.gms:play-services-base:11.0.4) and jetified-play-services-basement-17.6.0-runtime (com.google.android.gms:play-services-basement:17.6.0)
Duplicate class com.google.android.gms.common.internal.zzad found in modules jetified-play-services-base-11.0.4-runtime (com.google.android.gms:play-services-base:11.0.4) and jetified-play-services-basement-17.6.0-runtime (com.google.android.gms:play-services-basement:17.6.0)
Duplicate class com.google.android.gms.common.internal.zzb found in modules jetified-play-services-base-11.0.4-runtime (com.google.android.gms:play-services-base:11.0.4) and jetified-play-services-basement-17.6.0-runtime (com.google.android.gms:play-services-basement:17.6.0)
Duplicate class com.google.android.gms.common.internal.zzq found in modules jetified-play-services-base-11.0.4-runtime (com.google.android.gms:play-services-base:11.0.4) and jetified-play-services-basement-17.6.0-runtime (com.google.android.gms:play-services-basement:17.6.0)
Duplicate class com.google.android.gms.common.internal.zzr found in modules jetified-play-services-base-11.0.4-runtime (com.google.android.gms:play-services-base:11.0.4) and jetified-play-services-basement-17.6.0-runtime (com.google.android.gms:play-services-basement:17.6.0)
Duplicate class com.google.android.gms.common.internal.zzs found in modules jetified-play-services-base-11.0.4-runtime (com.google.android.gms:play-services-base:11.0.4) and jetified-play-services-basement-17.6.0-runtime (com.google.android.gms:play-services-basement:17.6.0)
Duplicate class com.google.android.gms.common.internal.zzt found in modules jetified-play-services-base-11.0.4-runtime (com.google.android.gms:play-services-base:11.0.4) and jetified-play-services-basement-17.6.0-runtime (com.google.android.gms:play-services-basement:17.6.0)
Duplicate class com.google.android.gms.common.internal.zzu found in modules jetified-play-services-base-11.0.4-runtime (com.google.android.gms:play-services-base:11.0.4) and jetified-play-services-basement-17.6.0-runtime (com.google.android.gms:play-services-basement:17.6.0)
Duplicate class com.google.android.gms.common.internal.zzv found in modules jetified-play-services-base-11.0.4-runtime (com.google.android.gms:play-services-base:11.0.4) and jetified-play-services-basement-17.6.0-runtime (com.google.android.gms:play-services-basement:17.6.0)
Duplicate class com.google.android.gms.common.internal.zzw found in modules jetified-play-services-base-11.0.4-runtime (com.google.android.gms:play-services-base:11.0.4) and jetified-play-services-basement-17.6.0-runtime (com.google.android.gms:play-services-basement:17.6.0)
Duplicate class com.google.android.gms.common.internal.zzz found in modules jetified-play-services-base-11.0.4-runtime (com.google.android.gms:play-services-base:11.0.4) and jetified-play-services-basement-17.6.0-runtime (com.google.android.gms:play-services-basement:17.6.0)
Duplicate class com.google.android.gms.dynamic.zza found in modules jetified-play-services-base-11.0.4-runtime (com.google.android.gms:play-services-base:11.0.4) and jetified-play-services-basement-17.6.0-runtime (com.google.android.gms:play-services-basement:17.6.0)
Duplicate class com.google.android.gms.dynamic.zzb found in modules jetified-play-services-base-11.0.4-runtime (com.google.android.gms:play-services-base:11.0.4) and jetified-play-services-basement-17.6.0-runtime (com.google.android.gms:play-services-basement:17.6.0)

Go to the documentation to learn how to Fix dependency resolution errors.

It looks like your admob-plus-cordova plugin is also pulling in SDKs: admob-plus/plugin.xml at admob-plus-cordova@1.25.0 · admob-plus/admob-plus · GitHub

You’ll need to override it for both plugins.

Hi Volt Support,

Now that cordova-android 11 has been released, what is your expected timeline for adding support for JDK 11 and newer Android SDKs?

I tested with the sample-main project, and updated it to use
engine name=“android” spec=“11.0.0”

Other than that I only removed obsolete stuff, such as the whitelist plugin and splash screen plugin.

This is the error I am getting:
UserError: FAILURE: Build failed with an exception. * Where: Script ‘/agent/upload/ba081260-0de7-4a38-8096-22e0dd67fcfc/platforms/android/CordovaLib/cordova.gradle’ line: 75 * What went wrong: A problem occurred evaluating script. > No usable Android build tools found. Highest 32.x installed version is 30.0.3; Recommended version is 32.0.0.

The same project builds fine using cordova cli on my pc.

We’re testing cordova-android 11 now, and will have it up and running as soon as possible.

To get ready for it, start by making sure your project is not still on engine 9.

Sounds promising. The project is ready, because I built it using cordova cli 11, and successfully run a cordova-android 11 app. However after installing JDK 11 it fails when trying to build cordova-android 9.x. So my question is if volt builder will support multiple versions of JDK? One approach for doing this manually in cordova cli is mentioned here: Can We Work with Multiple JDK Version? · Issue #284 · apache/cordova · GitHub

"setting JAVA_HOME and PATH environment variables. In POSIX shells (e.g. Git Bash) this could look like this:

export JAVA_HOME=C:/oldJava/jdk8
export PATH=$JAVA_HOME/bin:$PATH

In Windows cmd:

set JAVA_HOME=C:\oldJava\jdk8
set PATH=%JAVA_HOME%\bin;%PATH%

After that, all commands in this shell session will use the updated environment variables. So you can just use cordova run android"

That’s exactly what we’re working on. :slightly_smiling_face:

@nor, I just emailed you information about participating in our beta. Let us know what you find.

@wrappingduke, I just emailed you information about participating in our beta. Let us know what you find.

Thanks a lot, it’s working fine on the servers.