4

Is there a way to integrate Google Ad Mob with Kivy 1.11.1 apps running on Android?

I came across a package called KivMob on GitHub. Will it work with the latest version of Google api(s)?

Can someone share a sample code? Is there any other way to achieve this?

Please advise.

Shoumik Das
  • 441
  • 5
  • 16

1 Answers1

3

Yes you can use admob ads. As you said you should use kivmob. I have used that in my apps and it is working well. Sample code for banner ads.

from kivmob import KivMob, TestIds

from kivy.app import App
from kivy.uix.label import Label

class BannerTest(App):
    """ Displays a banner ad at top of the screen.
    """

    def build(self):
        self.ads = KivMob(TestIds.APP)
        self.ads.new_banner(TestIds.BANNER, top_pos=True)
        self.ads.request_banner()
        self.ads.show_banner()
        return Label(text='Banner Ad Demo')

if __name__ == "__main__":
    BannerTest().run()

Then in your buildozer.spec file

requirements =  kivy, android, jnius, kivmob
...
android.permissions = INTERNET, ACCESS_NETWORK_STATE
android.api = 28
android.minapi = 21
android.sdk = 24
android.ndk = 19b
android.gradle_dependencies = 'com.google.firebase:firebase-ads:10.2.0'
p4a.branch = master
# For test ads, use application ID ca-app-pub-3940256099942544~3347511713
android.meta_data = com.google.android.gms.ads.APPLICATION_ID={ADMOB_APP_ID_HERE}

For more information: http://kivmob.com/tutorials.html#

N Sivaram
  • 298
  • 1
  • 11