Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Trying to configure Amazon Ads — Gideros Forum

Trying to configure Amazon Ads

flyhereflyhere Member
edited March 2014 in Plugins

I'm trying to follow Amazon instructions for implementing the Mobile Ads API, ran into a few issues/questions. Would appreciate all pointers. Anyone here implemented Amazon? I posted this in Amazon forum as well.

4 steps according to Amazon:
1. Incorporate the API into Your Project
2. Update the Android Manifest
3. Set Your Application Key
4. Add the Amazon Ad Layout to Your App

Steps 1 and 2 are automatic as I am using the Eclipse plugin, and it seems they completed OK

So I continued with step #3, Amazon says

public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

AdRegistration.setAppKey("0123456789ABCDEF0123456789ABCDEF");
}

I got an error "R cannot resolve to a variable", how do I fix this?
I commented out line // setContentView(mGLView);

The next error is AdRegistration cannot be resolved, and my appkey was not resolve either

Did I miss a step?

Then I did the next step and added, all the lines gave errors.

// Programmatically create the AmazonAdLayout
this.adView = new AdLayout(this);
LinearLayout layout = (LinearLayout) findViewById(R.id.mainLayout);
// Set the correct width and height of the ad
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
layout.addView(this.adView,lp);

this.adView.loadAd(new AdTargetingOptions()); // This AsyncTask retrieves an ad


Thanks in advance

Comments

  • SinisterSoftSinisterSoft Maintainer
    edited March 2014
    Why don't you use the ads lib in gideros labs? - it's great. I had amazon ads working really quickly - no problems.

    http://docs.giderosmobile.com/interface/ads
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • ar2rsawseenar2rsawseen Maintainer
    edited March 2014
    @flyhere yes xml layouting and programmatical layouting can be confusing (especially when mixed :) )

    Something like this should work (simply put it inside onCreate after
    GiderosApplication.onCreate(externalClasses);
    call):
    //set amazon api key
    AdRegistration.setAppKey("0123456789ABCDEF0123456789ABCDEF");
     
    //get main layout
    FrameLayout layout = (FrameLayout)getWindow().getDecorView();
    //create amazon banner view (with the size you need)
    AdLayout adView = new AdLayout(this, AdSize.SIZE_300x50);
    //add it to layout
    layout.addView(adView);
    //load an ad
    adView.loadAd(new AdTargetingOptions());
    Then if something is underlined as red, hover over it and eclipse should provide a solution (like importing missing package)

    Bonus content, positioning an ad:
    //create layout params
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
    				FrameLayout.LayoutParams.WRAP_CONTENT,
    				FrameLayout.LayoutParams.WRAP_CONTENT);
    //set positioning based on what you need
    //LEFT TOP will position add to left top corner
    //change to other values to change position
    params.gravity = Gravity.LEFT | Gravity.TOP;
     
    //apply params
    adView.setLayoutParams(params);
    But the easiest way to do it is of course using Ads Interface provided with Gideros Indie or Professional licenses :)

    Likes: SinisterSoft

    +1 -1 (+1 / -0 )Share on Facebook
  • Also, having access to labs also give you the new gaming lib - that in turn can get you some pretty good promotion on Amazon:

    https://developer.amazon.com/appsandservices/resources/promotional-tools/featured-developer-program#benefits

    This is worth more than the cost of the Indie licence imho. :)
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • @SinisterSoft: Yes, I do have the indie license.
    Thanks all. Yes, right after I posted the question, I downloaded and installed the Ads plugin last night. The docs for installing are easy to follow, the docs for using the plugin are a bit sparse. Will read up more tonight.
  • OK so I downloaded and installed the Ads plugin, and followed all the steps, , and spent the last 2 days trying to make it work. I must have missed something because the game works without the ads plugin, but with the plugin I get an error:
    Project has compilation errors

    I spent the last 2 days repeating all the steps but still has the same error. The only thing I found unusual is the gideros.jar file which gives me "Failed to loas Main-Class manifest attribute from ...\..\...\gideros.jar

    If I remove the ads, re-export from gideros and re-import into Eclipse, export from Eclipse is successful.

    Would appreciate all pointers. I know others have made it work so it must be me.

    Thanks
  • ar2rsawseenar2rsawseen Maintainer
    @flyhere what kind of compilation errors exactly?
    "Failed to loas Main-Class manifest attribute from" Is really unusual, anything else?

    And you can always send me a project to ar2rsawseen at gmail dot com to check out for you ;)
  • Eclipse just says compilation errors without giving any details. Will go through step by step one more time, if it still does not work will take up your offer. Thanks.
  • SinisterSoftSinisterSoft Maintainer
    edited March 2014
    I had errors until I turned off the auto-build option in eclipse. I then cleaned my project. Then it all cleared up - I think it's a problem with auto build order - no actual code error.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • @SinisterSoft: Thanks, will try that.
Sign In or Register to comment.