我有一个Flutter应用程序,我想向其中添加Admob, 但是每次我收到此错误时:(我正在使用测试appId)
I/FA ( 3373): App measurement is starting up, version: 12451
I/FA ( 3373): To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
I/FA ( 3373): To enable faster debug mode event logging run:
I/FA ( 3373): adb shell setprop debug.firebase.analytics.app com.example.testapp
E/FA ( 3373): Missing google_app_id. Firebase Analytics disabled.
E/FA ( 3373): Uploading is not possible. App measurement disabled
I/cr_LibraryLoader( 3373): Time to load native libraries: 14 ms (timestamps 7792-7806)
I/chromium( 3373): [INFO:library_loader_hooks.cc(136)] Chromium logging enabled: level = 0, default verbosity = 0
I/cr_LibraryLoader( 3373): Expected native library version number "61.0.3163.98", actual native library version number "61.0.3163.98"
W/Ads ( 3373): There was a problem getting an ad response. ErrorCode: 0
W/Ads ( 3373): Failed to load ad: 0
W/flutter ( 3373): onAdFailedToLoad: 0
I/flutter ( 3373): Banner event is MobileAdEvent.failedToLoad
D/EGL_emulation( 3373): eglMakeCurrent: 0xaa705a20: ver 3 0 (tinfo 0xaa703610)
I/FA ( 3373): Tag Manager is not found and thus will not be used
E/FA ( 3373): Missing google_app_id. Firebase Analytics disabled.
我尝试了不同的解决方案,但所有解决方案均以上述错误结束。
我尝试了以下版本:0.9.0 + 3,0.7.0,0.5.5
这是我的代码:
AndroidManifest.xml:
<application
android:name="io.flutter.app.FlutterApplication"
android:label="testapp"
android:icon="@mipmap/ic_launcher">
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713"/>
</application>
Info.plist
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-3940256099942544~1458002511</string>
这是我的main.dart:
import 'package:flutter/material.dart';
import 'package:firebase_admob/firebase_admob.dart';
void main() {
runApp(new MaterialApp(
title: "NewApp",
home: new MyApp(),
));
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
FirebaseAdMob.instance
.initialize(appId: "ca-app-pub-3940256099942544~3347511713")
.then((response) {
myBanner
..load()
..show();
});
return new Scaffold(
appBar: new AppBar(
title: new Text("New App"),
),
body: new Center(
child: new RaisedButton(
child: new Text("data"),
onPressed: () {},
),
),
);
}
}
MobileAdTargetingInfo targetingInfo = MobileAdTargetingInfo(
keywords: <String>['demoapp', 'nice apps'],
contentUrl: "http:///www.google.com",
birthday: DateTime.now(),
childDirected: false,
designedForFamilies: false,
gender: MobileAdGender.male,
testDevices: <String>[]);
BannerAd myBanner = BannerAd(
adUnitId: BannerAd.testAdUnitId,
size: AdSize.smartBanner,
targetingInfo: targetingInfo,
listener: (MobileAdEvent event) {
print('Banner event is $event');
});
请帮助我。 任何解决方案都会有所帮助,谢谢。