Skip to content Skip to sidebar Skip to footer

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.webvie

Solution 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.

Solution 2:

in case when you deals with ads, in application class

try {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
            val process = getProcessName()
            if (packageName != process) WebView.setDataDirectorySuffix(process)
        }

        MobileAds.initialize(this)
        AudienceNetworkAds.initialize(this)

    } catch (e: Error) {
        Timber.e(e)
    } catch (e: Exception) {
        Timber.e(e)
    }

Post a Comment for "Admob Banner Ad Not Loading In Android P"