使用 gluon 移动插件的 JavaFX android 应用构建失败
Build failure for JavaFX android app using the gluon mobile plugin
我刚刚用 FXML 启动了一个新的 gluon 移动多视图项目,并在更改任何内容之前尝试 运行 它(除了从 1.2.0 更新 build.gradle 文件中的 jfxmobile-plugin 版本到 1.3.2)。它在桌面上运行良好,但是当我尝试 运行 android 安装 gradle 任务时(连接了我的 android phone)它失败了。它给了我以下错误:
:mergeClassesIntoJar
:shrinkMultiDexComponents
:createMainDexList
:writeInputListFile
[ant:java] Java Result: 1
:dex FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':dex'.
> org.gradle.api.GradleException (no error message)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
我的build.gradle文件:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.3.2'
}
}
apply plugin: 'org.javafxports.jfxmobile'
repositories {
jcenter()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
mainClassName = 'com.gluonapplication.GluonApplication'
dependencies {
compile 'com.gluonhq:charm:4.2.0'
}
jfxmobile {
downConfig {
version = '3.1.0'
// Do not edit the line below. Use Gluon Mobile Settings in your project context menu instead
plugins 'display', 'lifecycle', 'statusbar', 'storage'
}
android {
manifest = 'src/android/AndroidManifest.xml'
}
}
操作系统:Windows10.
如果需要任何其他信息来确定问题的原因,请告诉我。谢谢。
gradlew --info android 日志:
根据您的日志,我注意到您在 64 位 OS 上使用 32 位 JDK:
Starting process 'command 'C:\Program Files (x86)\Java\jdk1.8.0_101\bin\java.exe''. Working directory: D:\Android_Projects\GluonMobile-MultiViewProjectwithFXML Command: C:\Program Files (x86)\Java\jdk1.8.0_101\bin\java.exe ...
默认情况下,jfxmobile 插件 sets 2 GB 用于 Android 上的 JVM Xmx 选项,并考虑到无法分配的 32 位 OS ,解决方案是设置一个较低的值。
基于这段line的代码,您可以设置:
android {
dexOptions {
javaMaxHeapSize '1g'
}
}
或者可能多一点(1.5g 左右?)。
请注意,如果您使用 64 位JDK,这将得到解决。确保相应地更新 JAVA_HOME 环境变量,因为您不需要减少进程的内存。
我刚刚用 FXML 启动了一个新的 gluon 移动多视图项目,并在更改任何内容之前尝试 运行 它(除了从 1.2.0 更新 build.gradle 文件中的 jfxmobile-plugin 版本到 1.3.2)。它在桌面上运行良好,但是当我尝试 运行 android 安装 gradle 任务时(连接了我的 android phone)它失败了。它给了我以下错误:
:mergeClassesIntoJar
:shrinkMultiDexComponents
:createMainDexList
:writeInputListFile
[ant:java] Java Result: 1
:dex FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':dex'.
> org.gradle.api.GradleException (no error message)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
我的build.gradle文件:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.3.2'
}
}
apply plugin: 'org.javafxports.jfxmobile'
repositories {
jcenter()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
mainClassName = 'com.gluonapplication.GluonApplication'
dependencies {
compile 'com.gluonhq:charm:4.2.0'
}
jfxmobile {
downConfig {
version = '3.1.0'
// Do not edit the line below. Use Gluon Mobile Settings in your project context menu instead
plugins 'display', 'lifecycle', 'statusbar', 'storage'
}
android {
manifest = 'src/android/AndroidManifest.xml'
}
}
操作系统:Windows10.
如果需要任何其他信息来确定问题的原因,请告诉我。谢谢。
gradlew --info android 日志:
根据您的日志,我注意到您在 64 位 OS 上使用 32 位 JDK:
Starting process 'command 'C:\Program Files (x86)\Java\jdk1.8.0_101\bin\java.exe''. Working directory: D:\Android_Projects\GluonMobile-MultiViewProjectwithFXML Command: C:\Program Files (x86)\Java\jdk1.8.0_101\bin\java.exe ...
默认情况下,jfxmobile 插件 sets 2 GB 用于 Android 上的 JVM Xmx 选项,并考虑到无法分配的 32 位 OS ,解决方案是设置一个较低的值。
基于这段line的代码,您可以设置:
android {
dexOptions {
javaMaxHeapSize '1g'
}
}
或者可能多一点(1.5g 左右?)。
请注意,如果您使用 64 位JDK,这将得到解决。确保相应地更新 JAVA_HOME 环境变量,因为您不需要减少进程的内存。