## [0.10.2] AdMob support for Android!

bio1712
Citizen
Posts: 50
Joined: Wed Aug 19, 2015 4:13 pm
Location: Italy

### [0.10.2] AdMob support for Android!

Hi all.
As you may have noticed, the way to deploy Android apps has changed: the newest version of the official Android port doesen't use ant anymore, but uses the Gradle wrapper.
Therefore a new AdMob library is needed.

I want to thank Master Both, the author of this beautiful library for having let me use some of his code.

There is another reason I made this library: the functions are the same of the iOS library I have made before.

Let me show you the new module:

With this module is possible to request and display ads from LÖVE!
An AdMob account is needed in order to use this module.

I have added 9 functions and 5 callbacks:

string position : The position of the banner. Can be "top" or "bottom".
Initializes the banner ad without displaying it. This function may be fired only once.
The banner inizialized is a smart banner.
Displays the banner ad. This function may be fired after createBanner
Hides the banner ad. This function may be fired after createBanner
Requests an interstitial ad. This function should be called every time a new ad is needed.
Check if the interstitial ad previously requested is ready to be shown.

Returns:
Requests a rewarded video ad. This function should be called every time a new ad is needed.
Check if the rewarded video ad previously requested is ready to be shown.

Returns:
• love.interstitialClosed()
Fired when the user closes an interstitial ad.
• love.rewardUserWithReward(string rewardType,number rewardQuantity)
string rewardType : The type of the reward you set in your AdMob dashboard.
number rewardQuantity : The quantity of rewards you set in you AdMob dashboard.

Fired when a rewarded video ad successfully finishes playing.
Fired when a rewarded video ad is closed by the user.
This callback is fired even if the video has already finished.
Here is the repository of this library:
(LÖVE version: 0.10.2)

How to use:
In order to use this library you need to follow the instructions here.

Included in the source, there is an example game.love.
Screenshot_2017-08-05-11-21-15.png (25.67 KiB) Viewed 8310 times
Note: all the Ad-Unit IDs in the game.love are from this url.

greboide
Prole
Posts: 5
Joined: Mon Jul 31, 2017 6:40 am

### Re: [0.10.2] AdMob support for Android!

why dont you make a pull request to send this back to love main project, just curious, other than that nice work!

zorg
Party member
Posts: 2587
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

### Re: [0.10.2] AdMob support for Android!

greboide wrote:
Wed Aug 09, 2017 3:40 am
why dont you make a pull request to send this back to love main project, just curious, other than that nice work!
Because it would most likely not be incorporated, ever.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

yetneverdone
Party member
Posts: 325
Joined: Sat Sep 24, 2016 11:20 am
Contact:

### Re: [0.10.2] AdMob support for Android!

how is this different from this: https://bitbucket.org/npinochet/love-android-sdl2 ??

bio1712
Citizen
Posts: 50
Joined: Wed Aug 19, 2015 4:13 pm
Location: Italy

### Re: [0.10.2] AdMob support for Android!

yetneverdone wrote:
Wed Aug 09, 2017 6:59 am
how is this different from this: https://bitbucket.org/npinochet/love-android-sdl2 ??
The way of deploying it’s different, furthermore it doesn’t have rewarded videos and functions are called in a different way.
greboide wrote:
Wed Aug 09, 2017 3:40 am
why dont you make a pull request to send this back to love main project, just curious, other than that nice work!
Thank you!

yetneverdone
Party member
Posts: 325
Joined: Sat Sep 24, 2016 11:20 am
Contact:

### Re: [0.10.2] AdMob support for Android!

The way of deploying it’s different, furthermore it doesn’t have rewarded videos and functions are called in a different way.
Deploying? The link you provide for the instruction is the main wiki of master both's repo,which by the way, is very deprecated.

bio1712
Citizen
Posts: 50
Joined: Wed Aug 19, 2015 4:13 pm
Location: Italy

### Re: [0.10.2] AdMob support for Android!

yetneverdone wrote:
Wed Aug 09, 2017 2:03 pm
The way of deploying it’s different, furthermore it doesn’t have rewarded videos and functions are called in a different way.
Deploying? The link you provide for the instruction is the main wiki of master both's repo,which by the way, is very deprecated.
The link I provide for the instruction is the readme.md file of Martin Felis’ repo.
If you compare the “Quick start” sections of my library and Master Both’s one you will notice the differences.

Marty
Citizen
Posts: 89
Joined: Mon Dec 04, 2017 1:47 am
Location: Germany

### Re: [0.10.2] AdMob support for Android!

Hey bio1712. Thank you for these forked repos. I'm excited to try this out.

@everyone But I got a problem with the deployment using this, maybe anybody can help?

The common official documentations are very fussy and ant was missing the build.xml (gradle seems to be the way to go), I ended up downloading JetBrain's Android Studio to make things simple. I managed to compile the project with it, eventually. All dependencies are loaded, correctly as it seems.

All I did was adding my own love file to app\src\main\assets, adding my own ca-app-pub ID in the AdActivity and changing target from android-25 to android-19 in the project.properties (the game needs to run on KitKat).

Code: Select all

org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true
to increase the build process.

When I run the app on my SGS3 I get an SDL error, tho:

Anybody knows how I can fix this problem?

───▄▀▀▀▄▄▄▄▄▄▄▀▀▀▄───
───█▒▒░░░░░░░░░▒▒█───
────█░░░░░░░░░█────
▄▄──█░░░▀█▀░░░█──▄▄
█░░█▀▄░░░░░░░▄▀█░░█

bio1712
Citizen
Posts: 50
Joined: Wed Aug 19, 2015 4:13 pm
Location: Italy

### Re: [0.10.2] AdMob support for Android!

modiX wrote:
Thu Dec 07, 2017 11:40 pm
Hey bio1712. Thank you for these forked repos. I'm excited to try this out.

@everyone But I got a problem with the deployment using this, maybe anybody can help?

The common official documentations are very fussy and ant was missing the build.xml (gradle seems to be the way to go), I ended up downloading JetBrain's Android Studio to make things simple. I managed to compile the project with it, eventually. All dependencies are loaded, correctly as it seems.

All I did was adding my own love file to app\src\main\assets, adding my own ca-app-pub ID in the AdActivity and changing target from android-25 to android-19 in the project.properties (the game needs to run on KitKat).

Code: Select all

org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true
to increase the build process.

When I run the app on my SGS3 I get an SDL error, tho:

Anybody knows how I can fix this problem?
Have you tried using gradlew build? Why have you added a new gradle.properties file? And what version of Android Build Tools do you have?

Marty
Citizen
Posts: 89
Joined: Mon Dec 04, 2017 1:47 am
Location: Germany

### Re: [0.10.2] AdMob support for Android!

bio1712 wrote:
Tue Dec 12, 2017 5:58 am
Have you tried using gradlew build?
No, I haven't. So I gave it a shot, executed "gradlew.bat build", worked out. Then I created a keystore and signed my APK, I could install it. However, the problem persists.
bio1712 wrote:
Tue Dec 12, 2017 5:58 am
The build process took almost 20 minutes, so after 2 failed attempts I decided to search for a solution. With that file with the content you see in my last post, the build process only takes 2 minutes. Now, for my confusion, I've renamed the file and it still takes only 1-2 minutes, so not sure why it took so long before. I keep the file renamed as _gradle.properties to avoid any problems caused by it, for now.
bio1712 wrote:
Tue Dec 12, 2017 5:58 am
And what version of Android Build Tools do you have?
My build.gradle file has configured to use the build tools version is 25.0.2, just as it is in your fork. I tried it with the latest 27, too, but it didn't work either.

I'm going to test the whole thing with the original port as well as on some other devices tomorrow to see where the problem is coming from.