当前位置: 首页 > 知识库问答 >
问题:

“谷歌移动广告SDK初始化错误”

赵星华
2023-03-14

这不是这篇文章的重复(他们更新了错误的文件)。

获取错误

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

即使我更新了。。\app\src\main\AndroidManifest。带有的xml

<meta-data 
        android:name="com.google.android.gms.ads.APPLICATION_ID" 
        android:value="ca-app-pub-1234567890123456~1234567890"/>

我跟随了几篇教程和帖子,但结果总是一样的。

我在main中初始化。省道组件

FirebaseAdMob.instance.initialize(appId: "ca-app-pub-1234567890123456~1234567890");

以下是我的完整错误报告:

Launching lib\main.dart on Android SDK built for x86 in debug mode...
lib\main.dart
√ Built build\app\outputs\flutter-apk\app-debug.apk.
FATAL EXCEPTION: main
Process: com.dreamalytics.dreamapp, PID: 23404
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.zzzo.attachInfo(com.google.android.gms:play-services-ads-lite@@19.6.0:31)
    at com.google.android.gms.ads.MobileAdsInitProvider.attachInfo(com.google.android.gms:play-services-ads-lite@@19.6.0:3)
    at android.app.ActivityThread.installProvider(ActivityThread.java:6983)
    ... 10 more

颤振医生-v

[√] Flutter (Channel stable, 1.22.5, on Microsoft Windows [Version 10.0.18362.535], locale en-CA)
• Flutter version 1.22.5 at C:\projects\flutter
• Framework revision 7891006299 (4 weeks ago), 2020-12-10 11:54:40 -0800
• Engine revision ae90085a84
• Dart version 2.10.4

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at C:\Users\butto\AppData\Local\Android\sdk
• Platform android-29, build-tools 29.0.2
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.

[!] Android Studio (version 4.1.0)
• Android Studio at C:\Program Files\Android\Android Studio
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] Connected device (1 available)
• Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)

完整的AndroidManifest。xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dreamalytics.dreamapp">

<!-- io.flutter.app.FlutterApplication is an android.app.Application that
     calls FlutterMain.startInitialization(this); in its onCreate method.
     In most cases you can leave this as-is, but you if you want to provide
     additional functionality it is fine to subclass or reimplement
     FlutterApplication and put your custom class here. -->
<uses-permission android:name="android.permission.INTERNET"/>
<application
    android:name="io.flutter.app.FlutterApplication"
    android:label="Dreamalytics"
    android:icon="@mipmap/launcher_icon">
    <activity
        android:name=".MainActivity"
        android:launchMode="singleTop"
        android:theme="@style/LaunchTheme"
        android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
        android:hardwareAccelerated="true"
        android:windowSoftInputMode="adjustResize">
        <!-- This keeps the window background of the activity showing
             until Flutter renders its first frame. It can be removed if
             there is no splash screen (such as the default splash screen
             defined in @style/LaunchTheme). -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
        <intent-filter>
            <action android:name="FLUTTER_NOTIFICATION_CLICK"/>
            <category android:name="android.intent.category.DEFAULT"/>
        </intent-filter>
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_icon"
            android:resource="@drawable/notification_icon" />
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_color"
            android:resource="@color/deep_purple" />
        <meta-data
            android:name="com.google.android.gms.ads.AD_MANAGER_APP"
            android:value="true"/>
        <meta-data 
            android:name="com.google.android.gms.ads.APPLICATION_ID" 
            android:value="ca-app-pub-4347201915048498~6120388314"/>
    </activity>
</application>
</manifest>

共有1个答案

邹玮
2023-03-14

原来我在中有标签

所以,有了这个

<manifest>
    <application>
        <activity>
            <meta-data> 
                android:name="com.google.android.gms.ads.APPLICATION_ID" 
                android:value="ca-app-pub-4347201915048498~6120388314"/>
        </activity>
    </application>
</manifest>

当我应该拥有这个的时候

<manifest>
    <application>
        <activity>
        </activity>
        <meta-data 
            android:name="com.google.android.gms.ads.APPLICATION_ID" 
            android:value="ca-app-pub-4347201915048498~6120388314"/>
    </application>
</manifest>

 类似资料:
  • 如果我们需要初始化Admob SDK,那么我们应该在MainActivity中对其进行一次初始化。还是需要在每个有Admob广告的活动中初始化它? 根据此链接:https://firebase.google.com/docs/admob/android/quick-start"要在应用启动时初始化Google Mobile Ads SDK,请在MainActive类的onCreate()方法中调用

  • 我正在尝试向我的游戏添加广告,但发现Android实际上有两个选项(也就是说,如果我想使用Admob):有Google Mobile Ads,然后是Unity-Admob。有人可以告诉我它们之间的区别以及使用哪一个吗?当尝试谷歌它时,我得到的只是“Unity Ads vs Admob”,这不是我正在寻找的问题,因为(据我所知)我链接的两个应该基本相同。

  • 我合作的公司有许多客户使用谷歌广告为他们的网站做营销。公司希望使用客户的数据进行分析。我得到了一个项目,使用C#集成谷歌广告API,从谷歌广告中获取所有数据,如活动等,并将其移动到我们的系统中为每个客户端。我只给开发人员令牌和客户端的客户ID。例如 客户A的客户ID 客户B的客户ID 当我浏览谷歌广告API文档时,我有点不知所措。在文档中,是OAuth2。0需要创建才能使用客户端库,该库将生成客户

  • 我想得到的活动和广告表现的报告。到目前为止,我已经得到了竞选业绩报告,但我无法得到广告业绩报告。 我在客户端库中看到了谷歌广告api和它们的例子。但我无法理解如何获得广告报道。 我正在制作一个函数,通过谷歌广告api为我获取报告。 谷歌广告Api:https://developers.google.com/google-ads/api/docs/fields/ad_group_ad#ad_grou

  • 根据服务部署方式,分为公有云、专属云和私有云。其中专属云和私有云部署又称为独立部署,以下初始化分别介绍了服务部署方式为公有云部署和独立部署的情况。 整个应用程序中,在 App启动入口主线程初始化,我们建议您在首次打开app时调用, 只需要调用一次。但是对于B2B模式,需要在每次打开聊窗时候再次调用一次初始化方法,具体参考集成文档的B2B集成。 注意: 文档中提到的参数值仅作为演示说明用,正式集成时

  • 初始化SDK 在整个应用程序中,初始化sdk要放在application的oncreate方法中,该方法在整个应用的生命周期里只需要调用一次,且必须在主进程调用。 注意:如果在App开启时有多进程启动,需要将“initSDK”方法放到主进程中,保证打开App只会调用一次初始化,避免多进程启动导致Application的onCreate方法执行多次 。 公版用户,调用初始化方法如下 : /** *