I update my Android Studio (3.2.1) and its sdk to the latest version. After that it required a manual update for Manifest by adding these tags:

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@drawable/ic_launcher"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    tools:ignore="AllowBackup,GoogleAppIndexingWarning">

    <meta-data
        android:name="com.google.android.gms.ads.APP_ID"
        android:value="ca-app-pub-#############"/>

    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".NewActivity" />
    <activity android:name=".PreviewActivity" />
    <activity android:name=".EditActivity" />
    <activity
        android:name=".preferencesdata.AboutActivity"
        android:theme="@style/Theme.AppCompat.DayNight.NoActionBar" />
    <activity android:name=".preferencesdata.SettingsActivity"
        android:label="@string/settings">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value=".MainActivity"/>
    </activity>
</application>

whereby instead the app ID I put the real id of my app. The value has also been changed to the right Ad Unit id as shown here https://developers.google.com/admob/android/quick-start. I also called this function in the MainActivity.kt:

MobileAds.initialize(this, resources.getString(R.string.banner_ad_unit_id)) 

然而,这个问题并没有得到解决.它仍然打印如下:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.easyapps.cryptnote, PID: 3991
    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 LINK to add a valid  *
    * App ID inside the AndroidManifest. Google Ad Manager publishers should     *
    * follow instructions here: LINK.                           *
    ******************************************************************************


        at android.app.ActivityThread.installProvider(ActivityThread.java:5156)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688)
        at android.app.ActivityThread.-wrap1(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5417)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
     Caused by: java.lang.IllegalStateException: 

    ******************************************************************************
    * The Google Mobile Ads SDK was initialized incorrectly. AdMob publishers    *
    * should follow the instructions here: LINK to add a valid  *
    * App ID inside the AndroidManifest. Google Ad Manager publishers should     *
    * follow instructions here: LINK.                           *
    ******************************************************************************


        at com.google.android.gms.internal.ads.zzmn.attachInfo(Unknown Source)
        at com.google.android.gms.ads.MobileAdsInitProvider.attachInfo(Unknown Source)
        at android.app.ActivityThread.installProvider(ActivityThread.java:5153)
            ... 10 more

有人能告诉我为什么会这样,或者帮我解决吗?我试图用谷歌搜索这个问题,但没有解决方案.这似乎是一个尚未解决的新问题.非常感谢.

推荐答案

Google gave update for the Google ads so if you update your Admob library in gradle then you need to add this in your manifest.

<manifest>
   <application>
      <!-- TODO: Replace with your real AdMob app ID -->
      <meta-data
          android:name="com.google.android.gms.ads.APPLICATION_ID"
          android:value="ca-app-pub-################~##########"/>
  </application>
</manifest>

Kotlin相关问答推荐

在Kotlin中可以连接两个范围吗?

调用即发即忘方法--哪个作用域?

如何在Kotlin中为接受varargs的函数添加带有默认值的新参数?

Kotlin:将泛型添加到列表任何>

如何在 Kotlin 中初始化 Short 数组?

为什么 Kotlin main 函数需要 @JVMStatic 注解?

Kotlin - 如何避免在密封类的 when() 语句中转换第二个变量

在协程上下文中重新抛出异常

有什么方法可以要求在 kotlin 中的类型参数上进行注释?

kotlin 父类具有依赖于抽象变量的变量

通用接口继承

Kotlin 日期格式从一种更改为另一种

Kotlin 有垃圾收集器吗?如果是这样,它基于哪种算法?

Kotlin:泛型、反射以及类型 T 和 T:Any 之间的区别

kotlin,如何从函数返回类类型

Kotlin内联扩展属性

Kotlin suspend fun

创建Spring和#180的实例;Kotlin中的参数化类型引用

接口中的属性不能有支持字段

IllegalStateException:function = , count = 3, index = 3