问题
Launching lib/main.dart on sdk gphone x86 arm in debug mode... Running Gradle task 'assembleDebug'... ✓ Built build/app/outputs/flutter-apk/app-debug.apk. Installing build/app/outputs/flutter-apk/app.apk... E/AndroidRuntime(11877): FATAL EXCEPTION: main E/AndroidRuntime(11877): Process: com.example.truthfxac, PID: 11877 E/AndroidRuntime(11877): java.lang.RuntimeException: Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.IllegalStateException: E/AndroidRuntime(11877): E/AndroidRuntime(11877): ****************************************************************************** E/AndroidRuntime(11877): * The Google Mobile Ads SDK was initialized incorrectly. AdMob publishers * E/AndroidRuntime(11877): * should follow the instructions here: * E/AndroidRuntime(11877): * https://googlemobileadssdk.page.link/admob-android-update-manifest * E/AndroidRuntime(11877): * to add a valid App ID inside the AndroidManifest. * E/AndroidRuntime(11877): * Google Ad Manager publishers should follow instructions here: * E/AndroidRuntime(11877): * https://googlemobileadssdk.page.link/ad-manager-android-update-manifest. * E/AndroidRuntime(11877): ****************************************************************************** E/AndroidRuntime(11877): E/AndroidRuntime(11877): E/AndroidRuntime(11877): at android.app.ActivityThread.installProvider(ActivityThread.java:7244) E/AndroidRuntime(11877): at android.app.ActivityThread.installContentProviders(ActivityThread.java:6780) E/AndroidRuntime(11877): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6697) E/AndroidRuntime(11877): at android.app.ActivityThread.access$1300(ActivityThread.java:237) E/AndroidRuntime(11877): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913) E/AndroidRuntime(11877): at android.os.Handler.dispatchMessage(Handler.java:106) E/AndroidRuntime(11877): at android.os.Looper.loop(Looper.java:223) E/AndroidRuntime(11877): at android.app.ActivityThread.main(ActivityThread.java:7656) E/AndroidRuntime(11877): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(11877): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) E/AndroidRuntime(11877): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) E/AndroidRuntime(11877): Caused by: java.lang.IllegalStateException: E/AndroidRuntime(11877): E/AndroidRuntime(11877): ****************************************************************************** E/AndroidRuntime(11877): * The Google Mobile Ads SDK was initialized incorrectly. AdMob publishers * E/AndroidRuntime(11877): * should follow the instructions here: * E/AndroidRuntime(11877): * https://googlemobileadssdk.page.link/admob-android-update-manifest * E/AndroidRuntime(11877): * to add a valid App ID inside the AndroidManifest. * E/AndroidRuntime(11877): * Google Ad Manager publishers should follow instructions here: * E/AndroidRuntime(11877): * https://googlemobileadssdk.page.link/ad-manager-android-update-manifest. * E/AndroidRuntime(11877): ****************************************************************************** E/AndroidRuntime(11877): E/AndroidRuntime(11877): E/AndroidRuntime(11877): at com.google.android.gms.internal.ads.zzzi.attachInfo(com.google.android.gms:play-services-ads-lite@@19.4.0:33) E/AndroidRuntime(11877): at com.google.android.gms.ads.MobileAdsInitProvider.attachInfo(com.google.android.gms:play-services-ads-lite@@19.4.0:3) E/AndroidRuntime(11877): at android.app.ActivityThread.installProvider(ActivityThread.java:7239) E/AndroidRuntime(11877): ... 10 more
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.name">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="Truthfx Academy"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.MyApplication">
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="jhhjjhkjkjkjhkjkjjhkjhkjhkjhkjkj"/>
</application>
回答1:
Replace <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="jhhjjhkjkjkjhkjkjjhkjhkjhkjhkjkj"/>
With this
<!-- Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
If you are using real ads in app use your app id instead
来源:https://stackoverflow.com/questions/65368880/the-google-mobile-ads-sdk-was-initialized-incorrectly-admob-publishers-should-f