Admob横幅广告未在Android P中加载

问题描述 投票:3回答:1

我在多进程中使用AdMob横幅广告。它在低于29的API版本上工作正常,但在android-P上,它给出了这个错误。

 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

我在应用程序类中初始化了MobileAds。我也尝试在其他使用广告但没有运气的过程中进行初始化。

android admob google-admob android-9.0-pie
1个回答
6
投票

注意你的错误中的这一行:“Caused by: java.lang.RuntimeException: Using WebView from more than one process at once with the same data directory is not supported.

这意味着您的应用程序正在使用2个或更多进程,您需要为每个进程设置不同的WebView目录(主进程已经有默认文件夹),如我的question and answer here中所述。

在Android 9.0 API 28上,在使用任何WebView.setDataDirectorySuffix("any-folder-name")之前,在第二个进程运行时调用WebView

© www.soinside.com 2019 - 2024. All rights reserved.