Home Features Docs Blog Support GitHub

LibGDX & MOE 'application Did Finish Launching With Options'

Hello guys,

I used LibGDX 1.9.10 and MOE 1.7.4 to create my IOS app.
I use Xcode to and test it on my IOS device. Actually everything were fine - it work properly on
device .

But when i tried to install some Admob / Firebase SDK inside ‘applicationDidFinishLaunchingWithOptions’ -> problem up:

It said : ‘applicationDidFinishLaunchingWithOptions(UIApplication, NSDictionary<?, ?>)’ in ‘com.game.IOSMoeLauncher’ clashes with ‘applicationDidFinishLaunchingWithOptions(UIApplication, NSDictionary<String, ?>)’ in ‘apple.uikit.protocol.UIApplicationDelegate’; both methods have same erasure, yet neither overrides the other

Here my IOSMoeLauncer.java:

public class IOSMoeLauncher extends IOSApplication.Delegate {
protected IOSMoeLauncher(Pointer peer) {
    super(peer);
}
IOSApplication application;
MyGame game;
@Override
protected IOSApplication createApplication() {
    IOSApplicationConfiguration config = new IOSApplicationConfiguration();
    config.useAccelerometer = false;

    game = new MyGame();
    application =  new IOSApplication(game, config);

    return application;
}



public static void main(String[] argv) {
    UIKit.UIApplicationMain(0, null, null, IOSMoeLauncher.class.getName());
}

@Override
public void applicationDidBecomeActive(UIApplication application) {
    // Gdx.app.log("TEST", "applicationDidBecomeActive");
    super.applicationDidBecomeActive(application);
}

@Override
public boolean applicationDidFinishLaunchingWithOptions(UIApplication application, NSDictionary<?, ?> launchOptions) {
    // I want to install some sdk here
    return super.applicationDidFinishLaunchingWithOptions(application, launchOptions);
}

@Override
public void applicationDidFinishLaunching(UIApplication application) {
    //Gdx.app.log("TEST", "applicationDidFinishLaunching");
    super.applicationDidFinishLaunching(application);

}
}

Any solutions for this one?? I look forward and appreciate your help!!

Regards!!

The problem here is that the MOE version the libgdx backend was build for doesn’t match the MOE version you are using. The parameters of " applicationDidFinishLaunchingWithOptions" changed from NSDictionary<?, ?> to NSDictionary<String, ?> in this commit: https://github.com/multi-os-engine/moe-core/commit/9d3ddbf02cf21cf1e96f19501b2b3899d58a94be
So there are three options I think:

  1. Use an older MOE version.
  2. Don’t use IOSApplication.Delegate. A option how you could do it can be found here: https://github.com/multi-os-engine/moe-samples-java/blob/moe-svm/LibGDXMissileCommand/ios/src/main/java/org/moe/libgdxmissilecommand/ios/Main.java
  3. Build LibGDX from source with an updated MOE backend. (I have a repo for this but it is currently just for MOE 2.0. But it can be easily adjusted to MOE 1.x. Just some file deletion I think). With this you could also have LibGDX use Metal instead of the deprecated OpenGLES. If this would be the way you want to go I could give you further informations.
1 Like

Ohh hey @Berstanio!! Thank for your help :+1:

Actually I already fixed my code. I have checked and followed the instructions from this post:
https://discuss.multi-os-engine.org/t/launch-a-libgdx-game-using-moe-from-ios-storyboard/1005/12

  1. So I did change my IOSMoeLauncher.java
  2. Created a new AppViewCotroller
  3. Created a new Main.Storyboard and link the View

It took me a little time to reseach and adjust to the above changes :grinning: Now i can run my app on IOS Devices and I also added some SDK from GoogleAdmob and Firebase.

But due to my lack of experience with handling these above, so my app has new probs :joy: :joy:

  1. Config the View to make it Fullscreen on all IOS devices.
  2. Try to freeze my orientation. My app is landscape but after show an Interstitial or VideoReward -> It became Potrait?? Please check my demo images:

1
Right Orientation.

2
Orientation changed after see ads :))

I will try to fix these above and also try your methods. Hope that i wont have more probs !!

Thank you!!

Hi @Berstanio!! Hope you have a nice day :+1:

I fixed my app by following your suggestion :grinning:
https://github.com/multi-os-engine/moe-samples-java/blob/moe-svm/LibGDXMissileCommand/ios/src/main/java/org/moe/libgdxmissilecommand/ios/Main.java

So here what i changed:

  1. Changed everything inside the IOSMoeLancher . Instead of IOSApplication.Delegate -> I used UIApplicationDelegate.
  2. Create a new class MyIOSApplication extends IOSApplication.
  3. Remove the Main.storyboard & AppViewController . Now i created my app inside the applicationDidFinishLaunchingWithOptions .
  4. Use Metal instead of OpenGLES.
  5. My app have proguard , so i added this: -keep class apple.uikit.protocol.UIApplicationDelegate { *; } inside my proguard.

With the above changes, now i can run and test my app on my IOS devices.
Remove the storyboard and view -> so bye bye 2 probs in my last repiled :joy: :joy:
Now i need to add some Firebase Crashlystic and RemoteConfig to test and track my app before release it to the app store :laughing:

Once again, thank for your help!! It has saved me more time instead of having to research by myself.

Regards.

Ah thats great to hear!

About the 2. point. Here I forgot to mention something about the sample I gave you ( https://github.com/multi-os-engine/moe-samples-java/blob/moe-svm/LibGDXMissileCommand/ios/src/main/java/org/moe/libgdxmissilecommand/ios/Main.java ). The sample was updated to support MOE 2.0. In order to do that I needed to replace the old LibGDX MOE Logger with a updated one because the old Logger relied on some art libraries. So creating the MyIOSApplication class should be only needed for MOE 2.0, not for MOE 1.x which you are using. Therefor I think you could delete this class and use the standard “IOSApplication”.

Just curios about the 4. point. How did you switched to Metal? Have you found my repository?

Okay thanks for your info!

  • I had fix my app. So i deleted MyIOSApplication class.
  • Yeah when i used Xcode to build a demo on my IOS device. It said OpenGLES was deprecated , and use Metal instead. So I just followed that.

About the second point: The switching from OpenGLES to Metal needs to be done in LibGDX. Have a look here: https://github.com/libgdx/libgdx/blob/af899350378fc0908eb26867b8cc44fd3cfdce7c/gdx/jni/iosgl/iosgl20.cpp#L6-L7 This is the file that creates the OpenGL calls for LibGDX and as you see it imports the OpenGLES header. And switching from OpenGLES to Metal is sadly not easy for LibGDX.
But there is a project called “MetalANGLE” which creates from OpenGL calls Metal calls. I implemented this in a fork of LibGDX and if you want to test/use this, this would be the steps:

  1. change the libGDX Version to 1.10.1-SNAPSHOT
  2. add this maven repository with “maven { url ‘https://s01.oss.sonatype.org/content/repositories/snapshots/’ }”
  3. Change the artifacts:
    “com.badlogicgames.gdx:gdx-backend-moe:$gdxVersion”
    “com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios”
    to
    “io.github.berstanio:gdx-backend-moe-art-metalangle:$gdxVersion”
    “io.github.berstanio:gdx-platform:$gdxVersion:natives-ios-metalangle”
  4. Replace this line
if (jar.name.endsWith("natives-ios.jar")) outputDir = file("xcode/native/ios")

with this line

if (jar.name.matches(".*natives-ios.*")) outputDir = file("xcode/native/ios")
  1. Add Metal AND OpenGLES(don’t know really why but is still needed for some EAGL stuff.) in XCode to the Frameworks

Then everything should work the same as before, just faster! But keep in mind that this isn’t as well tested as the standard libGDX OpenGL implementation.

P.S: If you are working with the MOE Version 1.9.0-SNAPSHOT this wont work out of the box. You would need to add “-lc++” as a custom linker flag. But since you are using MOE 1.7.4 this shouldn’t be a problem for you. Later this will be probably again the default behavior(https://github.com/multi-os-engine/multi-os-engine/issues/143).