googleads-mobile-android-examples icon indicating copy to clipboard operation
googleads-mobile-android-examples copied to clipboard

AdaptiveBanner: AdSize "720x54_as" always ends up to error code 1 "Error building request URL."

Open milekey opened this issue 4 years ago • 0 comments

Based on the AdaptiveBannerExample https://github.com/googleads/googleads-mobile-android-examples/tree/master/java/admob/AdaptiveBannerExample I just added Immersive mode function:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    hideSystemUI();

    setContentView(R.layout.activity_main);

    // Initialize the Mobile Ads SDK.
    ...
}

private void hideSystemUI() {
    Window window = getWindow();
    View decorView = window.getDecorView();
    WindowInsetsController windowInsetsController = decorView.getWindowInsetsController();
    windowInsetsController.setSystemBarsBehavior(
            WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
    );
    windowInsetsController.hide(
            WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars()
    );

    window.setDecorFitsSystemWindows(false);
}

There is an error code 1 "Error building request URL." when it is in landscape mode on phone device (width: 720dp).

2021-12-15 16:06:47.865 22439-22439/com.adaptivebanner E/MainActivity: onAdFailedToLoad
2021-12-15 16:06:47.866 22439-22439/com.adaptivebanner E/MainActivity: {
  "Code": 1,
  "Message": "Error building request URL.",
  "Domain": "com.google.android.gms.ads",
  "Cause": "null",
  "Response Info": {
    "Response ID": "null",
    "Mediation Adapter Class Name": "",
    "Adapter Responses": []
  }
}

When in portrait mode on phone or in landscape mode without immersive (width: 672dp) on phone, or in either modes on tablet, there are no problems. So it should not be APPLICATION_ID or AD_UNIT_ID problem. (I'm using Google's test IDs for this testing purpose.)

I checked the AdSize by AdSize#toString(). It outputs "720x54_as" when the error occurs.

And I also tested on tablet devices (emulator Nexus7 and Nexus9 with API-31 images). Just ignoring the AdSize returned by AdSize#getCurrentOrientationAnchoredAdaptiveBannerAdSize, I manually made 720x54 sized AdSize instance by "new AdSize(720, 54)", and used it on tablet devices in landscape mode. This time it ended up to error code 3:

2021-12-14 22:28:27.750 7377-7377/com.adaptivebanner E/MainActivity: onAdFailedToLoad
2021-12-14 22:28:27.752 7377-7377/com.adaptivebanner E/MainActivity: {
  "Code": 3,
  "Message": "No ad config.",
  "Domain": "com.google.android.gms.ads",
  "Cause": "null",
  "Response Info": {
    "Response ID": "null",
    "Mediation Adapter Class Name": "",
    "Adapter Responses": []
  }
}

I think ignoring AdSize#getCurrentOrientationAnchoredAdaptiveBannerAdSize and manually setting AdSize should not be recommended. So this error code 3 is ok. But in the first place, what is the AdSize "720x54_as" which is returned by AdSize#getCurrentOrientationAnchoredAdaptiveBannerAdSize, and why it should end up to error code 1?

Same thing happens in immersive landscape mode on emulator Pixel 4 (API-31) device, whose AdSize is "781x59_as".

Is an Adaptive banner not supposed to be used in immersive landscape mode?

milekey avatar Dec 15 '21 08:12 milekey