Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

libgdx game crashes on some devices

Tags:

android

libgdx

Right after start of app, my app crushes without error message on a device. This only happens on Samsung Note 1(at least, can't test on all devices), but not on Motorola Moto G or Galaxy s4mini. The only hint I get is in the debugger. I pasted it below. What exactly is happening and why it crashes only on some devices?

Edit: it crashes also on return to the app from "running apps" menu. Note 1 has CyanogenMod installed. Maybe this has something to do with the crashing.

Edit2:Another observation: note 1 allocates only a half of the memory as the other two devices. Has this anything to do with the crash?

01-05 17:00:16.212 13486-13513/com.mygdx.myGame.android D/dalvikvm: Trying to load lib /data/app-lib/com.mygdx.myGame.android-2/libgdx-freetype.so 0x42441a58
    01-05 17:00:16.222 13486-13513/com.mygdx.myGame.android D/dalvikvm: Added shared lib /data/app-lib/com.mygdx.myGame.android-2/libgdx-freetype.so 0x42441a58
    01-05 17:00:16.222 13486-13513/com.mygdx.myGame.android D/dalvikvm: No JNI_OnLoad found in /data/app-lib/com.mygdx.myGame.android-2/libgdx-freetype.so 0x42441a58, skipping init
like image 739
potato Avatar asked Jan 05 '16 16:01

potato


2 Answers

The function "JNI_OnLoad" is not essential for an android app. It is not even an error. Your problem is from another part of your code. Even if you have not provided this function, your program should run normally.

References on JNI_OnLoad which can be helpful - Link 1 | Link 2 | Link 3

There is a way to fix it though-

Try to use ndk-gdb to fix it.

References for ndk-gdb - developer.android.com | Stackoverflow

I do have this issue in like most of the projects I have worked on. It is nothing related to Android app getting crashed.

There is something else in your app that is crashing. Some tips to consider which will help you debug-

  1. Check Playstore(if its on playstore) for logs(what exactly the error is). They give stack trace which helps to debug.

  2. If its not on Playstore, only way to go forward is to do remote debug on the mobile which is giving the error.

  3. I have had such experiences, and its MOST OF THE TIME because of API change. What I mean is, APIs would have changed from one Android version to another(Kitkat to Lollipop - there are lots of breaking changes!) Check this once. Most of my apps had lots of issues because of this.

  4. Some mobile's are strict when it comes to DB(sqlite or whatever you use on the phone) transactions. I mean, in one of the application, when the DB was not closed at the end of all transactions, the app was getting Force closed in most Samsung & HTC mobile phones. While it worked very well on most other phones.

Hope it helps :) Happy coding!

like image 125
bozzmob Avatar answered Oct 24 '22 21:10

bozzmob


Note to self: "Always use asset manager and texture atlases"

Over the course of developing I eventually replaced all textures with texture atlases and combined with asset manager. I didn't change any logic at all. Somehow the app stopped crashing. Can't explain it but I thing the asset manager and texture atlases did the trick.

like image 30
potato Avatar answered Oct 24 '22 21:10

potato