Use RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("289.......E6") to get test ads on this device

2,120

Solution

The way to solve it is to update RequestConfiguration with the testDeviceIds

String version;
  List<String> testDeviceIds = ['289C....E6'];

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  timeDilation = 1;
  PackageInfo packageInfo = await PackageInfo.fromPlatform();
  version = packageInfo.version;
  MobileAds.instance.initialize();

  // thing to add
  RequestConfiguration configuration =
       RequestConfiguration(testDeviceIds: testDeviceIds);
  MobileAds.instance.updateRequestConfiguration(configuration);


  await Firebase.initializeApp();
  runApp(MyApp());
}

How to get TestDeviceIDs

If you want to test ads in your app as you're developing.

  • Load your ads-integrated app and make an ad request.
  • Check the logcat output for a message that looks like the one below, which shows you your device ID and how to add it as a test device:

Use RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("289.......E6") to get test ads on this device.

  • Add the device ID that your logcat gave you in the terminal, and use it as testDeviceId
Share:
2,120
DIVYANSHU SAHU
Author by

DIVYANSHU SAHU

I'm a Freelance Flutter Developer.

Updated on December 31, 2022

Comments