android 在Flutter中的Ad Mob的logcat中找不到测试设备ID,在哪里可以找到它?

gudnpqoy  于 2024-01-04  发布在  Android
关注(0)|答案(1)|浏览(186)

在Flutter中的广告Mob的logcat中找不到test device ID。在哪里可以找到它?我正在Android Studio中扫描Logcat,但它不在那里。
目前在main.dart中使用:

  1. MobileAds.instance.updateRequestConfiguration(
  2. RequestConfiguration(testDeviceIds: ['MY MISSING TEST ID']));

字符串
这也不是在控制台发送任何东西,也不是Logcat实际上给予我的测试ID,我需要使用的样本/测试广告从谷歌AdMob在我的Android Studio中的Flutter Android模拟器。
有人可以帮助我了解我需要做什么吗?请注意,该应用程序尚未发布,我只使用模拟器。
我在这里检查:testDeviceId's are not working in google-mobile-ads flutterHow can I get device ID for Admob
但不幸的是,没有运气。我确实在控制台日志中看到了这一点,不知道它们是否相关:

  1. I/Ads (29143): This request is sent from a test device.
  2. W/ConnectionStatusConfig(29143): Dynamic lookup for intent failed for action: com.google.android.gms.ads.service.CACHE
  3. W/ConnectionStatusConfig(29143): Dynamic lookup for intent failed for action: com.google.android.gms.ads.service.START


PS:也试过了,没有任何运气:

  1. void main() async {
  2. WidgetsFlutterBinding.ensureInitialized();
  3. MobileAds.instance.initialize();
  4. // thing to add
  5. RequestConfiguration configuration = RequestConfiguration(testDeviceIds: ['TEST_EMULATOR']);
  6. MobileAds.instance.updateRequestConfiguration(configuration);


这里是我的全部家园. dart 代码:

  1. late BannerAd _bannerAd;
  2. bool _isAdLoaded = false;
  3. @override
  4. void dispose() {
  5. _tabController.dispose();
  6. _bannerAd.dispose();
  7. super.dispose();
  8. }
  9. void _loadBannerAd() {
  10. debugPrint('Attempting to load Banner Ad...');
  11. _bannerAd = BannerAd(
  12. adUnitId: 'ca-app-pub-3940256099942544/6300978111', // Replace with your ad unit ID
  13. size: AdSize.banner,
  14. request: AdRequest(),
  15. listener: BannerAdListener(
  16. onAdLoaded: (ad) {
  17. debugPrint('Banner Ad loaded: $ad');
  18. setState(() {
  19. _isAdLoaded = true;
  20. });
  21. },
  22. onAdFailedToLoad: (ad, error) {
  23. debugPrint('Banner Ad failed to load: $ad, $error');
  24. ad.dispose();
  25. },
  26. ),
  27. );
  28. _bannerAd.load();
  29. }
  30. Widget _buildBannerAd() {
  31. debugPrint('Is Ad Loaded? $_isAdLoaded');
  32. return _isAdLoaded
  33. ? AdWidget(ad: _bannerAd)
  34. : SizedBox(height: 50); // Placeholder if ad is not loaded
  35. }
  36. @override
  37. void initState() {
  38. super.initState();
  39. _loadBannerAd();
  40. }


Main.dart:import 'package:google_移动的_ads/google_移动的_ads. dart';

  1. void main() async {
  2. WidgetsFlutterBinding.ensureInitialized();
  3. MobileAds.instance.initialize();
  4. /// run app etc.
  5. }

aiazj4mn

aiazj4mn1#

根据文档,您需要执行以下步骤:
1.使用带有ID的测试广告(即,对于Android为“ca-app-pub-3940256099942544/6300978111”)
1.请求加载广告
1.检查日志中是否有这样的消息:
I/Ads:使用RequestConfiguration.Builder .setTestDeviceIds(Arrays.asList(“33 BE 2250 B43518 CCDA 7 DE 426 D 04 EE 231”))
在这个设备上投放测试广告
1.你可能会有一个不同的设备ID,但采取该设备ID,并设置它使用:

  1. MobileAds.instance.updateRequestConfiguration(
  2. RequestConfiguration(testDeviceIds: ['33BE2250B43518CCDA7DE426D04EE231']));

字符串

您是否遵循了所有这些步骤?也许您没有提出广告请求?

此外,请注意,iOS模拟器和Android模拟设备会自动配置为测试设备,但您必须手动添加物理设备(您没有提到您正在测试的设备类型)。

展开查看全部

相关问题