在 Android 设备上安装 gluonfx:install 命令失败,找不到文件
Posted
技术标签:
【中文标题】在 Android 设备上安装 gluonfx:install 命令失败,找不到文件【英文标题】:Install on Android device fails for gluonfx:install command, file not found 【发布时间】:2021-11-13 07:36:29 【问题描述】:我正在我的 Ubuntu 20.04 桌面上浏览 Gluon 的 Gluon-Mobile 在线文档,for the android Platform。我试图直接从我的 CLI(而不是 Eclipse)中遵循这个指令。
要将应用程序安装到已连接的 Android 设备上,请运行 mvn -Pandroid gluonfx:install。
这让我很困惑,因为我不明白我连接到我的 Ubuntu 桌面(通过 USB)的设备将如何被感知。我之前在使用AndroidStudio时已经成功编译到Android设备上,因为它有一个控件,可以选择连接的手机作为目标。
在运行命令时(认为我可能会被要求识别目标设备或者它可能会以某种方式被自动感知),我得到了以下异常:
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)
文件位置../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
程序运行,窗口和图形显示以下消息:
您好,JavaFX 16,在 Java 15.0.2 上运行。
../gluon-samples-master/HelloFX$ mvn -Pandroid gluonfx:build
程序达到构建成功点。控制台上的消息如下:
[Sat Sep 18 18:58:06 PDT 2021][INFO] [SUB] # 将构建工件打印到:/home/phil/Projects/metronome/gluon-samples-master/HelloFX/target/gluonfx/x86_64- linux/gvm/HelloFX/hellofx.hellofx.build_artifacts.txt
检查这个目录,这个文件和其他文件是否存在。但我在这里没有看到任何关于运行此构建或如何验证构建的说明。
我还尝试运行命令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$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!
引用日志内容如下:
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:m2repository
或extras;google:m2repository
。
【问题讨论】:
您是否在gluonfx:build
之后运行了mvn gluonfx:package
?该目标创建 Android 项目和 APK,然后您可以使用 gluonfx:install
将其安装到您的设备上。所有这些都记录在这里:docs.gluonhq.com/#platforms_android
谢谢!我将在今天晚些时候尝试 gluonfx:package。我想指出,我正在密切关注您链接的文档。引发异常的两个命令都在 gluonfx:build 之后立即给出,在“打包和分发”部分之前的“在设备上运行”标题下,没有提及在这些命令运行之前所需的任何步骤。通常我不喜欢在失败的步骤之前走得太远。
你是对的......所以我是,由于在包部分之前和之后重复的Run on device
部分,应该修复。反正没有包你就不能运行……
@JoséPereda 非常感谢您在这方面的帮助,并且正在继续打包步骤。同时,我能做些什么来开始修复文档中的这种歧义或重复吗?作为一般做法,我喜欢在进行过程中进行清理,或者至少努力确保清理过程已启动。
【参考方案1】:
@JoséPereda 在 cmets 中给出的答案在我看来就像我们可以发布来解决这个特定问题的东西。他写道,为了在设备上运行应用程序,必须首先对应用程序进行打包。
因此,如果我理解这一点并且尚未更正,那么https://docs.gluonhq.com/#platforms_android_development_run 部分中提到的步骤实际上应该在包装之后进行,这在https://docs.gluonhq.com/#platforms_android_distribution_build 部分中进行了讨论。
【讨论】:
以上是关于在 Android 设备上安装 gluonfx:install 命令失败,找不到文件的主要内容,如果未能解决你的问题,请参考以下文章