Execution failed for task ':capacitor-android:compileDebugJavaWithJavac'. > error: invalid source release: 21

the interesting thing is that i never installed java version 21, but i use 17, with which i have created apk before, what is going on?

Welcome to Gradle 8.11.1!

Here are the highlights of this release:

  • Parallel load and store for Configuration Cache
  • Java compilation errors at the end of the build output
  • Consolidated report for warnings and deprecations

For more details see Gradle 8.11.1 Release Notes

Starting a Gradle Daemon (subsequent builds will be faster)

Configure project :app
WARNING: Using flatDir should be avoided because it doesn’t support any meta-data formats.

Configure project :capacitor-cordova-android-plugins
WARNING: Using flatDir should be avoided because it doesn’t support any meta-data formats.
Errors during XML parse:
Additionally, the fallback loader failed to parse the XML.
Checking the license for package Android SDK Platform 35 in /opt/android-sdk/licenses
License for package Android SDK Platform 35 accepted.
Preparing “Install Android SDK Platform 35 (revision 2)”.
“Install Android SDK Platform 35 (revision 2)” ready.
Installing Android SDK Platform 35 in /opt/android-sdk/platforms/android-35
“Install Android SDK Platform 35 (revision 2)” complete.
“Install Android SDK Platform 35 (revision 2)” finished.

Task :app:preBuild UP-TO-DATE
Task :app:preDebugBuild UP-TO-DATE
Task :app:mergeDebugNativeDebugMetadata NO-SOURCE
Task :capacitor-android:preBuild UP-TO-DATE
Task :capacitor-android:preDebugBuild UP-TO-DATE
Task :app:javaPreCompileDebug
Task :capacitor-cordova-android-plugins:preBuild UP-TO-DATE
Task :capacitor-cordova-android-plugins:preDebugBuild UP-TO-DATE
Task :capacitor-cordova-android-plugins:writeDebugAarMetadata
Task :capacitor-android:writeDebugAarMetadata
Task :app:generateDebugResValues
Task :capacitor-android:generateDebugResValues
Task :app:checkDebugAarMetadata
Task :capacitor-android:generateDebugResources
Task :capacitor-android:packageDebugResources
Task :capacitor-cordova-android-plugins:generateDebugResValues
Task :capacitor-cordova-android-plugins:generateDebugResources
Task :capacitor-cordova-android-plugins:packageDebugResources
Task :app:mapDebugSourceSetPaths
Task :app:generateDebugResources
Task :app:packageDebugResources
Task :app:createDebugCompatibleScreenManifests
Task :app:extractDeepLinksDebug
Task :capacitor-android:extractDeepLinksDebug
Task :capacitor-cordova-android-plugins:extractDeepLinksDebug
Task :capacitor-cordova-android-plugins:processDebugManifest
Task :capacitor-android:processDebugManifest
Task :app:parseDebugLocalResources
Task :app:mergeDebugResources
Task :capacitor-android:compileDebugLibraryResources
Task :app:processDebugMainManifest
Task :app:processDebugManifest
Task :app:processDebugManifestForPackage
Task :capacitor-cordova-android-plugins:compileDebugLibraryResources
Task :capacitor-android:javaPreCompileDebug
Task :capacitor-cordova-android-plugins:javaPreCompileDebug
Task :capacitor-android:parseDebugLocalResources
Task :capacitor-cordova-android-plugins:parseDebugLocalResources
Task :app:mergeDebugShaders
Task :app:compileDebugShaders NO-SOURCE
Task :app:generateDebugAssets UP-TO-DATE
Task :capacitor-android:mergeDebugShaders
Task :capacitor-android:compileDebugShaders NO-SOURCE
Task :capacitor-cordova-android-plugins:generateDebugRFile
Task :capacitor-android:generateDebugRFile
Task :capacitor-cordova-android-plugins:compileDebugJavaWithJavac NO-SOURCE
Task :app:processDebugResources
Task :capacitor-android:compileDebugJavaWithJavac FAILED
[Incubating] Problems report is available at: file:///android/build/reports/problems/problems-report.html

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:capacitor-android:compileDebugJavaWithJavac’.

error: invalid source release: 21

  • Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org.

Are you using Capacitor 7?

We’ve got a beta running for that. I’ve just sent you instructions on how to use it.

Let us know if that takes care of your issue.

I also tried 6.2, but it tells me it requires 7.0.1. can you give me the link with the instructions to make it work with android 7.0.1?

You should have gotten an email by now, but here’s the content:

Good news! We’ve made updates to our Capacitor build process.

  1. Support added for Capacitor 7: You can now use Ionic’s latest version of Capacitor.

  2. Build stack updated: lots updates to tools, SDKs, operating systems, etc.: Everything is now on the latest version.

  3. The Capacitor sample has been updated to use Capacitor 7.

You shouldn’t notice any difference to how your jobs run or their output. To be certain of this, we’re running a limited time beta.

On the Upload screen, you will notice a new prompt: “Build using beta servers?”. It would be of great help to us and others if you could submit your job and let us know if it works OK.

As always, if you have suggestions how we can make VoltBuilder better, please let us know!

I just noticed you signed up to VoltBuilder using more than one email address, and that you submitted again under the new email.

I have enabled that email address as well - give it another try!

Hi There,

I’m experiencing the same issue since two days (error: invalid source release: 21), I cannot build for Android using approximately the same archive that worked last week.

I’m using capacitor 7 which actually uses JVM 21, here is the Capacitor doctor :

:pill: Capacitor Doctor :pill:

Latest Dependencies:

@capacitor/cli: 7.2.0
@capacitor/core: 7.2.0
@capacitor/android: 7.2.0
@capacitor/ios: 7.2.0

Installed Dependencies:

@capacitor/cli: 7.2.0
@capacitor/core: 7.2.0
@capacitor/android: 7.2.0
@capacitor/ios: 7.2.0

[success] iOS looking great! :ok_hand:
[success] Android looking great! :ok_hand:

Kind regards, François.

Can you provide a build ID or log for your build? Thank you!

Of course here it is : f5918263-d71c-4400-9f1f-f3e4b4949b6a

The full logs is too long to be put here but here is the link anyway : https://apps.volt.build/f5918263-d71c-4400-9f1f-f3e4b4949b6a/voltbuilder.log

Thanks for quick answer :pray:

Looks like it’s a plugin issue - possibly your version of Google Maps, possibly something else.

The only way to figure out which one is to remove various plugins and try building again, in a binary search.

@ghenne maybe it is a plugin issue, I’m gonna look into that thanks, but then why did it worked like a charm two weeks ago ?
My Google Maps plugin has not been updated since then and I upload a package-lock.json file precisely to avoid this kind of disagreements…

We updated to Java 21 about two weeks ago. This was required to support Capacitor 7.

Please let us know if you can find the plugin causing the issue. If not, we can provide a flag to downgrade to compiling with Java 17, but ideally you should update your dependencies to work with the latest version of Java that capacitor 7 requires.

Hi there,

I removed my custom Google Maps plugin and replaced it with the official one and it still fails the same way as Build Id : 157ae4b2-b0da-4ae7-847f-0c4af420725c

It seems it would now be the official Capacitor Status Bar that ruins it, as it is the last task executed but I don’t think it really is…

Is there a more detailed log I can get ?

This is almost certainly an issue with one of your dependencies not being ready for Java 21 (which Capacitor 7 requires. There’s not a more detailed log. However I will be working to add a config option to allow building using older versions of Java. I expect this to be done today - however this isn’t a long term fix. You’ll need to sort out which plugin is causing the issue. I suggest removing half, seeing if the problem persists, and then repeating until you’re down to one.

You can now attempt a build using the following flag in your voltbuilder.json:

{
  "capacitor": {
    "jvm_21": false
  }
}

This will fall back to JVM 17, which was the default before our upgrade a few weeks ago.

I’ve updated all dependencies and my custom Google Maps plugin as well and now builds pass using JVM 21.
I know my custom plugin was making builds fail and I know that another plugin was too but unfortunately I’m unable to say which one…

Thank you guys a lot :pray:

FYI in order to build with JVM 21 I have to set this now, if not it defaults to 17 :

    "capacitor": {
        "jvm_21": true
    }

Can I see your package.json?

{
  "name": "geo-convois",
  "version": "3.0.0",
  "description": "GeoConvois V3 - Application de suivi de réalisation de convois exceptionnels.",
  "main": "main.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "webpack serve --config webpack.dev.js --mode development",
    "dash": "webpack-dashboard -- webpack serve --config webpack.dev.js --mode development",
    "stop": "taskkill /f /im node.exe",
    "dev": "npm run start && http-server dist",
    "build": "webpack --config webpack.prod.js --mode production && npx cap sync",
    "capbuild": "webpack --config webpack.prod.js --mode production && npx cap sync",
    "voltbuild": "webpack --config webpack.prod.js --mode production && rm -R VoltBuilder/www/* && cp -R dist/ VoltBuilder/www && rm VoltBuilder/www/stores.html && echo \"DON'T FORGET TO ADD cordova.js reference in index.html. Then You will have to zip required files and upload to Volt.Build !\"",
    "zipbuild": "rm app.zip ; zip -r -X app.zip VoltBuilder/",
    "xcode": "npx cap open ios",
    "studio": "npx cap open android",
    "ios": "npx cap run ios",
    "android": "npx cap run android",
    "preview": "npm run build && http-server dist"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/SNS-SOLUTIONS/GeoCap.git"
  },
  "author": "François-Régis SIMON",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/SNS-SOLUTIONS/GeoCap/issues"
  },
  "homepage": "https://github.com/SNS-SOLUTIONS/GeoCap#readme",
  "devDependencies": {
    "@babel/core": "^7.26.10",
    "@babel/preset-env": "^7.26.9",
    "@capacitor/android": "^7.2.0",
    "@capacitor/cli": "^7.2.0",
    "@capacitor/core": "^7.2.0",
    "@capacitor/ios": "^7.2.0",
    "@fullhuman/postcss-purgecss": "^7.0.2",
    "autoprefixer": "^10.4.21",
    "babel-loader": "^10.0.0",
    "clean-webpack-plugin": "^4.0.0",
    "css-loader": "^7.1.2",
    "css-minimizer-webpack-plugin": "^7.0.2",
    "file-loader": "^6.2.0",
    "html-loader": "^5.1.0",
    "html-webpack-plugin": "^5.6.3",
    "http-server": "^14.1.1",
    "mini-css-extract-plugin": "^2.9.2",
    "postcss": "^8.5.3",
    "postcss-loader": "^8.1.1",
    "regenerator-runtime": "^0.14.1",
    "sass": "^1.86.3",
    "sass-loader": "^16.0.5",
    "style-loader": "^4.0.0",
    "terser-webpack-plugin": "^5.3.14",
    "url-loader": "^4.1.1",
    "webpack": "^5.99.6",
    "webpack-cli": "^6.0.1",
    "webpack-dashboard": "^3.3.8",
    "webpack-dev-server": "^5.2.1"
  },
  "dependencies": {
    "@awesome-cordova-plugins/core": "^6.16.0",
    "@awesome-cordova-plugins/device-orientation": "^6.16.0",
    "@capacitor-community/background-geolocation": "^1.2.22",
    "@capacitor-community/keep-awake": "^7.0.0",
    "@capacitor-community/safe-area": "^7.0.0-alpha.1",
    "@capacitor-mlkit/translation": "^7.2.1",
    "@capacitor/app": "^7.0.1",
    "@capacitor/browser": "^7.0.1",
    "@capacitor/device": "^7.0.1",
    "@capacitor/dialog": "^7.0.1",
    "@capacitor/geolocation": "^7.1.1",
    "@capacitor/haptics": "^7.0.1",
    "@capacitor/keyboard": "^7.0.1",
    "@capacitor/motion": "^7.0.0",
    "@capacitor/network": "^7.0.1",
    "@capacitor/screen-orientation": "^7.0.1",
    "@capacitor/share": "^7.0.1",
    "@capacitor/splash-screen": "^7.0.1",
    "@capacitor/status-bar": "^7.0.1",
    "@flossyweb/capacitor-google-maps": "^7.0.1",
    "@fortawesome/fontawesome-free": "^6.7.2",
    "@ionic/core": "^8.5.5",
    "@mapbox/polyline": "^1.2.1",
    "@mapbox/togeojson": "^0.16.2",
    "@popperjs/core": "^2.11.8",
    "bootstrap": "^5.3.5",
    "bootstrap-icons": "^1.11.3",
    "cordova-plugin-device-orientation": "^3.0.0",
    "geojson-bounds": "^1.0.4",
    "jquery": "^3.7.1",
    "navigo": "^8.11.1",
    "sweetalert2": "^11.19.1",
    "swiper": "^11.2.6",
    "togpx": "^0.5.4"
  },
  "dependenciesComments": {
    "Comments": "Having together @capacitor/google-maps and @flossyweb/capacitor-google-maps makes Volt.Build fail with 2 duplicate symbols error",
    "@capacitor/google-maps": "^7.0.1"
  }
}

I see the issue - we’ll get a fix out for this ASAP, but you should be good to go regardless.