ionic-team / trapeze

The mobile project configuration toolbox. Manage native iOS, Android, Ionic/Capacitor, React Native, and Flutter apps through a simple YAML format.
https://trapeze.dev
Other
323 stars 40 forks source link

Java runtime mismatch #152

Closed kristojorg closed 1 year ago

kristojorg commented 1 year ago

I am trying to use trapeze to auto-increment my build numbers on AppFlow. I can successfully build my app on iOS, but when trying to build and Android binary, I get the below error. It seems to be caused by trapeze because when I remove trapeze, everything works and the build is fine. Is there a way to use a newer version of the Java Runtime?

[17:47:05]: $ npm run appflow:build
[17:47:06]: ▸ > oeh@3.0.0 appflow:build
[17:47:06]: ▸ > npx trapeze run appflow.yml -y && npm run build
[17:47:08]: ▸ run ios buildNumber 49
[17:47:08]: ▸ run android versionCode 49
[17:47:10]: ▸ Fatal error: Error running command
[17:47:10]: ▸ Error: Unable to load or parse gradle file: Error: A JNI error has occurred, please check your installation and try again,
[17:47:10]: ▸ ,Exception ,in thread "main" ,java.lang.UnsupportedClassVersionError: com/capacitorjs/gradle/Parse has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0,
[17:47:10]: ▸ , at java.lang.ClassLoader.defineClass1(Native Method),
[17:47:10]: ▸ , at java.lang.ClassLoader.defineClass(ClassLoader.java:756),
[17:47:10]: ▸ , at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142),
[17:47:10]: ▸ , at java.net.URLClassLoader.defineClass(URLClassLoader.java:473),
[17:47:10]: ▸ , at java.net.URLClassLoader.access$100(URLClassLoader.java:74),
[17:47:10]: ▸ , at java.net.URLClassLoader$1.run(URLClassLoader.java:369),
[17:47:10]: ▸ , at java.net.URLClassLoader$1.run(URLClassLoader.java:363),
[17:47:10]: ▸ , at java.security.AccessController.doPrivileged(Native Method),
[17:47:10]: ▸ , at java.net.URLClassLoader.findClass(URLClassLoader.java:362),
[17:47:10]: ▸ , at java.lang.ClassLoader.loadClass(ClassLoader.java:418),
[17:47:10]: ▸ , at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352),
[17:47:10]: ▸ , at java.lang.ClassLoader.loadClass(ClassLoader.java:351),
[17:47:10]: ▸ , at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:601),
[17:47:10]: ▸ at GradleFile.parse (/builds/NYPL-Simplified/circulation-patron-web/node_modules/@trapezedev/project/dist/android/gradle-file.js:228:19)
[17:47:10]: ▸ at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[17:47:10]: ▸ at async GradleFile.replaceProperties (/builds/NYPL-Simplified/circulation-patron-web/node_modules/@trapezedev/project/dist/android/gradle-file.js:53:9)
[17:47:10]: ▸ at async executeOperations (/builds/NYPL-Simplified/circulation-patron-web/node_modules/@trapezedev/configure/dist/tasks/run.js:52:10)
[17:47:10]: ▸ at async runCommand (/builds/NYPL-Simplified/circulation-patron-web/node_modules/@trapezedev/configure/dist/tasks/run.js:31:9)
[17:47:10]: ▸ at async /builds/NYPL-Simplified/circulation-patron-web/node_modules/@trapezedev/configure/dist/index.js:56:13
[17:47:10]: ▸ at async Command.<anonymous> (/builds/NYPL-Simplified/circulation-patron-web/node_modules/@trapezedev/configure/dist/util/cli.js:31:13)
[17:47:10]: ▸ npm ERR! Lifecycle script `appflow:build` failed with error:
[17:47:10]: ▸ npm ERR! Error: command failed
[17:47:10]: ▸ npm ERR!   in workspace: oeh@3.0.0
[17:47:10]: ▸ npm ERR!   at location: /builds/NYPL-Simplified/circulation-patron-web/apps/oeh
mlynch commented 1 year ago

Hi, have you filed a ticket with Appflow support? They have some recommendations for handling the location of java in the environment

kristojorg commented 1 year ago

I have not, but will do that now. It appears that trapeze is for some reason using the Java 8 that is installed instead of the Java 11

mlynch commented 1 year ago

Sounds great. Right now the resolution for Java is that it will first use the one in your path if that's available, or it will use the one at JAVA_HOME. So you can try setting JAVA_HOME but support will be able to help with the right paths/etc.

https://github.com/ionic-team/trapeze/blob/main/packages/project/src/android/gradle-file.ts#L507