Font error AssetNotFoundException when using admob interstitial

Hi,
I am configurating the admob to show an interstitial.
It popups in the screen normally, but when the user close it and the jm3 app gets back the control, it fires this unknow error Default.fnt not found and crash the app … :

W/dalvikvm(21523): threadid=36: thread exiting with uncaught exception (group=0x41745e48)
E/com.jme3.app.AndroidHarness(21523): SEVERE Exception thrown in Thread[GLThread 88713,5,main]
E/com.jme3.app.AndroidHarness(21523): com.jme3.asset.AssetNotFoundException: Interface/Fonts/Default.fnt
E/com.jme3.app.AndroidHarness(21523): 	at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:283)
E/com.jme3.app.AndroidHarness(21523): 	at com.jme3.asset.DesktopAssetManager.loadFont(DesktopAssetManager.java:370)
E/com.jme3.app.AndroidHarness(21523): 	at com.jme3.app.SimpleApplication.loadGuiFont(SimpleApplication.java:179)
E/com.jme3.app.AndroidHarness(21523): 	at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:187)
E/com.jme3.app.AndroidHarness(21523): 	at com.jme3.app.AndroidHarness.initialize(AndroidHarness.java:455)
E/com.jme3.app.AndroidHarness(21523): 	at com.jme3.system.android.OGLESContext.initInThread(OGLESContext.java:229)
E/com.jme3.app.AndroidHarness(21523): 	at com.jme3.system.android.OGLESContext.onSurfaceCreated(OGLESContext.java:205)
E/com.jme3.app.AndroidHarness(21523): 	at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1501)
E/com.jme3.app.AndroidHarness(21523): 	at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
E/com.jme3.app.AndroidHarness(21523): 

I saw a few threads here with the same error that may be related but with no fix for it.
Do anyone know how to fix it ?

That is strange. Are you closing the app before showing the ad? that error usually happens when we close the android app and it goes to the background and then reopens

No, I am just closing the interstitial…
But I think its the same problem, I mean, it runs in another thread right, it pauses the jm3 thread runs the interstatial and when it backs it resumes the jm3 thread…

When the interstitial closes, do you use the event it triggers?

I would use the onClose event to invoke a call on the game and continue and so far didn’t have any issues.

And can you tell me which Android device and OS version are you using to test this?

I am not triggering anything, should I ?
My android is 3.2 ( minimun for this interstatial ), the device am testing it is an old LG-D170.

I tried to add the ondestroy tips on here that fixed the error :

Now I am not getting this error anymore, but weird things are happening depending on when I call the intestatial :

  1. If I call the interstatial before I attach an new appstate, it dont show the interstatial.
  2. If I call the interstatial after I attach an new appstate, it “restarts” all the application and goes back to the main menu…

I think its not pausing correctly, you may be right, I should be calling some method to resume the main thread, how did you do that ?

I’ve definitely seen this error before. This has to do with the application not closing properly and trying to reopen.

Personally I’ve never been able to properly get interstitials working but it does have something to do with the activity trying to reopen after not properly closing.

I use interfaces to communicate the Android code to the Game code, makes things easier when I move from one platform to the next.

To tell the game that the add has ended you have two choices: use the onResume method or have a listener that Admob has. Then from the android code tell the game via interface that the add is gone.

How do you detect the add is closed ?

I have this methods :

@Override public void onAdLoaded()
@Override public void onAdFailedToLoad(int errorCode)
@Override public void onAdClosed()

The last one I am loading the add… Should I resume the main app on the onAdClosed() ?

Code :

public void initAdmob() { 
    this.runOnUiThread(new Runnable() { 
        public void run() { initAdMobInterstitialsAds(); } }); 
}
protected void initAdMobInterstitialsAds() {
    
    showAlert("Start admob interstitial initialization");
    interstitialAd = new InterstitialAd(this);
    interstitialAd.setAdUnitId(ADMOB_INTERSTITIALS_ID);
    
    interstitialAd.setAdListener(new AdListener() { // Set the AdListener.
        @Override public void onAdLoaded() { 
            showAlert("Admob Interstitial loaded"); 
        }
        
        @Override public void onAdFailedToLoad(int errorCode) { 
            String message = String.format("onAdFailedToLoad (%s)", 
                    getInterstitialsAdErrorReason(errorCode)); 
            showAlert(message); 
        }

        @Override public void onAdClosed() {
            if (interstitialAd != null) {
                showAlert("Load the next admob ad");
                AdRequest adRequest = new AdRequest.Builder().addTestDevice("YOUR_DEVICE_HASH").build();
                interstitialAd.loadAd(adRequest); }
        }

    });
    AdRequest adRequest = new AdRequest.Builder().build();
    interstitialAd.loadAd(adRequest);
}

This is my interface, I guess I need to add some resumeFromAdmobIntertitial() suff ??

package mygame;

public interface AndroidInterface {
    
    //Initialize Admob
    public void initAdmob();

    // Show the full screen Intertitial
    public void showAdmobIntertitial();

}

Also, what did you do to pause the jm3 ? appstate.setenable( false ) ?

Use onAdClosed when teh ad closes.

You can disable/enable app states but I prefer to have a flag that I can control better.

Your AndroidInterface is for the game to talk to Android code. Create another interface like GameInterface so that the android code can talk to your game. your Android interface would look like this

public interface AndroidInterface {
    
    //Initialize Admob
    public void initAdmob();

    // Show the full screen Intertitial
    public void showAdmobIntertitial();

    // Sets the GameInterface for android to talk to
    public void setGameInterface(GameInterface gameInterface);
}

your GameInterface will look like this

public interface GameInterface{
    public void onPause(boolean pause);

   //any other code you want to talk from android to game
}

I dont know, I did some tests, implement this call back to pause the app, same results.
It seens I am getting the issue of android getting not shutdown completely, but if I add the ondestroy solution, the interstatial is destroyed before it shows up for some reason…
Did you have to use this ondestroy clenup in your app ?

Hmmm, I did not get the same errors on my devices but they are Android 4.x and 5.x.

Another chance you should try are adbuddiz, they interstitial are less intrusive and work more like an overlay

I had a look on this, it looks much better, even the pay is better.
I tried to test it, but it didnt shows any screen…
Did you use it already ? If so, did you call it that way or using thread ?

Code:

public void initAdBuddiz() {
    AdBuddiz.setPublisherKey("code");
    AdBuddiz.cacheAds(this); // this = current Activity
    AdBuddiz.setTestModeActive();
    AdBuddiz.setLogLevel(AdBuddizLogLevel.Info);    // or Error, Silent
}

public void showAdBuddizIntertitial() {
    if (AdBuddiz.isReadyToShowAd(this)) AdBuddiz.showAd(this);
}

Nevermind , its working now !
I will stick with Adbuddiz for now, at least for interstitial.
Thanks again friend !

Are you sure the pay is better?

I tried AdBuddiz for a period of time. Essentially the staff misleads you into believing that you will be making more money.

I loved the fact that their institials were so easy to do. But the earnings were vastly lower.

Despite what their staff told me would happen.

There platform seems to pays per installation, in there site they says something between $1 to $3 per installation, not bad, but I dont know how much true its in it, did you get this results when you use it ?
But I dont know, I will use it until we fix this error on admob x jm3, since admob pays per impressions, I guess it pays more, but it depends of the game, I guess …

The admob support is terrible as well, just google discussions groups it seems, very bad for such type of business, I saw in the site a lot of peaple complain about crash, so we need to care about the software quality as well, if an player install your game and get crashed in an advertisement screen, its very bad for your game …

The problem I am having with admob is that it seens something is not beeing clean up somewhere when it closes, I dont know if the problem is on Jm3 or on admob, but I found out that the architecture of it is too much complicated in compassion with AdBuddiz for example.

I dont have any experience with this yet, I am just starting, so maybe others can help more.

Exactly the same they told me.

What they mean is they pay per installation your ads generate. Also Admob pays per click on the ad regardless of whether the application advertised is downloaded, not based on impressions at all.

AdBuddiz will only pay if they click on the advertisement and download the game.

In my experience this is much lower than AdMob as you can go days without getting a single download but multiple clicks.

Admob on average pays about 5 cents per click so unless you generate a download once every 20-60 ad clicks then it is a losing deal.

I would also bet that it’s on the lower end of 1-3$ and you would have to get a download at least every 20 clicks.

Even further with interstitials you are limit the amount of impressions you generate as well. A banner can show a new ad by being refreshed every 45 seconds and constantly remains visible.

Interstitials can only appear at breaks in your logic.

AdBuddiz will only pay if they click on the advertisement and download the game.

Thats too bad, they dont say this to you, scammers ! I will check this out with they and post here.

There are people talking about an new tecnology of videos ads of vungle company that pays very well, I guess the integration will need some kind of caching and threads, but it seens to be something to look at.

I am noticing this error as well when you minimize the application and try to back to reopen the window.
I tried the setPauseOnLostFocus(true); but it seens to have no effect on android…
Do anyone knows how to fix it ?