LIBGDX、MacOS M1、Lwjgl3,- 创建 .jar 文件时出现问题
新项目。 我正在尝试创建一个工作 .jar 文件 - 它不起作用,它会引发错误。
苹果系统M1 Java 11 Zulu ARM 64
导出 JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home/ 导出 PATH=$JAVA_HOME/bin:$PATH
或
导出 JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-11.0.12.jdk/Contents/Home/ 导出 PATH=$JAVA_HOME/bin:$PATH
Android Gradle 插件 Vesrion - 4.2.2 Gradle 版本 - 6.9
如果版本增加,则会给出重复的 META-INF 错误:
nexus@MacBook-Pro-Igor imperialist % ./gradlew desktop:dist
> Task :desktop:dist FAILED
FAILURE: Build failed with an exception.
*What went wrong:
Execution failed for task ':desktop:dist'.
> Entry META-INF/INDEX.LIST is a duplicate but no duplicate handling strategy has been set. Please refer to https://docs.gradle.org/7.2/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy for details.
* try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 6s
5 actionable tasks: 5 executed
nexus@MacBook-Pro-Igor imperialist %
运行命令: ./gradlew 构建 ./gradlew Desktop:dist
结果:构建成功
运行命令:java -jar -XstartOnFirstThreaddesktop-1.0.jar
结果:
nexus@MacBook-Pro-Igor libs % java -jar -XstartOnFirstThread desktop-1.0.jar
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.lwjgl.system.Pointer$Default.<clinit>(Pointer.java:67)
at org.lwjgl.system.Callback.<clinit>(Callback.java:40)
at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.initializeGlfw(Lwjgl3Application.java:84)
at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.<init>(Lwjgl3Application.java:138)
at com.nexlab.a3.desktop.DesktopLauncher.main(DesktopLauncher.java:11)
Caused by: java.lang.UnsupportedOperationException: java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
org/lwjgl/system/jni/JNINativeInterface.GetJavaVM(Lorg/lwjgl/PointerBuffer;)I @8: invokestatic
Reason:
Type 'org/lwjgl/PointerBuffer' (current frame, stack[0]) is not assignable to 'org/lwjgl/system/CustomBuffer'
Current Frame:
bci: @8
flags: { }
locals: { 'org/lwjgl/PointerBuffer' }
stack: { 'org/lwjgl/PointerBuffer', integer }
Bytecode:
0000000: b200 0499 0008 2a04 b800 432a b800 44b8
0000010: 0045 ac
Stackmap Table:
same_frame(@11)
at org.lwjgl.system.MemoryUtil.<clinit>(MemoryUtil.java:130)
... 5 more
Caused by: java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
org/lwjgl/system/jni/JNINativeInterface.GetJavaVM(Lorg/lwjgl/PointerBuffer;)I @8: invokestatic
Reason:
Type 'org/lwjgl/PointerBuffer' (current frame, stack[0]) is not assignable to 'org/lwjgl/system/CustomBuffer'
Current Frame:
bci: @8
flags: { }
locals: { 'org/lwjgl/PointerBuffer' }
stack: { 'org/lwjgl/PointerBuffer', integer }
Bytecode:
0000000: b200 0499 0008 2a04 b800 432a b800 44b8
0000010: 0045 ac
Stackmap Table:
same_frame(@11)
at org.lwjgl.system.MemoryUtil.getMarkOffset(MemoryUtil.java:3013)
at org.lwjgl.system.MemoryUtil.<clinit>(MemoryUtil.java:115)
... 5 more
nexus@MacBook-Pro-Igor libs %
其他更改的设置:
Main gradle set lwjgl3 - api "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion “
Gradle 桌面 - sourceCompatibility = 1.8
AndroidManifest.xml - 活动 - android:exported="true"
DesktopLauncher.java:IDE
package com.nexlab.a3.desktop;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import com.nexlab.a3.A3;
public class DesktopLauncher {
public static void main (String[] arg) {
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
new Lwjgl3Application(new A3(), config);
}
}
中的“开始”按钮正常启动(这里我还指定了参数--XstartOnFirstThread)
New project.
I'm trying to create a working .jar file - it doesn't work, it throws an error.
MacOS M1
Java 11 Zulu ARM 64
export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home/
export PATH=$JAVA_HOME/bin:$PATH
or
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-11.0.12.jdk/Contents/Home/
export PATH=$JAVA_HOME/bin:$PATH
Android Gradle Plugin Vesrion - 4.2.2
Gradle Version - 6.9
If the version is increased, it gives a duplicate META-INF error:
nexus@MacBook-Pro-Igor imperialist % ./gradlew desktop:dist
> Task :desktop:dist FAILED
FAILURE: Build failed with an exception.
*What went wrong:
Execution failed for task ':desktop:dist'.
> Entry META-INF/INDEX.LIST is a duplicate but no duplicate handling strategy has been set. Please refer to https://docs.gradle.org/7.2/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy for details.
* try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 6s
5 actionable tasks: 5 executed
nexus@MacBook-Pro-Igor imperialist %
Run commands:
./gradlew build
./gradlew desktop:dist
Result: BUILD SUCCESSFUL
Run command: java -jar -XstartOnFirstThread desktop-1.0.jar
Result:
nexus@MacBook-Pro-Igor libs % java -jar -XstartOnFirstThread desktop-1.0.jar
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.lwjgl.system.Pointer$Default.<clinit>(Pointer.java:67)
at org.lwjgl.system.Callback.<clinit>(Callback.java:40)
at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.initializeGlfw(Lwjgl3Application.java:84)
at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.<init>(Lwjgl3Application.java:138)
at com.nexlab.a3.desktop.DesktopLauncher.main(DesktopLauncher.java:11)
Caused by: java.lang.UnsupportedOperationException: java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
org/lwjgl/system/jni/JNINativeInterface.GetJavaVM(Lorg/lwjgl/PointerBuffer;)I @8: invokestatic
Reason:
Type 'org/lwjgl/PointerBuffer' (current frame, stack[0]) is not assignable to 'org/lwjgl/system/CustomBuffer'
Current Frame:
bci: @8
flags: { }
locals: { 'org/lwjgl/PointerBuffer' }
stack: { 'org/lwjgl/PointerBuffer', integer }
Bytecode:
0000000: b200 0499 0008 2a04 b800 432a b800 44b8
0000010: 0045 ac
Stackmap Table:
same_frame(@11)
at org.lwjgl.system.MemoryUtil.<clinit>(MemoryUtil.java:130)
... 5 more
Caused by: java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
org/lwjgl/system/jni/JNINativeInterface.GetJavaVM(Lorg/lwjgl/PointerBuffer;)I @8: invokestatic
Reason:
Type 'org/lwjgl/PointerBuffer' (current frame, stack[0]) is not assignable to 'org/lwjgl/system/CustomBuffer'
Current Frame:
bci: @8
flags: { }
locals: { 'org/lwjgl/PointerBuffer' }
stack: { 'org/lwjgl/PointerBuffer', integer }
Bytecode:
0000000: b200 0499 0008 2a04 b800 432a b800 44b8
0000010: 0045 ac
Stackmap Table:
same_frame(@11)
at org.lwjgl.system.MemoryUtil.getMarkOffset(MemoryUtil.java:3013)
at org.lwjgl.system.MemoryUtil.<clinit>(MemoryUtil.java:115)
... 5 more
nexus@MacBook-Pro-Igor libs %
Other changed settings:
Main gradle set lwjgl3 - api "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
Gradle desktop - sourceCompatibility = 1.8
AndroidManifest.xml - activity - android:exported="true"
DesktopLauncher.java:
package com.nexlab.a3.desktop;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import com.nexlab.a3.A3;
public class DesktopLauncher {
public static void main (String[] arg) {
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
new Lwjgl3Application(new A3(), config);
}
}
The "Start" button in the IDE starts normally (there I also specify the parameter - -XstartOnFirstThread)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论