首页 > 解决方案 > java.lang.RuntimeException:无法获取提供程序 com.google.android.gms.ads.MobileAdsInitProvider:java.lang.IllegalStateException:

问题描述

如何在java项目中的android studio 4.0中解决这个问题

我没有在我的项目中使用任何 admob,但它也显示了这个错误。请帮助我尝试了您在上述解决方案中提到的内容。但错误继续....

2020-06-23 00:59:20.816 10332-10332/? W/ample.importcs: Unexpected CPU variant for X86 using defaults: x86
2020-06-23 00:59:22.200 10332-10332/com.example.importcsv E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.importcsv, PID: 10332
    java.lang.RuntimeException: Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.IllegalStateException: 
    
    ******************************************************************************
    * The Google Mobile Ads SDK was initialized incorrectly. AdMob publishers    *
    * should follow the instructions here:                                       *
    * https://googlemobileadssdk.page.link/admob-android-update-manifest         *
    * to add a valid App ID inside the AndroidManifest.                          *
    * Google Ad Manager publishers should follow instructions here:              *
    * https://googlemobileadssdk.page.link/ad-manager-android-update-manifest.   *
    ******************************************************************************
    
    
        at android.app.ActivityThread.installProvider(ActivityThread.java:6988)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:6528)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6445)
        at android.app.ActivityThread.access$1300(ActivityThread.java:219)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
     Caused by: java.lang.IllegalStateException: 
    
    ******************************************************************************
    * The Google Mobile Ads SDK was initialized incorrectly. AdMob publishers    *
    * should follow the instructions here:                                       *
    * https://googlemobileadssdk.page.link/admob-android-update-manifest         *
    * to add a valid App ID inside the AndroidManifest.                          *
    * Google Ad Manager publishers should follow instructions here:              *
    * https://googlemobileadssdk.page.link/ad-manager-android-update-manifest.   *
    ******************************************************************************
    
    
        at com.google.android.gms.internal.ads.zzyz.attachInfo(com.google.android.gms:play-services-ads-lite@@19.2.0:33)
        at com.google.android.gms.ads.MobileAdsInitProvider.attachInfo(com.google.android.gms:play-services-ads-lite@@19.2.0:3)
        at android.app.ActivityThread.installProvider(ActivityThread.java:6983)
            ... 10 more```

标签: javaandroid

解决方案


只需将此代码添加到您的应用程序的清单中即可

<meta-data
            android:name="com.google.android.gms.ads.AD_MANAGER_APP"
            android:value="true"/>

推荐阅读