Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Admob banner ad not loading in android P

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@[email protected]:5)
    at com.google.android.gms.ads.internal.i.a(:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:6)
    at com.google.android.gms.ads.internal.y.a(:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:4)
    at com.google.android.gms.ads.internal.l.run(:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]: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@[email protected]: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.

like image 593
Mateen Chaudhry Avatar asked Sep 03 '18 06:09

Mateen Chaudhry


1 Answers

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.

like image 51
Lior Iluz Avatar answered Sep 28 '22 01:09

Lior Iluz