简体   繁体   中英

Setting up LibGDX on RoboVM without Gradle (getting black screen only)

I have a working cross-platform app that always ran fine under RoboVM. I started moving the graphics backend of the app over to LibGDX. Everything runs fine under LWJGL but I can't get LibGDX to work on RoboVM.

I really don't feel like installing and learning yet another build-tool or dependency management thing, so I would like to get this working without having to use Gradle.

Here's what I did so far:

  • Downloaded the latest LibGDX release (1.6.1) from the releases directory .
  • Unpacked the zip-file into some directory on my computer (not in my Eclipse project).
  • Created a new user library in Eclipse containing these external jars from the folder:
    gdx.jar , gdx-backend-robovm.jar , and gdx-natives.jar
  • Added the user library to my project.
  • Created a folder called libs in the root of my RoboVM project.
  • Copied the iOS folder from the libgdx folder into libs containing the following files:
    libgdx.a and libObjectAL.a
  • Added a <libs> , a <frameworks> , and a <forceLinkClasses> section to my project's robovm.xml, which now looks like this:

     <config> <executableName>${app.executable}</executableName> <mainClass>${app.mainclass}</mainClass> <os>ios</os> <arch>thumbv7</arch> <resources> <resource> <directory>resources</directory> <skipPngCrush>true</skipPngCrush> </resource> </resources> <libs> <lib>libs/ios/libgdx.a</lib> <lib>libs/ios/libObjectAL.a</lib> </libs> <frameworks> <framework>UIKit</framework> <framework>OpenGLES</framework> <framework>QuartzCore</framework> <framework>CoreGraphics</framework> <framework>OpenAL</framework> <framework>AudioToolbox</framework> <framework>AVFoundation</framework> </frameworks> <forceLinkClasses> <pattern>com.badlogix.gdx.scenes.scene2d.ui.*</pattern> </forceLinkClasses> <target>ios</target> <iosInfoPList>Info.plist.xml</iosInfoPList> </config> 
  • Added the following code to my main method:

     IOSApplicationConfiguration cfg = new IOSApplicationConfiguration(); cfg.orientationLandscape = true; cfg.orientationPortrait = true; new IOSApplication(getApplicationListener(), cfg); System.out.println("Should be ready..."); 

where getApplicationListener() returns the same object as in my LWGJL app.
The create() method in this object begins with System.out.println("Hello?"); .

When I run the app, it launches (launch image and all) and starts playing some sound effects (not using LibGDX!) but just displays a black screen. It prints "Should be ready..." but it does not print "Hello?". So, the ApplicationListener gets created fine and the IOSApplication gets created fine, but the listener's create() method is never called. As always, there are no helpful (or any for that matter) error messages...

Am I missing something???

I am pretty certain that the .a files got included in the build, because as soon as I added the <libs> section to robovm.xml, I got flooded with build errors that went away as soon as I also added the <frameworks> section. Is there some other export setting that I need to worry about? Is there a way to at least get some sort of error or log message?

UPDATE :

If I run it in the simulator, I also get a black screen. But if I click on the black screen, I get the following error message:

unexpected nil window in _UIApplicationHandleEventFromQueueEvent, _windowServerHitTestWindow: <UIClassicWindow: 0x7fafa27175b0; frame = (0 0; 375 667); userInteractionEnabled = NO; gestureRecognizers = <NSArray: 0x7fafa2514d70>; layer = <UIWindowLayer: 0x7fafa2718060>>

I imported the LibGDX test projects into my Eclipse/RoboVM setup and those work fine...

SO stupid:

The main class must extend IOSApplication.Delegate instead of UIApplicationDelegateAdapter .

6 hours wasted... And this is why I hate using external libraries rather than coding as close to the metal as possible (hence my earlier question ): To the person who writes the library, such a trivial thing will immediately become self-understood, automated, and forgotten. Therefore: No documentation, no useful error messages, no other checks and balances. Do a search for "libgdx IOSApplication.Delegate" and see if you can find a page that says that this is what one needs to do. The only place it shows up is in some of the example codes where your attention immediately jumps to the content of the methods rather than the boilerplate that out of the corner of your eye looks the same as always anyways... But I'll stop here... Only the second sentence is really relevant to this answer anyways...

But, hey, we finally have a detailed description of how to add LibGDX to an existing project in RoboVM without using Gradle...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM