Я создал тестовое приложение для рекламы, и оно работало там, но в моем основном проекте приложения тот же код вызывает сбой приложения
Тот же код в новом проекте Работает нормально, но в моем существующем проекте это вызывает сбой, пожалуйста, помогите мне.
Спасибо
Файл манифеста
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="@string/testAppID"/>
</activity>
Мой код MainActivity
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//testAppID = sample ID provided by admob
MobileAds.initialize(this, "@strings/testAppID");
mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
}
Erros:
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: to add a valid *
* App ID inside the AndroidManifest. Google Ad Manager publishers should *
* follow instructions here: *
******************************************************************************
at android.app.ActivityThread.installProvider(ActivityThread.java:7192)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6727)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6618)
at android.app.ActivityThread.access$2000(ActivityThread.java:268)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1995)
at android.os.Handler.dispatchMessage(Handler.java:109)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:7539)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958)
Caused by: java.lang.IllegalStateException:
******************************************************************************
* The Google Mobile Ads SDK was initialized incorrectly. AdMob publishers *
* should follow the instructions here: to add a valid *
* App ID inside the AndroidManifest. Google Ad Manager publishers should *
* follow instructions here: *
******************************************************************************
at com.google.android.gms.internal.ads.zzabg.attachInfo(Unknown Source:16)
at com.google.android.gms.ads.MobileAdsInitProvider.attachInfo(Unknown Source:3)
at android.app.ActivityThread.installProvider(ActivityThread.java:7187)
... 10 more