Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio: Cannot resolve symbol ‘RequestConfiguration’

Tags:

android

admob

I am modifying an android app, which used to work, but the test ad is no longer loaded and in the Android Studio log I see:

Use RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("8B…D76C") to get test ads on this device.

I tried to add that to the code, but I get a “Cannot resolve symbol ‘RequestConfiguration’. Unfortunately Android Studio is not suggesting what's the package which needs to be imported.

This is how the code look after adding the requested line.

RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("device_id_3");

AdRequest adRequest = new AdRequest.Builder()
      // Add a test device to show Test Ads
      .addTestDevice(“device_id_1") 
      .addTestDevice("device_id_2")
      .addTestDevice("device_id_3") 
      .build();

// Load ads into Banner Ads
adView.loadAd(adRequest);
like image 594
P.Zaccaria Avatar asked Oct 21 '25 05:10

P.Zaccaria


1 Answers

Firebase is not needed, if you check AdMob documentation: https://developers.google.com/admob/android/test-ads#enable_test_devices , you will need to add following code instead of what the suggestion you see in the log cat:

List<String> testDeviceIds = Arrays.asList("<<< copy the device ID from logcat here >>>");
RequestConfiguration configuration =
    new RequestConfiguration.Builder().setTestDeviceIds(testDeviceIds).build();
MobileAds.setRequestConfiguration(configuration);
like image 137
tariq101 Avatar answered Oct 23 '25 21:10

tariq101



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!