gpt4 book ai didi

flutter - 如何将Google admob与Flutter项目集成在一起?

转载 作者:行者123 更新时间:2023-12-03 03:39:57 33 4
gpt4 key购买 nike

如何与带有flutter应用程序的Admob集成?

实际上,我想在应用程序的底部显示Google Ads,这就是为什么我浏览它并得到tutorial并跟随其后的原因,但不知道为什么它无法正常工作.. !!!
遇到问题,我无法捕获,
我搜索了此问题,但找不到任何解决方案

 Widget build(BuildContext context) {
FirebaseAdMob.instance.initialize(appId: "ca-app-pub-3280358404648281~7983595363");
myBanner..load()..show();
return Scaffold(
.....
);
}
}

MobileAdTargetingInfo targetingInfo = MobileAdTargetingInfo(
keywords: <String>['game', 'babilok'],
contentUrl: 'https://flutter.io',
birthday: DateTime.now(), //deprecated
childDirected: false,
designedForFamilies: false, //deprecated
gender: MobileAdGender.male, // or MobileAdGender.female, MobileAdGender.unknown (deprecated)
testDevices: <String>[], // Android emulators are considered test devices
);


BannerAd myBanner = BannerAd(
// Replace the testAdUnitId with an ad unit id from the AdMob dash.
// https://developers.google.com/admob/android/test-ads
// https://developers.google.com/admob/ios/test-ads
adUnitId: "ca-app-pub-3280358404648281/6455246498",
size: AdSize.smartBanner,
targetingInfo: targetingInfo,
listener: (MobileAdEvent event) {
print("BannerAd event is $event");
},
);

AndroidManifest.xml
<manifest 
<application
<activity
....
</activity>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3280358404648281~*********"/>
<meta-data
android:name="com.google.android.gms.ads.AD_MANAGER_APP"
android:value="true"/>
</application>
</manifest>

控制台日志:
D/DynamitePackage( 3049): Instantiating com.google.android.gms.ads.ChimeraMobileAdsSettingManagerCreatorImpl

I/WebViewFactory( 3049): Loading com.google.android.webview version 76.0.3809.132 (code 380913205)

D/ResourcesManager( 3049): creating new AssetManager and set to /data/app/com.google.android.webview-2/base.apk

I/cr_LibraryLoader( 3049): Time to load native libraries: 2 ms (timestamps 3902-3904)

I/chromium( 3049): [INFO:library_loader_hooks.cc(51)] Chromium logging enabled: level = 0, default verbosity = 0

I/cr_LibraryLoader( 3049): Expected native library version number "76.0.3809.132", actual native library version number "76.0.3809.132"

I/cr_BrowserStartup( 3049): Initializing chromium process, singleProcess=true

D/ConnectivityManager.CallbackHandler( 3049): CM callback handler got msg 524290

E/libEGL ( 3049): validate_display:255 error 3008 (EGL_BAD_DISPLAY)

E/chromium( 3049): [ERROR:gl_surface_egl.cc(343)] eglChooseConfig failed with error EGL_BAD_ATTRIBUTE

W/cr_media( 3049): Requires BLUETOOTH permission

D/DynamitePackage( 3049): Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl

E/chromium( 3049): [ERROR:gl_surface_egl.cc(343)] eglChooseConfig failed with error EGL_BAD_ATTRIBUTE

I/Ads ( 3049): Use AdRequest.Builder.addTestDevice("C93E3D5EBB200061812734814B28CC4D") to get test ads on this device.

W/AudioCapabilities( 3049): Unsupported mime audio/mpeg-L1

W/AudioCapabilities( 3049): Unsupported mime audio/mpeg-L2

W/AudioCapabilities( 3049): Unsupported mime audio/x-ms-wma

W/AudioCapabilities( 3049): Unsupported mime audio/x-ima

W/VideoCapabilities( 3049): Unrecognized profile/level 32768/2 for video/mp4v-es

W/VideoCapabilities( 3049): Unsupported mime video/wvc1

W/VideoCapabilities( 3049): Unsupported mime video/x-ms-wmv

W/VideoCapabilities( 3049): Unrecognized profile/level 32768/2 for video/mp4v-es

W/VideoCapabilities( 3049): Unsupported mime video/wvc1

W/VideoCapabilities( 3049): Unsupported mime video/x-ms-wmv

W/VideoCapabilities( 3049): Unsupported mime video/x-ms-wmv7

W/VideoCapabilities( 3049): Unsupported mime video/x-ms-wmv8

W/VideoCapabilities( 3049): Unsupported mime video/sorenson

W/VideoCapabilities( 3049): Unsupported mime video/mp43

W/VideoCapabilities( 3049): Unrecognized profile/level 32768/2 for video/mp4v-es

I/VideoCapabilities( 3049): Unsupported profile 4 for video/mp4v-es

W/AudioCapabilities( 3049): Unsupported mime audio/ac3

W/art ( 3049): mismatched stack depths (depth=1, incoming depth=2)

I/DynamiteModule( 3049): Considering local module com.google.android.gms.ads.dynamite:0 and remote module com.google.android.gms.ads.dynamite:20461

I/DynamiteModule( 3049): Selected remote version of com.google.android.gms.ads.dynamite, version >= 20461

D/ConnectivityManager.CallbackHandler( 3049): CM callback handler got msg 524290

E/IMGSRV ( 3049): :0: ComputeFrameBufferCompleteness: Switching psTex 0x8c777840 to XBGR

E/IMGSRV ( 3049): :0: ComputeFrameBufferCompleteness: Switching psLevel 0x9f1e0800 to XBGR

E/IMGSRV ( 3049): :0: ComputeFrameBufferCompleteness: Switching psTex 0x8c7778e0 to XBGR

E/IMGSRV ( 3049): :0: ComputeFrameBufferCompleteness: Switching psLevel 0x8c74f000 to XBGR
Syncing files to device GT I9500... 3,800ms (!)
E/FA ( 3049): GoogleService failed to initialize, status: 10, Missing google app id value from from string resources with name google_app_id.
W/art ( 3049): Suspending all threads took: 9.252ms

🔥 To hot reload changes while running, press "r". To hot restart (and rebuild state), press "R".
An Observatory debugger and profiler on GT I9500 is available at: //http://127.0.0.1:65429/WyO_d_pLZrY=/
For a more detailed help message, press "h". To detach, press "d"; to quit, press "q".
I/FA ( 3049): App measurement is starting up, version: 14711
I/FA ( 3049): To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
I/FA ( 3049): To enable faster debug mode event logging run:
I/FA ( 3049): adb shell setprop debug.firebase.analytics.app com.example.google_fire_admob
E/FA ( 3049): Missing google_app_id. Firebase Analytics disabled.

E/FA ( 3049): Uploading is not possible. App measurement disabled
W/Ads ( 3049): Not retrying to fetch app settings
W/flutter ( 3049): onAdFailedToLoad: 0
I/Ads ( 3049): Ad failed to load : 0
I/flutter ( 3049): BannerAd event is MobileAdEvent.failedToLoad
I/FA ( 3049): Tag Manager is not found and thus will not be used
E/FA ( 3049): Missing google_app_id. Firebase Analytics disabled.
I/Timeline( 3049): Timeline: Activity_idle id: android.os.BinderProxy@2669e1b1 time:9049317
E/FA ( 3049): Missing google_app_id. Firebase Analytics disabled.
V/ActivityThread( 3049): updateVisibility : ActivityRecord{50bb604 token=android.os.BinderProxy@2669e1b1 {com.example.google_fire_admob/com.example.google_fire_admob.MainActivity}} show : true

最佳答案

您需要添加google-service.json。如果您不知道如何找到此JSON。请按照以下步骤操作;

  • 从firebase.google.com创建firebase应用程序
  • 单击屏幕左侧的设置按钮>项目设置
  • 添加应用程序,然后您可以下载google-service.json

  • 您可以从 here找到更多信息

    最后,请使用测试广告单元ID进行测试。 Admob无法快速填写新的单位ID。

    关于flutter - 如何将Google admob与Flutter项目集成在一起?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57687796/

    33 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com