0

Our app was already using GluonFX 1.0.12. And we were able to build APK (with OpenJDK 11).

I've updated the GluonFX to 1.0.16 now. I am able to run the app. And running the app through mvn gluonfx:runagent goal is also working fine. But building using mvn gluonfx:build gluonfx:package -Pandroid results in error.

So I generated a sample project from start.gluon.io and tried to build APK with same configuration, and it also failed returing same error, as shown below.

[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB] [1/7] Initializing...                                                                                    (0.0s @ 0.13GB)
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB] Fatal error: java.lang.UnsupportedClassVersionError: javafx/application/Application has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB]  at java.base/java.lang.ClassLoader.defineClass1(Native Method)
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB]  at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB]  at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB]  at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:555)
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB]  at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:458)
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB]  at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:452)
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB]  at java.base/java.security.AccessController.doPrivileged(Native Method)
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB]  at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:451)
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB]  at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB]  at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB]  at java.base/java.lang.ClassLoader.defineClass1(Native Method)
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB]  at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB]  at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB]  at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:555)
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB]  at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:458)
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB]  at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:452)
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB]  at java.base/java.security.AccessController.doPrivileged(Native Method)
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB]  at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:451)
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB]  at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB]  at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB]  at java.base/java.lang.Class.forName0(Native Method)
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB]  at java.base/java.lang.Class.forName(Class.java:398)
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB]  at com.oracle.svm.hosted.ImageClassLoader.forName(ImageClassLoader.java:291)
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB]  at com.oracle.svm.hosted.ImageClassLoader.forName(ImageClassLoader.java:287)
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB]  at com.oracle.svm.hosted.ImageClassLoader.forName(ImageClassLoader.java:296)
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB]  at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:343)
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB]  at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:585)
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB]  at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:128)
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB]  at com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus.main(NativeImageGeneratorRunner.java:615)
[Wed Dec 28 15:02:03 IST 2022][INFO] [SUB] Error: Image build request failed with exit status 1
[Wed Dec 28 15:02:03 IST 2022][FINE] Result for compile: 1
[Wed Dec 28 15:02:03 IST 2022][SEVERE] Process compile failed with result: 1
Check the log files under /home/manikandan/git/hellojavafx/target/gluonfx/aarch64-android/gvm/log
And please check https://docs.gluonhq.com/ for more information.
[Wed Dec 28 15:02:03 IST 2022][INFO] Logging process [compile] to file: /home/manikandan/git/hellojavafx/target/gluonfx/log/process-compile-1672219923249.log
[Wed Dec 28 15:02:03 IST 2022][SEVERE] Compiling failed.
Check the log files under /home/manikandan/git/hellojavafx/target/gluonfx/aarch64-android/gvm/log
And please check https://docs.gluonhq.com/ for more information.

Complete log can be found here

Here's the pom.xml file.

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.manikandan</groupId>
    <artifactId>myapplication</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>HelloJavafx</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.release>11</maven.compiler.release>
        <javafx.version>19</javafx.version>
        <javafx.plugin.version>0.0.8</javafx.plugin.version>
        <gluonfx.plugin.version>1.0.16</gluonfx.plugin.version>
        <main.class>com.manikandan.sample.Main</main.class>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-base</artifactId>
            <version>${javafx.version}</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-graphics</artifactId>
            <version>${javafx.version}</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>${javafx.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
            </plugin>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>${javafx.plugin.version}</version>
                <configuration>
                    <mainClass>${main.class}</mainClass>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.gluonhq</groupId>
                <artifactId>gluonfx-maven-plugin</artifactId>
                <version>${gluonfx.plugin.version}</version>
                <configuration>
                    <target>${gluonfx.target}</target>
                    <mainClass>${main.class}</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>android</id>
            <properties>
                <gluonfx.target>android</gluonfx.target>
            </properties>
        </profile>
        <profile>
            <id>ios</id>
            <properties>
                <gluonfx.target>ios</gluonfx.target>
            </properties>
        </profile>
    </profiles>
</project>

I am using OpenJDK 11.0,14.

manikandan@manikandan-VirtualBox:~/git/hellojavafx$ java -version
openjdk version "11.0.14.1" 2022-02-08
OpenJDK Runtime Environment (build 11.0.14.1+1-Ubuntu-0ubuntu1.20.04)
OpenJDK 64-Bit Server VM (build 11.0.14.1+1-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)

And I am using graalvm-svm-java11-linux-gluon-22.1.0.1-Final.

manikandan@manikandan-VirtualBox:~/git/hellojavafx$ echo $GRAALVM_HOME
/media/sf_linux_softwares/graalvm-svm-java11-linux-gluon-22.1.0.1-Final

Please let me know what is the cause of this error?

Update 1:- As suggested, I've added javafxStaticSdkVersion-19 to gluonfx configuration.

<plugin>
    <groupId>com.gluonhq</groupId>
    <artifactId>gluonfx-maven-plugin</artifactId>
    <version>${gluonfx.plugin.version}</version>
    <configuration>
        <target>${gluonfx.target}</target>
        <mainClass>${main.class}</mainClass>
        <javafxStaticSdkVersion>19</javafxStaticSdkVersion>
    </configuration>
</plugin>

But now the build fails at linking stage.

[Thu Dec 29 11:13:04 IST 2022][INFO] ==================== LINK TASK ====================
[Thu Dec 29 11:13:07 IST 2022][INFO] [SUB] /media/sf_linux_softwares/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: unrecognized option '--rosegment'
[Thu Dec 29 11:13:07 IST 2022][INFO] [SUB] /media/sf_linux_softwares/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: use the --help option for usage information
[Thu Dec 29 11:13:07 IST 2022][INFO] [SUB] clang++: error: linker command failed with exit code 1 (use -v to see invocation)
[Thu Dec 29 11:13:07 IST 2022][SEVERE] Process link failed with result: 1
Check the log files under /home/manikandan/git/hellojavafx/target/gluonfx/aarch64-android/gvm/log
And please check https://docs.gluonhq.com/ for more information.
[Thu Dec 29 11:13:07 IST 2022][INFO] Logging process [link] to file: /home/manikandan/git/hellojavafx/target/gluonfx/log/process-link-1672292587129.log
[Thu Dec 29 11:13:07 IST 2022][SEVERE] Linking failed.
Check the log files under /home/manikandan/git/hellojavafx/target/gluonfx/aarch64-android/gvm/log
And please check https://docs.gluonhq.com/ for more information.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  06:35 min
[INFO] Finished at: 2022-12-29T11:13:07+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.gluonhq:gluonfx-maven-plugin:1.0.16:link (default-cli) on project myapplication: Linking failed -> [Help 1]

I am using android-ndk-r21b. Does gluonfx 1.0.16 require latest version of ndk ?

Update2:-

I let the plugin download the SDK, and I separately downloaded NDK r25b and updated PATH of 'ANDROID_NDK'

Now the build fails with "error: 127, clang not found" (shown below)

[Fri Dec 30 16:46:09 IST 2022][INFO] ==================== COMPILE TASK ====================
[Fri Dec 30 16:46:11 IST 2022][INFO] We will now compile your code for aarch64-linux-android. This may take some time.
[Fri Dec 30 16:46:11 IST 2022][FINE] Extracting native libs to: /home/manikandan/git/hellojavafx/target/gluonfx/aarch64-android/gvm/lib
[Fri Dec 30 16:46:11 IST 2022][FINE] Looking for resource: /native/android/c/dummy.c
[Fri Dec 30 16:46:11 IST 2022][FINE] Looking for resource: /native/android/c/launcher.c
[Fri Dec 30 16:46:11 IST 2022][FINE] Looking for resource: /native/android/c/javafx_adapter.c
[Fri Dec 30 16:46:11 IST 2022][FINE] Looking for resource: /native/android/c/touch_events.c
[Fri Dec 30 16:46:11 IST 2022][FINE] Looking for resource: /native/android/c/glibc_shim.c
[Fri Dec 30 16:46:11 IST 2022][FINE] Looking for resource: /native/android/c/attach_adapter.c
[Fri Dec 30 16:46:11 IST 2022][FINE] Looking for resource: /native/android/c/logger.c
[Fri Dec 30 16:46:11 IST 2022][FINE] Looking for resource: /native/android/c/grandroid.h
[Fri Dec 30 16:46:11 IST 2022][FINE] Looking for resource: /native/android/c/grandroid_ext.h
[Fri Dec 30 16:46:11 IST 2022][FINE] PB Command for compile-additional-sources: /media/sf_linux_softwares/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -c -DSUBSTRATE -target aarch64-linux-android -I. -fPIC -I/home/manikandan/git/hellojavafx/target/gluonfx/aarch64-android/gvm/HelloJavafx dummy.c launcher.c javafx_adapter.c touch_events.c glibc_shim.c attach_adapter.c logger.c
[Fri Dec 30 16:46:11 IST 2022][FINE] Start process compile-additional-sources...
[Fri Dec 30 16:46:11 IST 2022][FINE] [SUB] /media/sf_linux_softwares/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang: 1: clang-14: not found
[Fri Dec 30 16:46:11 IST 2022][FINE] Result for compile-additional-sources: 127
[Fri Dec 30 16:46:11 IST 2022][SEVERE] Process compile-additional-sources failed with result: 127
Check the log files under /home/manikandan/git/hellojavafx/target/gluonfx/aarch64-android/gvm/log
And please check https://docs.gluonhq.com/ for more information.
[Fri Dec 30 16:46:11 IST 2022][INFO] Logging process [compile-additional-sources] to file: /home/manikandan/git/hellojavafx/target/gluonfx/log/process-compile-additional-sources-1672398971174.log
[Fri Dec 30 16:46:11 IST 2022][SEVERE] Compiling failed.
Check the log files under /home/manikandan/git/hellojavafx/target/gluonfx/aarch64-android/gvm/log
And please check https://docs.gluonhq.com/ for more information.

But I checked the directory specified in error log, and clang-14 is there. clang-location-linux

How to handle this error ?

  • Can you try adding to the configuration of the GluonFX plugin `19`? Else, can you use JDK 17 and graalvm-svm-java17-linux-gluon-22.1.0.1-Final? – José Pereda Dec 28 '22 at 13:42
  • Hi @JoséPereda . Thanks for the reply. I've added javafx sdk version as you suggested. Now the previous error doesn't show up. But now it fails at linking stage. Please review it and let me know if I have to change android ndk version. – Mani kandan Dec 29 '22 at 06:03
  • Got it. https://github.com/gluonhq/gluonfx-maven-plugin/issues/439#issuecomment-1242767448. I have to use latest NDK. I'll try with latest version. – Mani kandan Dec 29 '22 at 08:27
  • Yes, but you can simply remove your ~/.gluon/substrate/Android folder and let the plugin install everything again (mainly NDK and Android SDK). – José Pereda Dec 29 '22 at 08:45
  • Can you please tell which version of NDK does gluonfx 1.0.16 require ? Because, 'Downloading Android toolchain' takes too long to download, and it never seems to complete. – Mani kandan Dec 30 '22 at 04:17
  • NDK-25 should work. – José Pereda Dec 30 '22 at 09:01
  • I've used ndk r25b, but it resulted in error : 127, clang not found. I've updated the details in question. Please let me know why this error occurs. – Mani kandan Dec 30 '22 at 11:48
  • If you run from a terminal `$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -v`, what do you see? – José Pereda Dec 30 '22 at 12:17
  • Following is shown when executed the command you specified - `bash: /toolchains/llvm/prebuilt/linux-x86_64/bin/clang: No such file or directory.` But when I checked there's a file 'clang', that has text 'clang-14' in it. – Mani kandan Dec 30 '22 at 12:34
  • right, but you don't have `ANDROID_NDK` in your path, make sure you add it to your `~/.bashrc`. – José Pereda Dec 30 '22 at 12:39
  • Forgot to add that. Now added it in `~/bashrc`. Now following message shows up when the command that you gave is executed `/media/sf_linux_softwares/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang: line 1: clang-14: command not found` – Mani kandan Dec 30 '22 at 13:22
  • Your NDK installation might not be correct? You should get something like: `$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/clang-14 -v Android (8490178, based on r450784d) clang version 14.0.6 (https://android.googlesource.com/toolchain/llvm-project 4c603efb0cca074e9238af8b4106c30add4418f6) Target: x86_64-unknown-linux-gnu`. That's why it is better if you let the GluonFX plugin take care of it. – José Pereda Dec 30 '22 at 13:30
  • Now the `clang-14 -v` command works. But still the build fails with `Process compile-additional-sources failed with result: 127`. Terminal log can be found [here](https://pastebin.com/twjiZUeF). – Mani kandan Jan 02 '23 at 04:36
  • Process compile log can be found [here](https://pastebin.com/GX2u4Tgh) – Mani kandan Jan 02 '23 at 04:44
  • From the last log you have posted, if you run that exact command line (`...clang -c ... `) from a terminal, does it fail as well?? – José Pereda Jan 03 '23 at 19:51
  • Yes. When I executed that command separately, I got `/media/sf_linux_softwares/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang: line 1: clang-14: command not found` error. – Mani kandan Jan 04 '23 at 09:05
  • Then there has to be something wrong with your setup, not related to the GluonFX plugin. Check your `$PATH`, permissions, uninstall NDK and try again... – José Pereda Jan 04 '23 at 09:16
  • I tried reinstalling NDK. But same issue occurs. As a final try, I would let gluonfx download NDK again. Can you please tell the approximate size of NDK that gluonfx 1.0.16 downloads?. Knowing that will help me assign some additional space for my VM. – Mani kandan Jan 04 '23 at 13:07
  • Once installed it is around 2 GB, but you also need space to download the bundle and uncompress it. – José Pereda Jan 04 '23 at 13:29

0 Answers0