B4A Library Amazon Interstitial Library

First, a little plug for Amazon. I've had a lot of success in app development over the past 2 years, and over that time, Amazon has been my best source of monetization. I was fortunate to get in on the ground floor with their advertising when they first started in beta back at the end of 2012. I wanted to share an interstitial library that I developed to support these ads from Amazon. I have had a lot of interaction with the Amazon mobile ads team, and I can tell you that they are great to work with and they really listen to feedback.

Steps for implementation:

1) Set up a developer account with Amazon.
2) Add an app and make note of the App ID for use with the library. You don't have to publish it at this point to get the ID.
3) Download the SDK. Copy the amazon-ads jar file to your b4a libraries folder. Rename it to amazon-ads.jar.
4) Copy the library files attached to this post to your b4a libraries folder.
5) Implement the code in a similar manner as the attached example app.
6) Remember to add the following to your app manifest.

B4X:
AddApplicationText(<activity android:name="com.amazon.device.ads.AdActivity" android:configChanges="keyboardHidden|orientation|screenSize"/> )

The only drawback to Amazon is a much lower fill rate than Admob. That said, it's worth it. I handle this by preloading interstitials from Amazon and Mopub. When it's time to show an ad, I check if the Amazon interstitial is loaded. If it is, I show that. If it's not, I check to see if the mopub ad is loaded. If it is, then I show that one. You could do this with Admob, or any other interstitial provider.

If you want to use Amazon for banner ads, canalrun has already written a library for that. Again, I recommend trying Amazon first for banners, and if that fails, back fill with another network.

Updated 4/11/16 to support amazon-ads-5.7.1.1.
 

Attachments

  • screenshot.png
    screenshot.png
    103.9 KB · Views: 252
  • mwAmazonInterstitial.zip
    17.4 KB · Views: 173
Last edited:

susu

Well-Known Member
Licensed User
Longtime User
May I ask something off topic?

- In "More Apps" menu, I point to all my apps on Google Play, is it acceptable? Do I need to point to Amazon Store?

- I tried to publish my app on Amazon but its dashboard keep saying that my app is ringtone app (of cousre it's not) and it's not compatible with Amazon Fire devices. How do I fix it?

Thank you so much.
 

canalrun

Well-Known Member
Licensed User
Longtime User
May I ask something off topic?

- In "More Apps" menu, I point to all my apps on Google Play, is it acceptable? Do I need to point to Amazon Store?

- I tried to publish my app on Amazon but its dashboard keep saying that my app is ringtone app (of cousre it's not) and it's not compatible with Amazon Fire devices. How do I fix it?

Thank you so much.

For the ring tone question, I had the same issue. It is due to the fact that including the Phone library adds a permission that makes Amazon think your app is a ring tone app. Erel describes a Phone2 modification that does not include this permission:

http://www.b4x.com/android/forum/threads/new-amazon-fire.42190/#post-254700

For the first question, I think I read somewhere that Amazon requires you to point to Amazon's website for sales and downloads – I am not sure about this, though. What I do is use a Build Configuration Conditional Symbol to select either Google Play or Amazon in my "See more apps" menu. Yes, this means I now have different APK's for each site, but I hope it avoids future trouble.

Barry.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
It is due to the fact that including the Phone library adds a permission that makes Amazon think your app is a ring tone app. Erel describes a Phone2 modification that does not include this permission:
Not exactly. The Phone library doesn't add any permission automatically. Permissions are only added when you used object that require a specific permission. The issue here is that the Phone library includes code that interacts with the internal Ringtone API. Amazon scan your compiled code and rejects it because it sees this API. The solution is to delete the ringtone classes from Phone.jar.
 

Jack Cole

Well-Known Member
Licensed User
Longtime User
May I ask something off topic?

- In "More Apps" menu, I point to all my apps on Google Play, is it acceptable? Do I need to point to Amazon Store?

- I tried to publish my app on Amazon but its dashboard keep saying that my app is ringtone app (of cousre it's not) and it's not compatible with Amazon Fire devices. How do I fix it?

Thank you so much.

I think you can just ignore the whole ringtone thing.

Here is how I handle rating and more apps. Marketplace is set up as a global variable.

B4X:
Sub RateApp
        Dim market As Intent
        Select marketplace
            Case "Amazon" : uri="amzn://apps/android?p=mindware.minesweeper" 'for amazon
            Case "Google" : uri="market://details?id=mindware.minesweeper" 'for android market
        End Select
        market.Initialize(market.ACTION_VIEW,uri)
        StartActivity(market)   

End Sub
Sub MoreApps
    Dim market As Intent
    Select marketplace
        Case "Amazon" : uri="amzn://apps/android?s=Mindware Consulting, Inc"
        Case "Google" : uri="market://search?q=pub:Mindware Consulting, Inc" 'Mindware Consulting, Inc
    End Select
    market.Initialize(market.ACTION_VIEW,uri)
    StartActivity(market)   
End Sub
 

Gunther

Active Member
Licensed User
Longtime User
Hi Jack,

any way to check if the user has clickt on an Ad?

Thanks, Gunther
 

MarcoRome

Expert
Licensed User
Longtime User
Hi Jack and all.
I have this message when i try:
DISABLED_APP.

I read HERE this:

B4X:
INTERNAL_ERROR    Server Message: DISABLED_APP
The server has denied your ad request. If you have recently integrated ads
on this app for the first time then you may need to wait longer for your
registration information to process.

in based on your experience how long it takes to activate it ?
Thank you
Marco
 

MarcoRome

Expert
Licensed User
Longtime User
Hi Jack.
Amazon accepted some of my app on app amazon --> State "Active".
If I try banners work without problem ( library canalrun ) but if i use interstitial i receive random errors (in some cases DISABLED_APP in another NO RESULTS).
You write:
"2) Add an app and make note of the App ID for use with the library"
but i think it's Application key right?
again if i try with your license key (8e071cba925c448b999fa47243615a88) i have same result (in some cases DISABLED_APP in another NO RESULTS)
Where i wrong ? or maybe is library ?
Thank you
Marco
 
Last edited:

MarcoRome

Expert
Licensed User
Longtime User
also try with
"amazon-ads-5.4.46" as suggestion in your example and new amazon ads "amazon-ads-5.6.20.jar"
but same result
 

MarcoRome

Expert
Licensed User
Longtime User
Well... after some testing i came to the following conclusion:

1. The wrapper ( Thank you Jack ) work without problem
2. Amazon Interstitial work but only few country ( USA, UK, Spain, France, Japan, Italy ). I live in italy but anyway i have ever this message "Server Message: no results". But in magic mode if i change IP example US work 3 on 5.
3. Banner work ever without problem.

and so i think ( but it is only mythink ) it is too early to consider this type of advertising.
Anyway thank you for your library Jack
 

MarcoRome

Expert
Licensed User
Longtime User
Yes, it might just be your location that is keeping you from getting ad impressions.
Hi Jack.
Amazone answered me in this mode
"...
Hi Marco,

Could you please send us the full logcat of your attempt to display Amazon Mobile Ads?

Best regards,

Brian R.
Amazon Mobile App Distribution Support Team"

We have this possibility (full logcat ) with your library ?
Thanks
Marco
 

Feten7

Member
Licensed User
Hi all,

I have this problem when trying the interstitial program given by Jack.

java.lang.NoSuchMethodError: No direct method <init>(Landroid/app/Activity;)V in class Lcom/amazon/device/ads/InterstitialAd; or its super classes (declaration of 'com.amazon.device.ads.InterstitialAd' appears in /data/app/b4a.example-2/base.apk)

What seems strange is the file size. When adding Admobs ads, the sdk made a file much bigger. But this time the sdk is not included, just changed names and added to libraries, or i'm wrong? I guess the problem is the sdk. Now it is 5.7.1.1 and the library was made for 5.4.4.6

Can someone help me?

Thanks in advance
 

Feten7

Member
Licensed User
Thanks for the help but i've done that and it's in the libraries folder. I've checked that point a lot because it seems it can't find the SDK file. I don't have to add it in the IDE because the library refers to it, isn't it?

Have you, or anyone, been able to update the SDK file without problems?
 

Jack Cole

Well-Known Member
Licensed User
Longtime User
Yes, it works fine for me with the updated SDK. Just check the .xml file for the library. Scroll to the end. There will be a dependsOn section. The name shown there should be the same and the filename for the SDK .jar file (omitting the .jar).
 

Feten7

Member
Licensed User
upload_2016-4-9_18-49-54.png


This is what i have and, as you can see, it's ok. Maybe it can be the SDK I downloaded. Which is:
upload_2016-4-9_19-2-39.png


I downloaded from:

upload_2016-4-9_19-4-25.png


I'll keep on trying.

Thanks for your time!
 
Top