自从在 NetBeans 12.6 上升级到 codenameone-maven-plugin:7.0.150 以来,我一直无法构建 codenameone Android Gradle 项目。 收到以下错误消息:
Generating android gradle Project to /Users/mike/IT/NetBeansProjects/myapp/android/target/myapp-android-1.0-SNAPSHOT-android-source...
Starting android project builder...
Failed to build Android project with error: When using gradle 8, you must set the JAVA17_HOME environment variable to the location of a Java 17 JDK
com.codename1.builders.BuildException: When using gradle 8, you must set the JAVA17_HOME environment variable to the location of a Java 17 JDK
at com.codename1.builders.AndroidGradleBuilder.getGradleJavaHome (AndroidGradleBuilder.java:440)
at com.codename1.builders.AndroidGradleBuilder.build (AndroidGradleBuilder.java:489)
at com.codename1.maven.CN1BuildMojo.doAndroidLocalBuild (CN1BuildMojo.java:847)
at com.codename1.maven.CN1BuildMojo.createAntProject (CN1BuildMojo.java:562)
at com.codename1.maven.CN1BuildMojo.executeImpl (CN1BuildMojo.java:116)
at com.codename1.maven.AbstractCN1Mojo.execute (AbstractCN1Mojo.java:195)
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 jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
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)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.apache.maven.wrapper.BootstrapMainStarter.start (BootstrapMainStarter.java:39)
at org.apache.maven.wrapper.WrapperExecutor.execute (WrapperExecutor.java:122)
at org.apache.maven.wrapper.MavenWrapperMain.main (MavenWrapperMain.java:61)
有什么建议吗? 谢谢
当使用最新的 Codename One 版本(例如 7.0.142)生成 Android gradle 项目时,我在 Linux 上遇到了类似的问题,默认情况下需要 gradle 8。 为了解决这个问题我
• 安装了 Java-17
• 使用
geddit
编辑 etc/environment
文件
• 将 Java-17 安装
PATH
和 JAVA17_HOME
变量添加到 etc/environment
PATH="/usr/local/sbin:/usr/lib/jvm/java-17-open-jdk-amd64/bin"
JAVA17_HOME="/usr/lib/jvm/java-17-open-jdk-amd64/"
注意附加多个路径的
:
• 保存并重新启动电脑以将更改应用到环境。
在不重新启动 PC 的情况下,项目生成仍然失败,因为尚未应用对环境的新更改。
您可以在 Mac 中尝试以下步骤来设置环境