Search code examples
androidmavenjavafxgluon-mobile

Install on Android device fails for gluonfx:install command, file not found


I'm working through Gluon's online documentation for Gluon-Mobile, for the Android Platform, on my Ubuntu 20.04 desktop. I attempted to follow this instruction directly from my CLI (not from Eclipse).

To install the application to a connected android device, run mvn -Pandroid gluonfx:install.

This is puzzling to me, as I don't understand how the device which I have attached to my Ubuntu desktop (via USB) is going to be sensed. I have successfully compiled to the Android device before, when using AndroidStudio, as it has a control that allows one to choose the connected phone as the target.

Upon running the commands (thinking that I'd perhaps be asked to identify the target device or that it might somehow be sensed automatically), I got the following exception:

phil@UbuntuDesktop:~/Projects/metronome/gluon-samples-master/HelloFX$ mvn -Pandroid gluonfx:install
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO] Scanning for projects...
[INFO] 
[INFO] --------------------< com.gluonhq.samples:hellofx >---------------------
[INFO] Building HelloFX 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- gluonfx-maven-plugin:1.0.5:install (default-cli) @ hellofx ---
[Sat Sep 18 19:22:41 PDT 2021][INFO] ==================== INSTALL TASK ====================
java.io.IOException: Cannot run program "/home/phil/Projects/metronome/gluon-samples-master/HelloFX/target/gluonfx/aarch64-android/gvm/android_project/gradlew": error=2, No such file or directory
    at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1142)

The file location ../HelloFX/target/gluonfx/aarch64-android/gvm only holds two directories: /log and /tmp. There is no gvm/android_project directory or gradlew file. The log file in that directory holds the following information about the run:

[Sat Sep 18 19:22:41 PDT 2021][FINE] PB Command for install-task: /home/phil/Projects/metronome/gluon-samples-master/HelloFX/target/gluonfx/aarch64-android/gvm/android_project/gradlew -p /home/phil/Projects/metronome/gluon-samples-master/HelloFX/target/gluonfx/aarch64-android/gvm/android_project installDebug
[Sat Sep 18 19:22:41 PDT 2021][FINE] Start process install-task...

Perhaps there are steps that I omitted that are "so obvious" that they are not included in the documentation? For example there are either arguments to be included with the gluonfx:install command or properties to set in the pom.xml file?

Previous steps in the instructions were successful executed:

../gluon-samples-master/HelloFX$ mvn gluonfx:run

The program runs and the window and graphic display the following message:

Hello, JavaFX 16, running on Java 15.0.2.

../gluon-samples-master/HelloFX$ mvn -Pandroid gluonfx:build

The program reaches the BUILD SUCCESS point. Among the messages on the console is the following:

[Sat Sep 18 18:58:06 PDT 2021][INFO] [SUB] # Printing build artifacts to: /home/phil/Projects/metronome/gluon-samples-master/HelloFX/target/gluonfx/x86_64-linux/gvm/HelloFX/hellofx.hellofx.build_artifacts.txt

Inspecting this directory, this file and others exist. But I do not see any instructions here on running this build or how to otherwise verify the build.


I also tried running the command mvn -Pandroid gluonfx:nativerun with unsuccessful results:

phil@UbuntuDesktop:~/Projects/metronome/gluon-samples-master/HelloFX$ mvn -Pandroid gluonfx:nativerun
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO] Scanning for projects...
[INFO] 
[INFO] --------------------< com.gluonhq.samples:hellofx >---------------------
[INFO] Building HelloFX 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- gluonfx-maven-plugin:1.0.5:nativerun (default-cli) @ hellofx ---
[Sat Sep 18 20:09:35 PDT 2021][INFO] ==================== RUN TASK ====================
[Sat Sep 18 20:09:37 PDT 2021][SEVERE] Process run failed with result: 252
Check the log files under /home/phil/Projects/metronome/gluon-samples-master/HelloFX/target/gluonfx/aarch64-android/gvm/log
And please check https://docs.gluonhq.com/ for more information.
[Sat Sep 18 20:09:37 PDT 2021][INFO] Logging process [run] to file: /home/phil/Projects/metronome/gluon-samples-master/HelloFX/target/gluonfx/log/process-run-1632020977612.log
java.io.IOException: Application starting failed!
    at com.gluonhq.substrate.target.AndroidTargetConfiguration.runUntilEnd(AndroidTargetConfiguration.java:213)
    at com.gluonhq.substrate.SubstrateDispatcher.nativeRun(SubstrateDispatcher.java:492)
    at com.gluonhq.NativeRunMojo.execute(NativeRunMojo.java:45)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.006 s
[INFO] Finished at: 2021-09-18T20:09:37-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.gluonhq:gluonfx-maven-plugin:1.0.5:nativerun (default-cli) on project hellofx: Error: Application starting failed!

The cited log contents are as follows:

Sat Sep 18 20:09:35 PDT 2021][INFO] ==================== RUN TASK ====================
[Sat Sep 18 20:09:35 PDT 2021][FINE] PB Command for clearLog: /home/phil/Android/Sdk/platform-tools/adb logcat -c
[Sat Sep 18 20:09:35 PDT 2021][FINE] Start process clearLog...
[Sat Sep 18 20:09:35 PDT 2021][FINE] PB Command for run: /home/phil/Android/Sdk/platform-tools/adb shell monkey -p com.gluonhq.samples.hellofx 1
[Sat Sep 18 20:09:35 PDT 2021][FINE] Start process run...
[Sat Sep 18 20:09:36 PDT 2021][FINE] Result for clearLog: 0
[Sat Sep 18 20:09:36 PDT 2021][FINE] PB Command for log: /home/phil/Android/Sdk/platform-tools/adb logcat -v brief -v color GraalCompiled:V GraalActivity:V GraalGluon:V GluonAttach:V AndroidRuntime:E ActivityManager:W *:S
[Sat Sep 18 20:09:36 PDT 2021][FINE] Start process log...
[Sat Sep 18 20:09:37 PDT 2021][FINE] [SUB] ** No activities found to run, monkey aborted.
[Sat Sep 18 20:09:37 PDT 2021][FINE] Result for run: 252
[Sat Sep 18 20:09:37 PDT 2021][SEVERE] Process run failed with result: 252
Check the log files under /home/phil/Projects/metronome/gluon-samples-master/HelloFX/target/gluonfx/aarch64-android/gvm/log
And please check https://docs.gluonhq.com/ for more information.
[Sat Sep 18 20:09:37 PDT 2021][INFO] Logging process [run] to file: /home/phil/Projects/metronome/gluon-samples-master/HelloFX/target/gluonfx/log/process-run-1632020977612.log 

Adding to my hesitancy, parts of the documentation seem to be going stale, and I have to wonder if I made the right adjustments in response. For example, the documentation refers to "required packages" and the list includes: ndk-bundle but I have not been able to locate anything with this exact name. But I have installed the NDK tools via my AndroidStudio SDK Manager. The Android tools selection did not list required packages extras;android:m2repository or extras;google:m2repository either.


Solution

  • The answer given by @JoséPereda in the comments seems to me like something we can post to resolve this particular question. He writes that in order to run the app on the device, the app must first be packaged.

    Thus, if I understand this and if it hasn't already been corrected, the steps mentioned in section https://docs.gluonhq.com/#platforms_android_development_run should actually come after packaging, which is discussed in the section https://docs.gluonhq.com/#platforms_android_distribution_build.