errors using Android AdMob 4.3.1 SDK

2,407 views
Skip to first unread message

Irene

unread,
Nov 4, 2011, 12:57:15 PM11/4/11
to google-adm...@googlegroups.com
I just updated one of my apps to use the newest AdMob SDK, and I'm seeing some errors in the publisher console and in my Flurry account which I believe are related. The app does not use WebView or have any internet content of it's own, so I'm fairly sure the following error can be attributed to the AdMob SDK. Has anyone else seen this? Does anyone have any ideas on how to work around these errors? I am instantiated an AdView in code rather than using the xml and I can include my code if it would be helpful. The following are some of the error reports I've received in Flurry and in my publisher console so far:

class java.lang.NullPointerException
Msg: android.webkit.WebView.sendViewSizeZoom:2157

class java.lang.NullPointerException
Msg: android.webkit.WebView.requestFocus:6109

class java.lang.NullPointerException
Msg: android.webkit.WebView.getSettings:2791

java.lang.NullPointerException
at android.webkit.WebView.requestFocus(WebView.java:6109)
at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1073)
at android.view.ViewGroup.requestFocus(ViewGroup.java:1029)
at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1073)
at android.view.ViewGroup.requestFocus(ViewGroup.java:1029)
at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1073)
at android.view.ViewGroup.requestFocus(ViewGroup.java:1029)
at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1073)
at android.view.ViewGroup.requestFocus(ViewGroup.java:1029)
at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1073)
at android.view.ViewGroup.requestFocus(ViewGroup.java:1029)
at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1073)
at android.view.ViewGroup.requestFocus(ViewGroup.java:1032)
at android.view.View.requestFocus(View.java:3568)
at android.view.ViewRoot.clearChildFocus(ViewRoot.java:1586)
at android.view.ViewGroup.clearChildFocus(ViewGroup.java:508)
at android.view.ViewGroup.clearChildFocus(ViewGroup.java:508)
at android.view.ViewGroup.clearChildFocus(ViewGroup.java:508)
at android.view.ViewGroup.clearChildFocus(ViewGroup.java:508)
at android.view.View.clearFocus(View.java:2572)
at android.view.ViewGroup.clearFocus(ViewGroup.java:517)
at android.view.View.setFlags(View.java:4479)
at android.view.View.setFocusable(View.java:3095)
at android.widget.AdapterView.checkFocus(AdapterView.java:695)
at android.widget.AdapterView$AdapterDataSetObserver.onChanged(AdapterView.java:789)
at android.database.DataSetObservable.notifyChanged(DataSetObservable.java:31)
at android.widget.BaseAdapter.notifyDataSetChanged(BaseAdapter.java:50)
at android.widget.CursorAdapter$MyDataSetObserver.onChanged(CursorAdapter.java:385)
at android.database.DataSetObservable.notifyChanged(DataSetObservable.java:31)
at android.database.AbstractCursor.requery(AbstractCursor.java:97)
at android.database.sqlite.SQLiteCursor.requery(SQLiteCursor.java:544)
at android.database.CursorWrapper.requery(CursorWrapper.java:211)
at android.widget.CursorAdapter.onContentChanged(CursorAdapter.java:361)
at android.widget.CursorAdapter$ChangeObserver.onChange(CursorAdapter.java:377)
at android.database.ContentObserver$NotificationRunnable.run(ContentObserver.java:43)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
at dalvik.system.NativeStart.main(Native Method)

Jim

unread,
Nov 4, 2011, 2:24:14 PM11/4/11
to Google AdMob Ads Developers
Please post the code. At first glance, it looks like you might be
referencing an AdView that specifies an incorrect parent view or the
AdView is destroyed while references to it are still trying to modify
it...

-Jim
> android.widget.AdapterView$AdapterDataSetObserver.onChanged(AdapterView.jav a:789)
> at
> android.database.DataSetObservable.notifyChanged(DataSetObservable.java:31)
> at android.widget.BaseAdapter.notifyDataSetChanged(BaseAdapter.java:50)
> at
> android.widget.CursorAdapter$MyDataSetObserver.onChanged(CursorAdapter.java :385)
> at
> android.database.DataSetObservable.notifyChanged(DataSetObservable.java:31)
> at android.database.AbstractCursor.requery(AbstractCursor.java:97)
> at android.database.sqlite.SQLiteCursor.requery(SQLiteCursor.java:544)
> at android.database.CursorWrapper.requery(CursorWrapper.java:211)
> at android.widget.CursorAdapter.onContentChanged(CursorAdapter.java:361)
> at
> android.widget.CursorAdapter$ChangeObserver.onChange(CursorAdapter.java:377 )
> at
> android.database.ContentObserver$NotificationRunnable.run(ContentObserver.j ava:43)

Alvaro

unread,
Nov 4, 2011, 2:39:32 PM11/4/11
to google-adm...@googlegroups.com
I have exactly the same problem, in the onDestroy of my Activity.

I have something like this:

@Override
protected void onDestroy(){
AdView adView = (AdView) findViewById(R.id.ad);
if(adView!=null){
adView.destroy();
}
super.onDestroy();
}

And it raises an exception:

11-04 20:34:59.476: E/AndroidRuntime(9514): FATAL EXCEPTION: main
11-04 20:34:59.476: E/AndroidRuntime(9514): java.lang.RuntimeException: Unable to destroy activity {com.meeble.talkdroidfree/activities.MainActivity}: java.lang.NullPointerException
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2676)
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:2694)
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.app.ActivityThread.access$2100(ActivityThread.java:117)
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:968)
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.os.Handler.dispatchMessage(Handler.java:99)
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.os.Looper.loop(Looper.java:130)
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.app.ActivityThread.main(ActivityThread.java:3687)
11-04 20:34:59.476: E/AndroidRuntime(9514): at java.lang.reflect.Method.invokeNative(Native Method)
11-04 20:34:59.476: E/AndroidRuntime(9514): at java.lang.reflect.Method.invoke(Method.java:507)
11-04 20:34:59.476: E/AndroidRuntime(9514): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
11-04 20:34:59.476: E/AndroidRuntime(9514): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
11-04 20:34:59.476: E/AndroidRuntime(9514): at dalvik.system.NativeStart.main(Native Method)
11-04 20:34:59.476: E/AndroidRuntime(9514): Caused by: java.lang.NullPointerException
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.webkit.WebView.requestFocus(WebView.java:8808)
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1079)
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.view.ViewGroup.requestFocus(ViewGroup.java:1035)
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1079)
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.view.ViewGroup.requestFocus(ViewGroup.java:1035)
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1079)
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.view.ViewGroup.requestFocus(ViewGroup.java:1035)
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1079)
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.view.ViewGroup.requestFocus(ViewGroup.java:1038)
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.view.View.requestFocus(View.java:3724)
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.view.ViewRoot.clearChildFocus(ViewRoot.java:1707)
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.view.ViewGroup.clearChildFocus(ViewGroup.java:509)
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.view.ViewGroup.clearChildFocus(ViewGroup.java:509)
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.view.ViewGroup.clearChildFocus(ViewGroup.java:509)
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.view.ViewGroup.clearChildFocus(ViewGroup.java:509)
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.view.ViewGroup.removeViewInternal(ViewGroup.java:2213)
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.view.ViewGroup.removeViewInternal(ViewGroup.java:2187)
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.view.ViewGroup.removeView(ViewGroup.java:2135)
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:972)
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1053)
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1036)
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.support.v4.app.FragmentManagerImpl.dispatchDestroy(FragmentManager.java:1779)
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.support.v4.app.FragmentActivity.onDestroy(FragmentActivity.java:308)
11-04 20:34:59.476: E/AndroidRuntime(9514): at activities.MessengerActivity.onDestroy(MessengerActivity.java:168)
11-04 20:34:59.476: E/AndroidRuntime(9514): at activities.MainActivity.onDestroy(MainActivity.java:161)
11-04 20:34:59.476: E/AndroidRuntime(9514): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2663)
11-04 20:34:59.476: E/AndroidRuntime(9514): ... 11 more

I have solved it removing the code in the onDesroy... I think that actually is not a problem since my app only works from 2.2. And the leak bug should be fixed...

2011/11/4 Jim <secondp...@gmail.com>



--
Alvaro Luis Bustamante
Universidad Carlos III de Madrid
GIAA - Grupo de Inteligencia Artificial Aplicada

Irene

unread,
Nov 7, 2011, 1:39:38 PM11/7/11
to google-adm...@googlegroups.com
Below is the code I'm using to load ads. I also override the onConfigurationChanged method in some of my activities and call the reloadAd() method there. Is it possible that the error is happening when the AdView is removed from the ViewFlipper? I have an onDestroy method similar to Meeble Labs response below as well. Is it ok to remove the adView.destroy(); in order to fix this issue?

protected void reloadAd() {
try {
if(viewFlipper != null) {
viewFlipper.removeAllViews();
viewFlipper = null;
}
viewFlipper = (SafeViewFlipper) findViewById(R.id.ad);
if(adMobView == null) {
adMobView = new AdView(this, AdSize.BANNER, Constants.ADMOB_PUBLISHER_ID);
adMobView.setAdListener(this);
}
adMobRequest = new AdRequest();
adMobView.loadAd(adMobRequest);

viewFlipper.addView(adMobView);
viewFlipper.setDisplayedChild(0);

} catch(Exception e) { }
}
}

Thanks in advance.

Eric Leichtenschlag

unread,
Nov 7, 2011, 2:08:18 PM11/7/11
to google-adm...@googlegroups.com
Have you been able to reproduce this crash yourself?  If so, what version of the emulator or device are you getting these errors on?  The adView.destroy() method is a workaround to some WebView crashes that occur on Android 1.5 and 1.6 devices.  If you support those devices, then removing adView.destroy() is probably not a great solution.  I'm also not sure this will work for you anyways, as I don't see an onDestroy() method in your stack trace.

Also, is there a reason you're placing the AdView in a ViewFlipper?

Eric, AdMob SDK Support

Irene

unread,
Nov 7, 2011, 2:27:14 PM11/7/11
to Google AdMob Ads Developers
I have not been able to reproduce the crash myself so I may not have
the full stack trace. We support only Android 2.1+. Does this mean it
is ok to remove the adMobView.destroy() call? Should it be replaced
with adMobView.stopLoading()? Do you know of any other reasons I could
be seeing these errors in the Android market publisher console?

I'm placing the AdView in a ViewFlipper so that I can show my own
house ad when AdMob fails to return an ad. I'm overriding the
AdViewListener methods as follows:

@Override
public void onReceiveAd(Ad arg0) {
try {
if (viewFlipper != null && Constants.FREE &&
viewFlipper.getCurrentView() != adMobView) {
viewFlipper.setDisplayedChild(0);
}
} catch(Exception e) { }
}

@Override
public void onFailedToReceiveAd(Ad arg0, ErrorCode arg1) {
try {
if(viewFlipper != null && Constants.FREE) {
if(viewFlipper.getChildCount() == 1) {
viewFlipper.addView(Utils.getHouseAd());
}
viewFlipper.setDisplayedChild(1);
}
} catch (Exception e) {
Log.d("Caught a Flurry exception");
}
}


On Nov 7, 11:08 am, Eric Leichtenschlag <eleichtens...@google.com>
wrote:

costa

unread,
Nov 13, 2011, 8:01:27 PM11/13/11
to Google AdMob Ads Developers
I'm have same problem

test device: Android 2.1.1

java.lang.NullPointerException
at android.webkit.WebView.getSettings(WebView.java:2791)
at android.webkit.WebView.onWindowFocusChanged(WebView.java:3621)
at android.view.View.dispatchWindowFocusChanged(View.java:3785)
at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:
741)
at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:
745)
at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:
745)
at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:
745)
at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:
745)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1819)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4370)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)


code:
protected void onCreate(Bundle savedInstanceState)
{
...(ignore)...


RelativeLayout layout = new RelativeLayout(this);

// Create and setup the AdMob view
mAdView = new AdView(this, AdSize.BANNER, "xxxxxxxxxx");
mAdView.setAdListener(this);
AdRequest request = new AdRequest();
mAdView.loadAd(request);

// Add the libgdx view
layout.addView(getGLSurfaceView());

// Add the AdMob view
RelativeLayout.LayoutParams adParams = new
RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,

RelativeLayout.LayoutParams.WRAP_CONTENT);
adParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
adParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);

layout.addView(mAdView, adParams);

// Hook it all up
setContentView(layout);

...(ignore)...
}

protected void onPause()
{
try
{
mAdView.destroy();
}
catch(NullPointerException e)
{
;
}

super.onPause();
finish();
}

b0b

unread,
Nov 15, 2011, 5:58:18 AM11/15/11
to google-adm...@googlegroups.com


Hi Eric,

Can the call to AdView.onDestroy() be omitted on an app targetting Android 2.1+ ?

Eric Leichtenschlag

unread,
Nov 15, 2011, 10:50:39 AM11/15/11
to google-adm...@googlegroups.com
Hello b0b,

The call to AdView.destroy() isn't as important if you are running Android 2.1+, as I'm not sure there are any known WebView crashes on Android 2.1+ devices.  If not making this call is indeed a workaround to this error, it is your best short term bet.  We don't want this to be the long term solution though.  The AdView.destroy() call lets us clean up the AdView properly, and it is intended to prevent catch these WebView errors, not cause them.

@Irene, I didn't see anything particular in your code that would cause this error.

Eric, AdMob SDK Support

Michael Diener

unread,
Nov 21, 2011, 11:17:32 AM11/21/11
to google-adm...@googlegroups.com
Hi Eric,

could be stopLoading() an alternative to destroy()? 

Following are different NullPointerExceptions I am seeing and which seem to happen quite often. I'm seriously considering to move back to 4.1.1 instead of 4.3.1 as I had less exceptions with it. Btw. I'm also not able to reproduce the exceptions myself.

Michael

java.lang.NullPointerException
        at android.webkit.WebView.requestFocus(WebView.java:5094)
        at android.view.View.requestFocus(View.java:3546)
        at android.view.ViewRoot.leaveTouchMode(ViewRoot.java:1996)
        at android.view.ViewRoot.ensureTouchModeLocally(ViewRoot.java:1921)
        at android.view.ViewRoot.ensureTouchMode(ViewRoot.java:1903)
        at android.view.View.requestFocusFromTouch(View.java:3616)
        at de.mdiener...onResume(Unknown Source)

java.lang.NullPointerException
        at android.webkit.WebView.pictureReady(WebView.java:6825)
        at android.webkit.WebView.onTouchEvent(WebView.java:6830)
        at android.view.View.dispatchTouchEvent(View.java:3938)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
        at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1154)
        at android.view.ViewRoot.dispatchDetachedFromWindow(ViewRoot.java:1754)
        at android.view.ViewRoot.doDie(ViewRoot.java:2847)
        at android.view.ViewRoot.die(ViewRoot.java:2817)
        at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:244)
        at android.view.Window$LocalWindowManager.removeViewImmediate(Window.java:436)
        at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:2705)
        at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2810)
        at android.app.ActivityThread.access$1600(ActivityThread.java:117)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:123)
        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:847)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
        at dalvik.system.NativeStart.main(Native Method)

java.lang.NullPointerException
        at android.webkit.WebView.onWindowFocusChanged(WebView.java:4369)
        at android.view.View.dispatchWindowFocusChanged(View.java:3731)
        at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:669)
        at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:673)
        at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:673)
        at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:673)
        at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:673)
        at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:673)
        at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:673)
        at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:673)
        at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:673)
        at android.view.ViewRoot.handleMessage(ViewRoot.java:1857)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:123)
        at android.app.ActivityThread.main(ActivityThread.java:4608)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:521)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
        at dalvik.system.NativeStart.main(Native Method)

Caused by: java.lang.NullPointerException
        at android.webkit.WebView.resumeTimers(WebView.java:3341)
        at de.mdiener....(Unknown Source)
        at de.mdiener....onResume(Unknown Source)
        at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1150)
        at android.app.Activity.performResume(Activity.java:3832)
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2114)
        ... 10 more

Caused by: java.lang.NullPointerException
        at android.webkit.WebView.pauseTimers(WebView.java:2732)
        at de.mdiener...(Unknown Source)
        at de.mdiener...onPause(Unknown Source)
        at android.app.Activity.performPause(Activity.java:3851)
        at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1191)
        at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2362)


b0b

unread,
Nov 21, 2011, 12:04:12 PM11/21/11
to google-adm...@googlegroups.com
I have seen very few crashes with 4.3.1 except 1 instance of

java.lang.NullPointerException
        at android.webkit.WebView.onWindowFocusChanged(WebView.java:4369)

Note that my app schedule requests at its own rate which might not be typical use.

4.1.1 was catastrophic with the infamous stopLoading() crash, but this version seems very stable.





Eric Leichtenschlag

unread,
Nov 21, 2011, 1:13:04 PM11/21/11
to google-adm...@googlegroups.com
Michael,

Which versions of Android does your app support?

stopLoading() isn't an alternate to destroy().  stopLoading() just stops loading ads.  If you don't call destroy(), then the WebView will get destroyed when Android is ready, and it may throw some exceptions.  Calling destroy() allows the SDK to proactively destroy the WebView and catch any such exceptions.  I'm still not sure how calling destroy() could throw additional exceptions that don't have the SDK in the stack trace.

Eric, AdMob SDK Support

Irene

unread,
Nov 21, 2011, 2:37:03 PM11/21/11
to Google AdMob Ads Developers
Just wanted to give an update: We started using stopLoading() instead
of destroy() and have not seen any errors since then.
-Irene

On Nov 21, 10:13 am, Eric Leichtenschlag <eleichtens...@google.com>
wrote:

Michael Diener

unread,
Nov 21, 2011, 2:10:28 PM11/21/11
to Google AdMob Ads Developers
Eric,

it supports SDK level 4 up to 14. I was thinking to do the destroy()
only for SDK levels > 4 - but I like to be sure before releasing a new
version.
Thanks for clarifying stopLoading in any case.

From my point of view only the AdMob SDK can cause the issues that I'm
experiencing because no other WebViews are used in my app. My guess
would be that the WebView.destroy() is called not only from my
Activity's onDestroy but somewhere else from within the AdMob SDK, but
again, that is only a guess.

Michael

On 21 Nov., 19:13, Eric Leichtenschlag <eleichtens...@google.com>
wrote:

Michael Diener

unread,
Nov 26, 2011, 4:45:23 AM11/26/11
to Google AdMob Ads Developers
Just a quick update from my side. Only thing I could do was to
experiment and that is what I did. I tried 2 different solutions in 2
apps. One was to use stopLoading() as Irene suggested and the other
was to destroy and remove all AdViews from the layout in onPause().
With both solutions I did not get the NullPointerExceptions anymore.
The stopLoading() solution still had the drawback of causing an
exception I only received from Google TV devices (reported in a
different thread), so finally I decided for the 2nd solution with
destroy and remove in onPause(). It might sound a bit radical to use
this kind of solution but at least it works and I don't have to run
more experiments with my users.

One thing I forgot to mention earlier was, that I have used the
AdWhirl SDK in its latest version. Maybe this is part of the problem.
Irene, did you use AdWhirl as well?

Michael

Lisitso

unread,
Mar 18, 2013, 5:39:07 PM3/18/13
to google-adm...@googlegroups.com
Same problem here, using GoogleAdMobAdsSdk-6.3.0, i have an incredible quantity of crash report.
Here just an example:
OS VERSION.RELEASE: 2.3.6 OS SDK_INT: 10
BRAND: samsung MODEL: GT-S5830i


java.lang.NullPointerException
        at android.webkit.WebView.
requestFocus(WebView.java:8919)
        at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1079)
        at android.view.ViewGroup.requestFocus(ViewGroup.java:1035)
        at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1079)
        at android.view.ViewGroup.requestFocus(ViewGroup.java:1035)
        at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1079)
        at android.view.ViewGroup.requestFocus(ViewGroup.java:1035)
        at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1079)
        at android.view.ViewGroup.requestFocus(ViewGroup.java:1035)
        at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1079)
        at android.view.ViewGroup.requestFocus(ViewGroup.java:1035)
        at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1079)
        at android.view.ViewGroup.requestFocus(ViewGroup.java:1035)
        at android.view.View.requestFocus(View.java:3671)
        at android.view.View.requestFocus(View.java:3649)
        at android.view.ViewRoot.focusableViewAvailable(ViewRoot.java:1720)
        at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:452)
        at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:452)
        at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:452)
        at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:452)
        at android.view.View.setFlags(View.java:4633)
        at android.view.View.setVisibility(View.java:3116)
        at android.widget.ViewAnimator.showOnly(ViewAnimator.java:146)
        at android.widget.ViewAnimator.setDisplayedChild(ViewAnimator.java:102)
        at android.widget.ViewAnimator.showNext(ViewAnimator.java:120)
        at ..here there's my code/line
        at ..here there's my code/line
        at ..here there's my code/line   $3$1.run (  ... )

        at android.os.Handler.handleCallback(Handler.java:587)
        at android.os.Handler.dispatchMessage(Handler.java:92)
        at android.os.Looper.loop(Looper.java:130)
        at android.app.ActivityThread.main(ActivityThread.java:3687)
        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:867)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
        at dalvik.system.NativeStart.main(Native Method)

any idea/suggestment to fix or at least catch this?
If you need more other examples or devices information
where this crash happen, feel free to ask me.

Thank you,
L.

Eric Leichtenschlag

unread,
Mar 20, 2013, 5:34:55 PM3/20/13
to google-adm...@googlegroups.com
This has been a tough crash to track down. AdMob isn't in the stack trace, and we haven't been able to reproduce it.

This is the first time I've seen ViewAnimator in the trace though. I haven't used ViewAnimator before, but I wonder if it exposes the crash in Android's WebView.

Do you have a sample project that can reproduce the issue?

Thanks,
Eric



--
 
---
You received this message because you are subscribed to the Google Groups "Google AdMob Ads Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
  

Lisitso

unread,
Mar 21, 2013, 9:52:21 AM3/21/13
to google-adm...@googlegroups.com
Hi Eric,
first of all thanks for the reply.
On my devices this crash doesn't happen, I just get the notice by the crash report catched via acra (and similar tools) or sent by users. Unfortunately I have no chance to provide you in short time a sample project to reproduce the issue but I'll try to write it.
Just few this I want you point on:
- the adview is hosted in a ViewFlipper container, this is the reason I guess you see the ViewAnimator on the stacktrace.
- I have 0 crash reports on the same application with AdMob deactivated: this lead me to believe that your sdk is connected to the issue (moreover: I have no webviews in my app)

If you need more details let me know.

Regards,
Andrea

Eric Leichtenschlag

unread,
Mar 22, 2013, 5:51:26 PM3/22/13
to google-adm...@googlegroups.com
Ok the ViewFlipper is likely not the problem then.

A sample app that can reproduce the issue would be best to help us track it down. Some statistics on which devices this occurs on could also be a hint, as sometimes it's an issue with a custom flavor of Android (i.e. Samsung's flavor in their Galaxy S series).

Thanks,
Eric


Olexander Danchuk

unread,
Dec 14, 2013, 12:46:05 AM12/14/13
to google-adm...@googlegroups.com
Thank you Dan!

Your solution works well
but I have noticed that if I switch activity couple times it raise memory usage from 7Mb to 32Mb and CPU up to 40%.
After couple seconds it comes back to 0

I have this problem on Android 2.2 Samsung Galaxy S device


On Wednesday, November 14, 2012 8:22:47 PM UTC-4, Dan Dragut wrote:
I just had the same problem with 6.2.1 with activity onDestroy(); it was easily replicable for me if leaving the activity early (back) right after the ad was loaded - I was simply calling adView.destroy(). Apparently calling adView.removeAllViews() beforehand helps. I've also put a stopLoading() just to be sure. My final code:
 
if (adView != null) {
  adView.stopLoading();
  adView.removeAllViews();
  adView.destroy();
}

Dan Dragut

unread,
Jan 12, 2014, 3:18:55 PM1/12/14
to google-adm...@googlegroups.com
Hi Olexander,

That's probably an issue that deserves it's own thread.

I would be taking HPROF dumps "before" and "after", then analyse them with Eclipse Memory Analyzer (MAT), which might even allow you to compare them for differences.

See if this blog post helps you get started:
http://android-developers.blogspot.com/2011/03/memory-analysis-for-android.html

- Dan
Reply all
Reply to author
Forward
0 new messages