Android-使用AdMob SDK 4.3.1 for Android 出现 NPE (at WebView.requestFocus)

Android-使用AdMob SDK 4.3.1 for Android 出现 NPE (at WebView.requestFocus)

瑾兮 发布于 2017-03-06 字数 3660 浏览 1247 回复 1
  1. AdMob SDK
    GoogleAdMobAdsSdk-4.3.1.jar
    AdWhirlSDK_Android_3.1.1.jar

    <coding-1 lang="other">

</coding>
2. 代码
LinearLayout adViewLayout =(LinearLayout)this.findViewById(R.id.adView_layout);
AdWhirlLayout adWhirlLayout = new AdWhirlLayout(this, "MY_AD_UNIT_ID");
AdWhirlManager.setConfigExpireTimeout(45*1000);
adViewLayout.addView(adWhirlLayout);

  1. 出现Bug的位置在onDestroy, 但是中国地区的广告在某天出现过该Bug,第二天后就暂时没出现了。从Bug收集上看,其他地区的客户端出现该Bug的几率非常大。下面是Bug Log:
    java.lang.RuntimeException: Unable to destroy activity : java.lang.NullPointerException at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3661) at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3679) at android.app.ActivityThread.access$2900(ActivityThread.java:126) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2071) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:123) at android.app.ActivityThread.main(ActivityThread.java:4633) 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:858) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at android.webkit.WebView.requestFocus(WebView.java:7410) 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:3556) 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.ViewGroup.clearChildFocus(ViewGroup.java:508) at android.view.ViewGroup.clearChildFocus(ViewGroup.java:508) at android.view.ViewGroup.removeViewInternal(ViewGroup.java:2207) at android.view.ViewGroup.removeViewInternal(ViewGroup.java:2181) at android.view.ViewGroup.removeView(ViewGroup.java:2129) at android.support.v4.app.FragmentManagerImpl.moveToState(Unknown Source) at android.support.v4.app.FragmentManagerImpl.moveToState(Unknown Source) at android.support.v4.app.FragmentManagerImpl.moveToState(Unknown Source) at android.support.v4.app.FragmentManagerImpl.dispatchDestroy(Unknown Source) at android.support.v4.app.FragmentActivity.onDestroy(Unknown Source) at xx.xxx.xxx.xxx.xxxActivity.onDestroy(Unknown Source) at ...

  2. 目前还不能准确定位问题所在,暂时处理方式为:在onPause时、或者在super.onDestroy前移除广告的View。

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浮生未歇 2017-11-02 1 楼

这个问题出现点比较狭窄,主要是admob4.3.1sdk上显现较多,主要可能是系统次啊用回调机制的时候,发现被调用的对象已经被destory.