Weird asset not found exception after displaying ad

im trying to implement Interstitial Ads on my android game.

ive got it so it shows the ad just fine, but as soon as i close it. the entire game restarts (onCreate() in MainActivity gets called again and everything, and it shows the splash image). I’m guessing this is just how the android harness handles switching between activities.

however as it returns back to the application, i get an assetnotfound exception

[java]E/com.jme3.app.AndroidHarness(19255): SEVERE Exception thrown in Thread[GLThread 15868,5,main]
E/com.jme3.app.AndroidHarness(19255): com.jme3.asset.AssetNotFoundException: Interface/Fonts/Default.fnt
E/com.jme3.app.AndroidHarness(19255): at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:283)
E/com.jme3.app.AndroidHarness(19255): at com.jme3.asset.DesktopAssetManager.loadFont(DesktopAssetManager.java:370)
E/com.jme3.app.AndroidHarness(19255): at com.jme3.app.SimpleApplication.loadGuiFont(SimpleApplication.java:179)
E/com.jme3.app.AndroidHarness(19255): at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:187)
E/com.jme3.app.AndroidHarness(19255): at com.jme3.app.AndroidHarness.initialize(AndroidHarness.java:455)
E/com.jme3.app.AndroidHarness(19255): at com.jme3.system.android.OGLESContext.initInThread(OGLESContext.java:229)
E/com.jme3.app.AndroidHarness(19255): at com.jme3.system.android.OGLESContext.onSurfaceCreated(OGLESContext.java:205)
E/com.jme3.app.AndroidHarness(19255): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1510)
E/com.jme3.app.AndroidHarness(19255): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1249)[/java]

which goes back to the “loadGuiFont()” call in SimpleApplication (called during the application restart after showing the ad)

I’ve had this sort of issue before, and i fixed it by doing a clean and build, but this time it seems to be some other cause. since my game runs fine until i display the ad. Does anyone know what to do about this?

to anyone who finds themselves in this same situation, here is the solution:

You need to change MainActivity to extend Activity instead of AndroidHarness, you can use this code as a base for your changes:

the main differences between this and AndroidHarness is in onCreate(), onDestroy() where it keeps a reference to Application. I also put in loadAd() to show how to load an ad (you need google play services in your library, though if youre getting the problem im having im sure you already knew that).

Instead of keeping the reference in appStatic it should really be saved using a fragment, but this was the quickest solution i came up with.

I also removed the setRequestedOrientation() line, as that causes a different bug leading to a weird AssetNotFoundException. the default screen orientation should be specified in the manifest instead