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/ SEVERE Exception thrown in Thread[GLThread 15868,5,main]
E/ com.jme3.asset.AssetNotFoundException: Interface/Fonts/Default.fnt
E/ at com.jme3.asset.DesktopAssetManager.loadAsset(
E/ at com.jme3.asset.DesktopAssetManager.loadFont(
E/ at
E/ at
E/ at
E/ at
E/ at
E/ at android.opengl.GLSurfaceView$GLThread.guardedRun(
E/ at android.opengl.GLSurfaceView$[/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