Admob banner ad not loading in android P

点点圈 提交于 2019-11-30 14:15:47

问题


I am using AdMob banner ads in multi-process. It is working fine on API version lower than 29 but on android-P, it is giving this error.

 com.google.android.gms.ads.internal.webview.s: Webview initialization failed.
    at com.google.android.gms.ads.internal.webview.o.a(:com.google.android.gms.policy_ads_fdr_dynamite@6000@6000.204543870.204543870:5)
    at com.google.android.gms.ads.internal.i.a(:com.google.android.gms.policy_ads_fdr_dynamite@6000@6000.204543870.204543870:6)
    at com.google.android.gms.ads.internal.y.a(:com.google.android.gms.policy_ads_fdr_dynamite@6000@6000.204543870.204543870:4)
    at com.google.android.gms.ads.internal.l.run(:com.google.android.gms.policy_ads_fdr_dynamite@6000@6000.204543870.204543870:11)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at com.google.android.gms.ads.internal.util.f.dispatchMessage(:com.google.android.gms.policy_ads_fdr_dynamite@6000@6000.204543870.204543870:1)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6669)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
 Caused by: java.lang.RuntimeException: Using WebView from more than one process at once with the same data directory is not supported. https://crbug.com/558377

I have initialized MobileAds in application class. i also tried to initialize in other process in which i am using ads but no luck.


回答1:


Notice this line in your error: " Caused by: java.lang.RuntimeException: Using WebView from more than one process at once with the same data directory is not supported."

It means your app is using 2 or more processes and you need to set a different WebView directory for each process (the main process already have the default folder), as explained in my question and answer here.

On Android 9.0 API 28, call WebView.setDataDirectorySuffix("any-folder-name") when the second process is running, before you use any WebView.



来源:https://stackoverflow.com/questions/52144354/admob-banner-ad-not-loading-in-android-p

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!