在手机上测试 Admob 时 DEVICE_ID_EMULATOR 和 TEST_EMULATOR 的区别

2022-01-12 00:00:00 android java libgdx admob

使用 TEST_EMULATOR 和 DEVICE_ID_EMULATOR 有什么区别?我想在我的手机上测试 admob 广告系统,NOT 在 PC 上的模拟器上.

AdRequest 广告 = 新 AdRequest.Builder()..addTestDevice(com.google.ads.AdRequest.TEST_EMULATOR)..addTestDevice("YOUR_HASHED_DEVICE_ID")..建造();AdRequest 广告 = 新 AdRequest.Builder()..addTestDevice(com.google.ads.AdRequest.DEVICE_ID_EMULATOR)..addTestDevice("YOUR_HASHED_DEVICE_ID")..建造();

解决方案

  1. 区别在于 com.google.ads.AdRequest.TEST_EMULATOR 指的是 old 旧版 admob 和 com.google.android.gms.ads.AdRequest.DEVICE_ID_EMULATOR 是 新 google play services 版本的 admob.这已经取代了旧的遗留 admob.显然,您现在应该只使用新的 admob,因为旧的 admob 已被弃用.

  2. 要在真实设备上测试 admob 广告,您需要获取移动设备 ID 哈希并将其放在此处:.addTestDevice("YOUR_HASHED_DEVICE_ID").Admob 在 logcat 中添加一个带有设备 id 的日志,看起来或多或少像这样:

<块引用>

05-20 20:27:20.888:I/Ads(32367):使用 AdRequest.Builder.addTestDevice("BANANANANANANANANANNANANANANANA") 在此设备上获取测试广告.

只需将其复制为 addTestDevice 方法中的参数即可.

What is the difference between using TEST_EMULATOR and DEVICE_ID_EMULATOR? I want to test the admob ad system on my mobile phones, NOT on an emulator on the PC.

AdRequest ad = new AdRequest.Builder().
 .addTestDevice(com.google.ads.AdRequest.TEST_EMULATOR).
 .addTestDevice("YOUR_HASHED_DEVICE_ID").
 .build();

AdRequest ad = new AdRequest.Builder().
 .addTestDevice(com.google.ads.AdRequest.DEVICE_ID_EMULATOR).
 .addTestDevice("YOUR_HASHED_DEVICE_ID").
 .build();

解决方案

  1. The difference is that com.google.ads.AdRequest.TEST_EMULATOR refers to the old legacy admob and com.google.android.gms.ads.AdRequest.DEVICE_ID_EMULATOR is the new google play services version of admob. This has replaced the old legacy admob. Obviously you should now only use the new admob as the old one is deprecated.

  2. To test admob ads on a real device you need to get the mobile device id hash and put it here: .addTestDevice("YOUR_HASHED_DEVICE_ID"). Admob adds a log with the device id in the logcat that looks more or less like this:

05-20 20:27:20.888: I/Ads(32367): Use AdRequest.Builder.addTestDevice("BANANANAANANANANANANNANANANANANA") to get test ads on this device.

Just copy this as a parameter in the addTestDevice method.

相关文章