Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kivy App Closes After Kivmob Ad Shows #98

Open
hjjr78 opened this issue Jan 16, 2021 · 6 comments
Open

Kivy App Closes After Kivmob Ad Shows #98

hjjr78 opened this issue Jan 16, 2021 · 6 comments

Comments

@hjjr78
Copy link

hjjr78 commented Jan 16, 2021

app_crash_after_ad.zip

After and Ad shows in my app and I just let it stay on the screen, my app will close in a matter of seconds. Sometimes the app close after I manually close the ad. I haven't had this issue on my android 7 phone.... The problem occurs on my android 10 tablet.

What I do is create my ad object at start up but I do not call request for an ad. At certain points in the app and at random times, a request for an ad gets called. An interval then starts, which calls the "if ad is ready" method/function. When the ad is loaded, the interval calls the show ad run_once interval and kills itself.

I do not call destroy on the ad, because i figured that's only for when the app is going to be exited. Instead, request ad just gets called again eventually and repeat. I'm guessing the issue is Kivmob related or maybe my device is running out of memory. My phone has 1.5 gig ram and my tablet has 1 gig ram. I'm wondering if that's the difference....I don't know because sometime my app doesn't crash on my tablet after ads until like, the 10th ad....it's all pretty random. Again, haven't seen this behavior on my android 7 phone yet.

I've also seen my app's view port get offset or something because sometimes...rarely but I've seen it happen more than once....after an ad closes and return to my app, my app's widgets will be offset or the entire screen will be partially out of view with a black boarder.

I really need to fix the crash after ad issue... If anyone has a clue, please email at: hjjr78@gmail.com

Regards

@akgupta0777
Copy link
Contributor

There must be a problem with your buildozer.spec file . please show us that file.

@hjjr78
Copy link
Author

hjjr78 commented Jan 17, 2021

There must be a problem with your buildozer.spec file . please show us that file.

I use the test setup on the Kivmob website but I build with the highest api level possible so that may be different...... Oh, my python is python 3 and that's in the spec file (not 2).

requirements = hostpython2, kivy, android, jnius, kivmob
...
android.permissions = INTERNET, ACCESS_NETWORK_STATE
android.api = 27
android.minapi = 21
android.sdk = 24
android.ndk = 17b
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}

I'm showing all Interstitials ads. What I do is create the object when the app starts....

self.ads = KivMob(TestIds.APP)
self.ads.new_interstitial(TestIds.INTERSTITIAL)

At certain points in the app, when and ad has a chance to go off.... The app checks to see if the 'checking' variable is True. If not, the function to 'request_interstitial()' is called and that function sets 'checking' to true and the end.

The "checking" variable True tells my app it can now check to see if the ad is loaded. At certain points in the app, there's a random chance the "checking" interval will run and that interval just calls 'is_interstitial_loaded()' until it returns True and the interval kills itself (setting 'checking' False) but calls the 'run_once' interval which calls....

self.ads.show_interstitial()
#self.ads.destroy_interstitial()
return False

At this point, 'checking' is false now which means the process will start over next time a random chance for an ad goes off. I don't call 'destroy_interstitial()' because I figured a connection to the ad server only needs to be made once and I only do the setup once at the start of the app (as mentioned up top).

This is what I've learned since I posted.......

I can run my app on my android 7 phone without any problems...it runs perfect. The app closing was happening on my android 10 Go tablet. The tablet only has around 1 gig ram, while my phone has around 1.5 gig ram. While looking into logcat during the app run on my android 10 Go tablet, I saw that onLowMemory was called along with 'killed' for my app.

So I got to thinking... Maybe my app is being killed after ads show because more memory is used at that time and the app just closes.... So what I did was reset the android 10 Go tablet to refresh and free all memory. I then ran the app at tablet start up and sure enough....my app ran without crashing. I did the reset tablet more than once to make sure it wasn't just by chance but I haven't seen the app close after the tablet restarts.

So... What do you think? Is it most like a memory issue and not something else? I've checked my code and it's really based off your own code on the website so I don't see anything that could be causing the crash code wise.

I've noticed android 10 Go probably has some issues too though because on my android 7 phone, when ads show...they create a background of their own if the ad doesn't fill the screen. On my android 10 Go tablet, ads do not show a background if they don't fill the screen (the background is just left empty; black).

I even downloaded a game app from the app store just to see how my tablet would handle it and when that app ran, it popped a message up stating the memory was limited.

So maybe all hand-held devices need at least 1.5 gigs ram for most game apps......

@hjjr78
Copy link
Author

hjjr78 commented Jan 17, 2021

I just tested my app on an android 10 phone with 1.9 ram.... App runs perfectly! So now I'm really thinking it was just a ram issue on my android 10 Go Tablet.

Now.... I'm trying to understand the logic behind Kivmob a bit more so correct me if I'm wrong..... Keeping in mine, I'm not a Java programmer and know little to nothing about Google's apis behind Kivy.....

self.ads = KivMob(TestIds.APP)
This sets up which app is trying to bridge with the ad account....

self.ads.new_interstitial(TestIds.INTERSTITIAL)
This tells the server side which ad source to use.......

self.ads.request_interstitial()
This actually request and ad from the ad source to download.......

self.ads.show_interstitial()
This obviously shows the ad if it has loaded.....

destroy_interstitial()
I'm guessing this is never really needed unless one wanted to change their ad source. I imagine the bridge between app and server will terminate when the app closes anyway.....

And that's how I see kivmob.

PS, I really think Google is sloppy when it comes to the android platform and developing apps. Developers really have to jump through a lot of loops that shouldn't have been their to begin with. Did Zurkurbug (or however it's spelled) do this "chite?"

@akgupta0777
Copy link
Contributor

Basically
self.ads = kivmob (TestIds.App)
Basically connects the ad object to your admob account in order to fetch ads from google.

self.ads.new_interstitial() will fetch a interstitial ad from Google and store it in memory so when you want to show the interstitial ads it will directly get it from the memory.

@akgupta0777
Copy link
Contributor

Maybe you are right as it maybe a memory issue.
Android Go is designed such that it runs smoothly on low end devices
The android regularly clears the memory while the app is using it. And if some app requires more memory then android freeze or killed that app instantly.

@akgupta0777
Copy link
Contributor

I don't think Google is responsible or it is sloppy as python was never the right tool for creating android apps.
There are bridges that work under the hood to transform your python code to Java bytecode or a language that android understands.

Have a look at this https://github.com/kivy/python-for-android

Python has potential and maybe it is given some performance boost in future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants