- Home /
Integrating unity ads in Python Kivy
Has anyone published a guide in how to integrate Unity's SDK in Python Kivy? (is it even possible?) I'm trying to do this through Pyjnius, but as I have no familiarity with java, this is naturally very hard. (I am planning to learn it soon to make life easier). This is what I've managed so far:
from jnius import autoclass, PythonJavaClass, java_method
from kivy.app import App
import logging
PythonActivity = autoclass("org.kivy.android.PythonActivity")
Unity_ads_listener = autoclass("com.unity3d.ads.IUnityAdsListener")
Unity_ads = autoclass("com.unity3d.ads.UnityAds")
class Unity_handler:
def __init__(self,application_id,test_m):
self.app_id = application_id
self.test_mode = test_m
def init_unity(self):
new_ad_listener = Unity_ads_init()
Unity_ads.addListener(new_ad_listener)
Unity_ads.initialize(self,self.app_id,testmode)
def show_ad(self, id_num):
#show interstial ads
self.inter_id = id_num
if Unity_ads.isReady(self.inter_id):
Unity_ads.show(self, self.inter_id)
#####################################################################################################################################
class Unity_ads_init(PythonJavaClass):
__javainterfaces__= ['com/unity3d/ads/IUnityAdsListener']
def __init__(self):
super(Unity_ads_init, self).__init__()
#self.callback = callback
@java_method('Ljava/lang/String;')
def onUnityAdsReady(self, inter_id):
pass
@java_method('Ljava/lang/String;')
def onUnityAdsStart(self, inter_id):
pass
@java_method('Ljava/lang/String;(Ljava/lang/String;)')
def onUnityAdsFinish(self, inter_id,un_f):
pass
@java_method('(Ljava/lang/String;)Ljava/lang/String;')
def onUnityAdsError(self, error, message):
pass
Any help with this would be appreciated. I feel like a total noobstick, Atm I'm getting "jnius.jnius.JavaException: JVM exception occurred: interface com.unity3d.ads.IUnityAdsListener is not visible from class loader"
Your answer
![](https://koobas.hobune.stream/wayback/20220613010559im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
including unity ads Kivy app 0 Answers
Admob Build Error ? 0 Answers
Unity ads successfully integrated in Python Kivy app, but crashes after 10 displays, help needed. 0 Answers
Android SDK Install Help 0 Answers
Java error when building 1 Answer