question

singletechgames avatar image
singletechgames asked

No Ads Loading

Guys, I can't implement the ads cause i'm getting the error : "Can't load an ad because layout parameters are blank. Use setLayoutParams() to specify dimensions for this AdLayout." I'm using the LibGDX Engine This is my code in Android: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Create the layout RelativeLayout layout = new RelativeLayout(this); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); //My Game AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); View gameView = initializeForView(new MyGame(), config); AdRegistration.setAppKey("MY_KEY"); AdLayout adView = new AdLayout(this, AdSize.SIZE_600x90); adView.loadAd(new AdTargetingOptions()); layout.addView(gameView); RelativeLayout.LayoutParams adParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); adParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); adParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT); layout.addView(adView, adParams); setContentView(layout); } Please Help! :S
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.

singletechgames avatar image
singletechgames answered
I could repair the no layout parameter error, but now i have this error: "Default ad listener called - Ad Failed to Load. Error code: NO_FILL, Error Message: Server Message: DISABLED_APP. Try again in 30 seconds" Since yesterday, it's a server error, do I need to do something else, I'm using the amazon key
10 |5000

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

vintral avatar image
vintral answered
How did you get around the setLayoutParams error? I'm just curious because I'm stuck with that and can't seem to find a way to get that error to go away.
10 |5000

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

iDevGuy avatar image
iDevGuy answered
How did you fix the no layout params error? I am creating my ad view in code and setting the layout parameters, I don't see where the issue is.
10 |5000

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

iDevGuy avatar image
iDevGuy answered
Actually I may have figured it out. For me I was calling adView.loadAd(new AdTargetingOptions()) before adding the view to my layout. I think somehow the async task was finishing before the layout was loaded, meaning that layout parameters weren't set. Seems to be working for me.
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 Singletechgames, The issue you are facing because you have not set width and height of the AdLayout instance which is basically a FrameLayout. You have to set it explicitly. From xml we do it this way, Pragmatically, you can do this way. LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); adView.setLayoutParams(lp); Are you still facing "DISABLED_APP"? It might take some time after you register the app in distribution portal.
10 |5000

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

singletechgames avatar image
singletechgames answered
It was a little tricky but i'm using this code instead of amazon's guide: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Create the layout RelativeLayout layout = new RelativeLayout(this); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); //My Game AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); View gameView = initializeForView(new MyGame(), config); AdRegistration.setAppKey("MY_KEY"); AdLayout adView = new AdLayout(this, AdSize.SIZE_600x90); adView.loadAd(new AdTargetingOptions()); layout.addView(gameView); ViewGroup.LayoutParams adParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); ((LayoutParams) adParams).addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); ((LayoutParams) adParams).addRule(RelativeLayout.ALIGN_PARENT_LEFT); adView.setLayoutParams(adParams); adView.loadAd(new AdTargetingOptions()); // async task to retrieve an ad layout.addView(adView); setContentView(layout); } The DISABLED_APP problem was because i didn't fill the tax information, i'm showing ads right now, the only problem now is I can't put the ads at bottom left of the screen, it always shows middle bottom of the screen. I solved the loading problem too, you can read that in my blog (it's in spanish) http://singletechgames.com/ Message was edited by: singletechgames
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 Singletechgames, To fix the ad to bottom left of the screen can you try this? FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(600, 90); adView.setLayoutParams(lp); Instead of, ViewGroup.LayoutParams adParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); ((LayoutParams) adParams).addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); ((LayoutParams) adParams).addRule(RelativeLayout.ALIGN_PARENT_LEFT); adView.setLayoutParams(adParams);
10 |5000

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