在 Android 设备上安装 gluonfx:install 命令失败,找不到文件

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

我正在阅读 Gluon 的 Gluon-Mobilefor the Android Platform 的在线文档,在我的 Ubuntu 20.04桌面。我试图直接从我的 CLI(而不是 Eclipse)中遵循这个指令。

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

这让我感到困惑,因为我不明白我连接到 Ubuntu 桌面(通过 USB)的设备将如何被感知。我之前已经成功编译到 Android 设备,当使用 AndroidStudio 时,因为它有一个控件允许选择连接的 phone作为目标。

在 运行 执行命令后(认为我可能会被要求识别目标设备或者它可能会以某种方式自动检测到),我得到以下异常:

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 (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
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)

文件位置 ../HelloFX/target/gluonfx/aarch64-android/gvm 仅包含两个目录:/log/tmp。没有 gvm/android_project 目录或 gradlew 文件。该目录中的日志文件包含有关 运行 的以下信息:

[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...

也许我省略了一些“非常明显”的步骤,以至于它们没有包含在文档中?例如,要包含在 gluonfx:install 命令中的参数或要在 pom.xml 文件中设置的属性?

说明中的前面步骤已成功执行:

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

程序 运行s 和 window 以及图形显示以下消息:

Hello, JavaFX 16, running on Java 15.0.2.

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

程序达到构建成功点。控制台上的消息如下:

[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

正在检查这个目录,这个文件和其他文件是否存在。但是我在这里没有看到任何关于 运行 构建此构建或如何验证构建的说明。


我也尝试了 运行ning 命令 mvn -Pandroid gluonfx:nativerun 但结果不成功:

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 (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
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!

引用日志内容如下:

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 

增加了我的犹豫,部分文档似乎变得陈旧,我想知道我是否做出了正确的响应调整。例如,文档提到“必需的包”并且列表包括:ndk-bundle 但我无法找到具有这个确切名称的任何内容。但是我已经通过 AndroidStudio SDK Manager 安装了 NDK 工具。 Android 工具选择未列出所需的软件包 extras;android:m2repositoryextras;google:m2repository

@JoséPereda 在评论中给出的答案在我看来像是我们可以 post 解决这个特定问题的东西。他写道,为了 运行 设备上的应用程序,必须先将应用程序打包。

因此,如果我理解这一点并且尚未更正,请执行 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.

部分中提到的步骤