While I am building my game, I look for a way to monetize it. This will be my first game, so it is also the first to attempt earning money with an App. I am also not familiar to monetization companies.
So, I have done a search to find an appropriate ads network which can be easily integrated with kivy. The first and only company who provides a sdk for kivy is RevMob. I integrated RevMob sdk and tested it. Unfortunately, it doesn't have a good performance and FullScreen Ads crashes. Just links will work. Therefore, RevMob option is not really preferable since ads need to be visually effective.
You can also integrate android sdk of any ads network by using pyjnius. In this post, I will show how to use Adbuddiz sdk with kivy.
First, you need to create an account at AdBuddiz and associate your application with this account. You will need 'Publisher Key' in info window of the app.
As next step, download AdBuddiz sdk and place the .jar file under libs/ directory of the project.
Here is an example code of AdBuddiz integration:
P.S. The work is originated from this wiki page of kivy.
So, I have done a search to find an appropriate ads network which can be easily integrated with kivy. The first and only company who provides a sdk for kivy is RevMob. I integrated RevMob sdk and tested it. Unfortunately, it doesn't have a good performance and FullScreen Ads crashes. Just links will work. Therefore, RevMob option is not really preferable since ads need to be visually effective.
You can also integrate android sdk of any ads network by using pyjnius. In this post, I will show how to use Adbuddiz sdk with kivy.
First, you need to create an account at AdBuddiz and associate your application with this account. You will need 'Publisher Key' in info window of the app.
As next step, download AdBuddiz sdk and place the .jar file under libs/ directory of the project.
Here is an example code of AdBuddiz integration:
from kivy.app import App
from jnius import autoclass
from kivy.utils import platform
platform = platform()
if platform=="android":
PythonActivity=autoclass("org.renpy.android.PythonActivity")
AdBuddiz=autoclass("com.purplebrain.adbuddiz.sdk.AdBuddiz")
class AdsNetwork():
def __init__(self):
if platform=="android":
AdBuddiz.setPublisherKey("Publisher Key"); #pass publisher key of your app as string
AdBuddiz.setTestModeActive(); #for testing purposes, use this command
AdBuddiz.cacheAds(PythonActivity.mActivity); #this will cache the ads
def show_ads(self):
if platform == 'android':
AdBuddiz.showAd(PythonActivity.mActivity) #show a popup ad
class MyGame(App):
def build(self):
self._adv = AdsNetwork()
return Button(text="Show ads", on_release=self._adv.show_ads())
if __name__=="__main__":
MyGame().run()
Some small configuration is necessary to show ads. Firstly, adnetwork uses some sources whose permissions need to be listed in AndroidManifest.xml file. To achieve it, open your buildozer.spec file and make sure following lines exist:
android.permissions = INTERNET,ACCESS_WIFI_STATE,ACCESS_NETWORK_STATE
In order buildozer to add your jar to the apk, you explicitly define it in buildozer.spec too:
android.add_jars = %(source.dir)s/libs/*.jar
It is almost done. In AdBuddiz side, it needs its activity definition to exist in AndroidManifest.xml file. For this purpose, add following line into AndroidManifest.tmpl.xml file under .buildozer/ directory:
<activity android:name="com.purplebrain.adbuddiz.sdk.AdBuddizActivity"
android:theme="@android:style/Theme.Translucent" />
Your code is ready to show ads now.P.S. The work is originated from this wiki page of kivy.
i tried the tutorial but on button release nothing happens, should i see something peticular? in the android manifest should the line pe indented or top level?
ReplyDeleteIf the test mode is active, you should see the popup app. Activity definition may be done right after python activity, under same xml tag. But this edit must be done in template AndroidManifest.xml file of buildozer. If these are done and nothing happens, logcat may be helpful, becuase in an error case adbuddiz sdk dumps related logs.
DeleteWll try again tomorow to configure again , tried revmob as well in the mean time but to me it seems that fulscreens don`t even initialize, sadly the sdk version for kivy is 0.2, so they`re probably didn`t do any more work on it. Too bad!!
DeleteCan you tell me where excatly I should put the code in AndroidManifest.tmpl.xml
ReplyDeleteUnder application tag,you will place activity tag which will be for AdBuddizActivity, just like PythonActivity.
DeleteDoesn't look like this works anymore :c
ReplyDelete