Reputation: 318
I'm creating a kivy app for android and I want to integrate an sdk but I can't seem to figure out how to build an apk with it integrated. So far none of the guides I've found have been helpful.
Upvotes: 0
Views: 335
Reputation: 8066
Here is an example of working with AdBuddiz a similar solution can be applied with admob using jnius
#ads.py
from jnius import autoclass
import logging
import random
log = logging.getLogger('kivy.funky.stuff')
PythonActivity=autoclass("org.renpy.android.PythonActivity")
AdBuddiz=autoclass("com.purplebrain.adbuddiz.sdk.AdBuddiz")
AD_CHANCE = 0.06
def init():
AdBuddiz.setPublisherKey("some-token")
#delete this before going to play at the store...
AdBuddiz.setTestModeActive()
AdBuddiz.cacheAds(PythonActivity.mActivity)
def show():
if (random.random() < AD_CHANCE):
log.info("Showing Ad!!!")
try:
AdBuddiz.showAd(PythonActivity.mActivity)
except Exception:
log.exception("Pizza is not healthy...")
else:
log.warn("Skipping the AD this time ;)")
to make this work you'll need to add pyjnius to your buildozer.spec as well as the java SDK (i.e. android.add_jars = %(source.dir)s/libs/*.jar).
Upvotes: 2