Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Ad Mob with Kivy on Android

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.

like image 699
Shoumik Das Avatar asked Oct 19 '25 03:10

Shoumik Das


2 Answers

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#

like image 55
N Sivaram Avatar answered Oct 21 '25 06:10

N Sivaram


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#

like image 23
N Sivaram Avatar answered Oct 21 '25 04:10

N Sivaram



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!