MobileAds.initialize() working

662 views
Skip to first unread message

Ali asjad

unread,
Mar 7, 2020, 12:42:55 AM3/7/20
to Google Mobile Ads SDK Developers
Hi,
i am using Admob ads in two processes. I am getting a crash.

Fatal Exception: java.lang.RuntimeException: Using WebView from more than one process at once with the same data directory is not supported. https://crbug.com/558377
       at org.chromium.android_webview.AwBrowserProcess.a + 40(AwBrowserProcess.java:40)
       at vo.c + 88(vo.java:88)
       at vs.run + 3(vs.java:3)
       at org.chromium.base.task.TaskRunnerImpl.d + 53(TaskRunnerImpl.java:53)
       at aNn.run + 2(aNn.java:2)
       at android.os.Handler.handleCallback + 873(Handler.java:873)
       at android.os.Handler.dispatchMessage + 99(Handler.java:99)
       at android.os.Looper.loop + 193(Looper.java:193)
       at android.app.ActivityThread.main + 6736(ActivityThread.java:6736)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run + 497(RuntimeInit.java:497)
       at com.android.internal.os.ZygoteInit.main + 912(ZygoteInit.java:912)

I have done something like this in my Application class:

if (Build.VERSION.SDK_INT >=  Build.VERSION_CODES.P) {
if (getProcessName().equals(getPackageName())) {
MobileAds.initialize(this,getString(R.string.ad_mob_app_id));
}else {
WebView.setDataDirectorySuffix("ads_dir");
}
}else {
MobileAds.initialize(this,getString(R.string.ad_mob_app_id));
}

My Question is:
1) Do i need to call MobileAds.initialize(this,getString(R.string.ad_mob_app_id)); in both process?
2) In Andoid P Should i call MobileAds.initialize(this,getString(R.string.ad_mob_app_id)); after WebView.setDataDirectorySuffix("ads_dir"); or before?

Mobile Ads SDK Forum Advisor Prod

unread,
Mar 9, 2020, 2:02:20 AM3/9/20
to mianal...@gmail.com, google-adm...@googlegroups.com

Hi Ali,

 

Thank you for reaching out to us.

 

I would first recommend checking out this thread, and seeing if it would suffice in answering your questions and/or fixing the issue. If the issue persists, could you then kindly provide the details below (via Reply privately to author) so that I can further investigate?

  • Copy of your sample project (replicating the issue)
  • Steps to reproduce the issue

 

Regards,

Ziv Yves Sanchez

Mobile Ads SDK Team



ref:_00D1U1174p._5001UXUQJJ:ref

Ali asjad

unread,
Mar 9, 2020, 2:39:52 PM3/9/20
to Google Mobile Ads SDK Developers
Yes, it helps but I am confused. There are two processes Main process and let suppose "test" process. I know i have to set WebView.setDataDirectorySuffix("ads_dir"); for "test" process.

My question: do I need to call MobileAds.initialize(this,getString(R.string.ad_mob_app_id)); in both process? or i have to initialize in Main process only and just set data directory for "test" process.

Mobile Ads SDK Forum Advisor Prod

unread,
Mar 10, 2020, 1:34:56 AM3/10/20
to mianal...@gmail.com, google-adm...@googlegroups.com

Hi Ali,

 

My apologies on the link I gave not being sufficient for your purposes. I'll be discussing your concern with the rest of the team in order to gather our insights on this. Rest assured that we'll get back to you shortly.

Mobile Ads SDK Forum Advisor Prod

unread,
Mar 11, 2020, 9:56:33 PM3/11/20
to mianal...@gmail.com, google-adm...@googlegroups.com
Hi Ali,

Thanks for reaching out to us. First of all, Google Mobile Ads SDK only support one process. You cannot request ads on multiple processes. Secondly, we advise you to call WebView.setDataDirectorySuffix() on every process you create that uses a WebView. On the process that initializes MobileAds, call it before the initialize() method.

Hope it helps,
Jill
Google Mobile Ads SDK Team

ref:_00D1U1174p._5001UXUQJJ:ref
Reply all
Reply to author
Forward
0 new messages