question

venta7 avatar image
venta7 asked

Ad failed to load due to invalid Auto Ad Size parameters

Hi, I have problems displaying ads - the warning message from the log is: "Ad failed to load. Code: REQUEST_ERROR, Message: Ad request failed due to invalid Auto Ad Size parameters." My layout is as follows: and MainActivity: public class MainActivity extends Activity implements TabListener, AdListener { private static final String APP_KEY = "my_app_key"; private AdLayout adView; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_grid); grid = (GridView) findViewById(R.id.grid); AdRegistration.setAppKey(APP_KEY); adView = (AdLayout) findViewById(R.id.adview); adView.setListener(this); adView.loadAd(new AdTargetingOptions()); .... rest of the code is omitted } How can I fix this? Thank you P.S. The buttons Ignore and IgnoreAll of the Spell Check option provided when posting a new message don't work. I got the message that the session was expired. Very frustrated.
mobile ads
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi venta7, I am able to launch the test ad by using your layout and code. public class AdTestActivity extends Activity implements AdListener { private static final String APP_KEY = "sample-app-v1_pub-2"; private AdLayout adView; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_grid); AdRegistration.setAppKey(APP_KEY); AdRegistration.enableTesting(true); adView = (AdLayout) findViewById(R.id.adview); adView.setListener(this); adView.loadAd(new AdTargetingOptions()); } @Override public void onAdLoaded(AdLayout adLayout, AdProperties adProperties) { Log.w("AdTestActivity","Ad Loaded"); } @Override public void onAdExpanded(AdLayout adLayout) { } @Override public void onAdCollapsed(AdLayout adLayout) { } @Override public void onAdFailedToLoad(AdLayout adLayout, AdError adError) { Log.w("AdTestActivity", "Ad failed to load. Code: " + adError.getCode() + ", Message: " + adError.getMessage()); } Though ad is not displayed due to inappropriate layout settings. Once I removed the GridView from the layout I can see the ad in the screen also. I did not receive any REQUEST_ERROR so far. There are two things left for you. 1. Please try loading test ad ( test app key is provided in the sample shipped with sdk) and see. 2. Can you please make a complete sample app put the project as zip in a pubic shared storage and share the url with me. Thanks.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

venta7 avatar image
venta7 answered
EDIT: The message was duplicated, sorry. Message was edited by: venta7
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

venta7 avatar image
venta7 answered
Hi, Thank you for trying to help me to resolve this issue that I'm having! I've removed the grid and tried using the app_key from the Amazon's SampleAd app but with no success of displaying ads again. It returns the same warning message in the logcat. Here is the link of my sample app and the code I'm using: https://drive.google.com/file/d/0B310g3_96AgDUUJKNUZxTmVjUE0/edit?usp=sharing Thank you again! venny
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Venta7, Please make below changes in your app. onCreate()-> AdRegistration.enableLogging(true); AdRegistration.enableTesting(true); Activity Grid xml You can replace the app id with the actual one and remove above two lines from onCreate() to see the real ads. Thanks.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

venta7 avatar image
venta7 answered
Hi Sujoy, After few hours trying to eliminate the issue I've found out that these lines of code in my layout xml file were causing my headaches: android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" These are generated automatically from ADT when create a new project and I left them there. I was testing the app on a phone and probably that is why it was failing to load the ads due auto ad sizing. I've also add this line to my layout xml, not sure if it helps at all though: xmlns:Amazon=" http://schemas.android.com/apk/lib/com.amazon.device.ads" and in onCreate() I've initialized the adview and register ad before anything else, didn't try to see if I move the initialization down the list will work also. Tried to place the ad below the grid, but that crash the app and return a ClassCastException that GridView cannot be cast to com.amazon.device.ads.AdLayout so I didn't dig any further and left the ad above the grid. Thank you for your help!
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.