PLEASE HELP! Unity interstitial ads crashing after 7 displays (in Python Kivy on my Android device)
Please help! This is my Python code, which only works for a short time before the app crashes with various different errors:
#! /usr/bin/python
import re
import sys
import os
from android.runnable import run_on_ui_thread
from jnius import autoclass, PythonJavaClass, java_method, cast
from kivy.app import App
import logging
testmode = True
inter_id = "12839"
PythonActivity = autoclass("org.kivy.android.PythonActivity")
Unity_ads_listener = autoclass("com.unity3d.ads.IUnityAdsListener")
Unity_ads = autoclass("com.unity3d.ads.UnityAds")
class Unity_handler(App):
@run_on_ui_thread
def __init__(self, a_id):
self.app_id = a_id
@run_on_ui_thread
def init_unity(self):
new_ad_listener = UnityAdsListener()
Unity_ads.addListener(new_ad_listener)
self.c_activity = cast('android.app.Activity',PythonActivity.mActivity)
Unity_ads.initialize(self.c_activity,self.app_id,testmode)
@run_on_ui_thread
def show_ad(self, id_num):
#show interstial ads
#self.inter_id = id_num
if Unity_ads.isReady(inter_id):
try:
Unity_ads.show(self.c_activity, inter_id)
except:
fail=1
class UnityAdsListener(PythonJavaClass):
__javainterfaces__= ['com/unity3d/ads/IUnityAdsListener']
__javacontext__= 'app'
@java_method('(Ljava/lang/String;)V')
def onUnityAdsReady(self,inter_id):
pass
@java_method('(Ljava/lang/String;)V')
def onUnityAdsStart(self,inter_id):
pass
@java_method('(Ljava/lang/String;Lcom/unity3d/ads/UnityAds$FinishState;)V')
def onUnityAdsFinish(self,inter_id,un_f):
pass
@java_method('(Lcom/unity3d/ads/UnityAds$UnityAdsError;Ljava/lang/String;)V')
def onUnityAdsError(self,error, message):
pass
This adb log report is below which displays the critical error (crash report)
10-02 19:00:45.552 14388 14388 I python : Traceback (most recent call last):
10-02 19:00:45.552 790 840 D WindowManager: notifyActivityDrawnForKeyguard: waiting=false Callers=com.android.server.wm.WindowSurfacePlacer.handleAppTransitionReadyLocked:1227 com.android.server.wm.WindowSurfacePlacer.performSurfacePlacementInner:337 com.android.server.wm.WindowSurfacePlacer.performSurfacePlacementLoop:235 com.android.server.wm.WindowSurfacePlacer.performSurfacePlacement:183 com.android.server.wm.WindowManagerService$H.handleMessage:8417
10-02 19:00:45.552 790 840 V WindowManager: Looking for focus: 12 = Window{cf0765f u0 StatusBar}, flags=-2122055608, canReceive=false
10-02 19:00:45.553 14388 14388 I python : File "jnius/jnius_proxy.pxi", line 156, in jnius.jnius.invoke0
10-02 19:00:45.554 14388 14388 I python : File "jnius/jnius_proxy.pxi", line 124, in jnius.jnius.py_invoke0
10-02 19:00:45.555 14388 14388 I python : AttributeError: 'list' object has no attribute 'invoke'
Interestingly, if I request to show the ad in the main screen (using a test button) the ad shows fine(multiple times). It is just when I call it from another screen in the app (one of many level screens in Kivy Screen manager), it crashes with that error after 7 displays. This never happened with google admob, so is there a work around or have I missed something?
Answer by DegenerateTech · Apr 09, 2021 at 09:22 PM
see this i also need this . https://github.com/SonofPoseidon1982/kivunity
Your answer
Follow this Question
Related Questions
Invalid JDK home selected (Mac) 1 Answer
How to send data to network on button press? 0 Answers
How to load android activity when the button clicked in unity scene? 0 Answers
Android SDK errors 0 Answers
Couldn't build Android App 2 Answers