Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on execution from generate jar with gdx-backend-lwjgl3 and gdx-tools dependencies #4777

Closed
1 of 7 tasks
DanielChesters opened this issue Jun 11, 2017 · 5 comments
Closed
1 of 7 tasks

Comments

@DanielChesters
Copy link

DanielChesters commented Jun 11, 2017

Issue details

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.

Reproduction steps/code

  1. Create a new gdx project with setup app for desktop only
  2. Migrate to gdx-backend-lwjgl3
  3. Add gdx-tools dependency in desktop module
  4. Do a ./gradlew clean dist
  5. Do a java -jar desktop/build/libs/desktop-1.0.jar

Version of LibGDX and/or relevant dependencies

1.9.6 with gdx-backend-lwjgl3 and gdx-tools dependencies

Stacktrace

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)

Please select the affected platforms

  • Android
  • iOS (robovm)
  • iOS (MOE)
  • HTML/GWT
  • Windows
  • Linux
  • MacOS
@Tom-Ski
Copy link
Member

Tom-Ski commented Jun 11, 2017

You can't include gdx-tools with lwjgl3 backend on dist, these are not compatible. see #3726

@Tom-Ski Tom-Ski closed this as completed Jun 11, 2017
@mgsx-dev
Copy link
Contributor

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.

@tedigc
Copy link

tedigc commented Mar 24, 2019

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'
}

@ghost
Copy link

ghost commented May 8, 2021

I added it the following way, but still get the same error after gradlew clean dist and executing the jar.

project(":desktop") {
    apply plugin: "java-library"


    dependencies {
        implementation project(":core")
        api "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
        api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
        api "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
        api "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop"
        api "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
        api "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
        api "com.badlogicgames.gdx-controllers:gdx-controllers-desktop:$gdxControllersVersion"
        compile ("com.badlogicgames.gdx:gdx-tools:$gdxVersion") {
            exclude group: 'com.badlogicgames.gdx', module: 'gdx-backend-lwjgl'
        }
    }

}```

@tommyettinger
Copy link
Member

@Amityville-DE There, you still depend on gdx-tools without the exclusion. You need to use:

project(":desktop") {
    apply plugin: "java-library"

    dependencies {
        implementation project(":core")
        api "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
        api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
        api "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
        api "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop"
        api "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
        // there was a problem line here.
        api "com.badlogicgames.gdx-controllers:gdx-controllers-desktop:$gdxControllersVersion"
        api ("com.badlogicgames.gdx:gdx-tools:$gdxVersion") {
            exclude group: 'com.badlogicgames.gdx', module: 'gdx-backend-lwjgl'
        }
    }
}

Note that excluding LWJGL means not all of gdx-tools will be runnable. It can only use the parts of libGDX that don't rely on any platform implementation, and because parts of gdx-tools use AWT or Swing, those must be used on a desktop JVM (not a headless one). I don't think gdx-tools was ever intended for use at runtime, because it isn't built to run on Android or other non-desktop platforms. It of course can still be used at runtime, just limited to desktop JVMs and such.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants