Marian Klühspies
Marian Klühspies

Reputation: 17627

Amazon Mobile Ads API issue with layout size

I want to switch from Admob to Amazon Ads, so I have basically everything done which is described in the official guide.

https://developer.amazon.com/sdk/mobileads/quick-start.html

  1. Replaced the admob xml layout with the amazon one
  2. Included xmlns namespace in parent layout
  3. Set all permissions manifest
  4. Set AdActivity in manifest
  5. Set Application Key
  6. Set AdTargetingOptions

The Ads are not showing off, because they seem to determine the wrong size.

This is the log

07-29 10:03:14.948  30966-30966/de.android.contacts D/AmazonMobileAds Configuration: Setting country configuration to United States.
07-29 10:03:14.948  30966-30966/de.android.contacts D/AmazonMobileAds Configuration: Country code set to us
07-29 10:03:14.948  30966-30966/de.android.contacts D/AmazonMobileAds Configuration: Setting configuration endpoints to North America.
07-29 10:03:14.948  30966-30966/de.android.contacts D/AmazonMobileAds Configuration: Region set to na
07-29 10:03:18.623  31130-31134/com.rectangularsoftware.stackanywhere D/dalvikvm: Debugger has detached; object registry had 1 entries
07-29 10:03:18.668  30966-30966/de.android.contacts D/AmazonMobileAds AdLayout: Ad size to be determined automatically.
07-29 10:03:34.558    2236-2318/system_process D/lights: set_light_buttons off
07-29 10:03:38.668  30966-31146/de.android.contacts E/AmazonMobileAds AdLayout: Can't load an ad because the view size cannot be determined.
07-29 10:03:38.668  30966-31146/de.android.contacts D/AmazonMobileAds AdController: adFailed
07-29 10:03:38.673  30966-30966/de.android.contacts D/AmazonMobileAds AdController: Default ad listener called - Ad Failed to Load. Error code: REQUEST_ERROR, Error Message: Can't load an ad because the view size cannot be determined.

The country code is also wrong, it should be Germany in my case.

What could cause this issue?

Upvotes: 0

Views: 782

Answers (2)

M Granja
M Granja

Reputation: 865

You need to add an Amazon:adSize attribute in your com.amazon.device.ads.AdLayout. You also need to add this schema to the parent LinearLayout or RelativeLayout of your xml file:

xmlns:Amazon="http://schemas.android.com/apk/lib/com.amazon.device.ads" or it won't recognize the Amazon:adSize attribute.

More info on sizes available here.

Upvotes: 1

Mike Hines
Mike Hines

Reputation: 196

Did you set the adSize attribute?

You also need to set layout_width and layout_height to match the adSize attribute.

<com.amazon.device.ads.AdLayout
        android:id="@+id/adview"
        Amazon:adSize="1024x50"
        android:layout_width="1024dp"
        android:layout_height="50dp"/>

If you want to have your ads AutoSize, you can do this:

<com.amazon.device.ads.AdLayout  
    android:id="@+id/adview" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"/>

If that doesn't help, review this documentation and see if that helps.

Upvotes: 0

Related Questions