Admob Unable to destroy activity

While I haven't witnessed this on any of my devices, which is more frustrating, I have this stack trace going through from users in the market.

java.lang.RuntimeException: Unable to destroy activity
sbsoftware.jewelgobbler/com.google.ads.AdActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2676)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:2694)
at android.app.ActivityThread.access$2100(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:968)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3691)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.webkit.WebView.loadUrl(WebView.java:2341)
at android.webkit.WebView.loadUrl(WebView.java:2357)
at a.a(Unknown Source)
at a.a(Unknown Source)
at a.b(Unknown Source)

      

The application is a game operated by AndEngine GLES1. It uses XML approach to customize the ad, for example in my main layout,

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<org.anddev.andengine.opengl.view.RenderSurfaceView
android:id="@+id/xmllayoutRenderSurfaceView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:gravity="center" />
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/xmllayoutRenderSurfaceView"
android:layout_centerInParent="true"
ads:adSize="BANNER"
ads:adUnitId="<MyCode>"
ads:loadAdOnCreate="true" />
</RelativeLayout>

      

This is a manifest activity of Admob,

<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize| 
smallestScreenSize"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
</application>

      

Implementation in the main activity, JewelGobblerActivity, which extends LayoutGameActivity,

public static AdView adView;
public static InterstitialAd interstitial;

@Override
public void onLoadResources() { 
    adView = (AdView) findViewById(R.id.adView);
    interstitial = new InterstitialAd(this, "<MyCode>");
    AdRequest adRequest = new AdRequest();
    interstitial.loadAd(adRequest);

    //other stuff       
    SceneManager.init(this, mCamera);
    LoadCurrentDetails();

} 
...
@Override
protected int getLayoutID() {
    // TODO Auto-generated method stub
    return R.layout.main;
}


@Override
protected int getRenderSurfaceViewID() {
    // TODO Auto-generated method stub
    return R.id.xmllayoutRenderSurfaceView;
}

      

And that goes for everything about Admob except for the two ad routines in my SceneManager,

public static void ShowInterstitialAd()
{
    JewelGobblerActivity.handler.post(new Runnable() {
    @Override
    public void run() {

    if (JewelGobblerActivity.interstitial != null)
    {

        if (JewelGobblerActivity.interstitial.isReady())
        {
            JewelGobblerActivity.interstitial.show();
            JewelGobblerActivity.interstitial.loadAd(new AdRequest()); //request a new ad
        }
    }

    }
});

}

public static void SetAdVisibility(final boolean Visible)
{
    JewelGobblerActivity.handler.post(new Runnable() {
    @Override
    public void run() {

        if (JewelGobblerActivity.adView != null)
        {
            if (Visible) JewelGobblerActivity.adView.setVisibility(View.VISIBLE);
            else JewelGobblerActivity.adView.setVisibility(View.INVISIBLE);
        }

    }
    });

}

      

I am using Admob 6.2.1. It works great on all the devices I need, including SG 1 and 3, Huawei and Archos ... everything works great, from banner and interstitial ads. Has anyone else had this problem or managed to fix it? Any help would be greatly appreciated!

Greetings

Stephen

+3


source to share





All Articles