When I generate a jar from a gdx projet with gdx-backend-lwjgl3 and gdx-tools dependencies and I try to run this jar, I have a error. The gdx application run perfectly with same configuration when I use Gradle to run this.
./gradlew clean dist
java -jar desktop/build/libs/desktop-1.0.jar
1.9.6 with gdx-backend-lwjgl3 and gdx-tools dependencies
Exception in thread "main" java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
org/lwjgl/system/Callback.<clinit>()V @136: invokestatic
Reason:
Type 'org/lwjgl/PointerBuffer' (current frame, stack[1]) is not assignable to 'org/lwjgl/system/CustomBuffer'
Current Frame:
bci: @136
flags: { }
locals: { 'org/lwjgl/system/MemoryStack', null, '[Ljava/lang/Class;', '[Ljava/lang/reflect/Method;', 'org/lwjgl/PointerBuffer' }
stack: { '[Ljava/lang/reflect/Method;', 'org/lwjgl/PointerBuffer' }
Bytecode:
0x0000000: b800 364b 014c 04bd 0037 5903 b200 3853
0x0000010: 4d10 09bd 0039 5903 123a 123b 2cb6 003c
0x0000020: 5359 0412 3d12 3b2c b600 3c53 5905 123e
0x0000030: 123b 2cb6 003c 5359 0612 3f12 3b2c b600
0x0000040: 3c53 5907 1240 123b 2cb6 003c 5359 0812
0x0000050: 4112 3b2c b600 3c53 5910 0612 4212 3b2c
0x0000060: b600 3c53 5910 0712 4312 3b2c b600 3c53
0x0000070: 5910 0812 4412 3b2c b600 3c53 4e2a 2dbe
0x0000080: b600 453a 042d 1904 b800 46b8 0047 5819
0x0000090: 04b6 0048 b300 1e19 04b6 0048 b300 1f19
0x00000a0: 04b6 0048 b300 2019 04b6 0048 b300 2119
0x00000b0: 04b6 0048 b300 2219 04b6 0048 b300 2319
0x00000c0: 04b6 0048 b300 2519 04b6 0048 b300 2619
0x00000d0: 04b6 0048 b300 242a c600 462b c600 132a
0x00000e0: b600 49a7 003b 4d2b 2cb6 004b a700 322a
0x00000f0: b600 49a7 002b 4d2c 4c2c bf3a 052a c600
0x0000100: 1d2b c600 152a b600 49a7 0012 3a06 2b19
0x0000110: 06b6 004b a700 072a b600 4919 05bf a700
0x0000120: 0f4b bb00 1459 124d 2ab7 004e bfb8 004f
0x0000130: 57b1
Exception Handler Table:
bci [223, 227] => handler: 230
bci [6, 215] => handler: 246
bci [6, 215] => handler: 251
bci [261, 265] => handler: 268
bci [246, 253] => handler: 251
bci [0, 286] => handler: 289
Stackmap Table:
full_frame(@230,{Object[#149],Object[#150]},{Object[#150]})
same_frame(@239)
same_locals_1_stack_item_frame(@246,Object[#150])
same_locals_1_stack_item_frame(@251,Object[#150])
full_frame(@268,{Object[#149],Object[#150],Top,Top,Top,Object[#150]},{Object[#150]})
same_frame(@279)
same_frame(@283)
full_frame(@286,{},{})
same_locals_1_stack_item_frame(@289,Object[#151])
same_frame(@301)
at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.initializeGlfw(Lwjgl3Application.java:78)
at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.<init>(Lwjgl3Application.java:87)
at com.mygdx.lwjgl3.desktop.DesktopLauncher.main(DesktopLauncher.java:10)
You can't include gdx-tools with lwjgl3 backend on dist, these are not compatible. see https://github.com/libgdx/libgdx/issues/3726
Indeed, gdx-tools project have both core, editor and test code. Editor and test code are based on Lwjgl backend. If you only need some Lwjgl agnostic classes (for instance texture packer), you can exclude Lwjgl from gdx-tools dependency in your gradle build, something like that (not tested) :
compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion" {
exclude "com.badlogicgames.gdx:gdx-backend-lwjgl"
}
see https://docs.gradle.org/3.3/userguide/dependency_management.html#sub:exclude_transitive_dependencies
This is just a workaround, IMO gdx-tools should be split in some way.
Hope it's help.
This comment was a godsend. For those finding this, the syntax is a little off. Try adding the following to your :desktop
dependencies in the root-level build.gradle
file:
compile ("com.badlogicgames.gdx:gdx-tools:$gdxVersion") {
exclude group: 'com.badlogicgames.gdx', module: 'gdx-backend-lwjgl'
}
Most helpful comment
This comment was a godsend. For those finding this, the syntax is a little off. Try adding the following to your
:desktop
dependencies in the root-levelbuild.gradle
file: