libGDX game crashes without any errors in console on android devices. It happens at different parts of game at different screens at different time. I don't see the reason. Game works well, without freezing. The game does not crash under resource-intensive operations like changing the screen, but already when the screen is loaded and the player plays for a while. The use of memory would probably be normal, based on the graphs of the use of RAM. The CPU is also not overloaded. enter image description here The strangest thing is that when a game crashes there are no errors displayed in the console. The phone screen turns black for a while, then the system emits on the home screen.The phone also does not show error messages in the application, etc. Also, sometimes after displaying the AdMob video, the game stops responding to the input, although the graphics continue to work, the animations are working.

At first I thought it might be due to AdMob's incorrect implementation. But after the complete removal of AdMob from the project, the problem did not disappear.

What then can lead to such behavior of the application?

Perhaps this is due to some error in AssetManager? I would like to note that I use a large number of textures (more then 170), packed in an atlas. All textures in atlas takes 4.31MB disk space and all my assets takes 6.2MB. All the resources I load during the initial loading of the game using AssetManager.

So, my Res class:

public class Res {

    public static final String LOCALE_BUNDLE_PATH = "i18n/locale";

    public static final String MAIN_ATLAS_PATH = "packs/main/MAIN.atlas";
    public static final String MUSIC_M3_THEME_PATH = "music/atc_m3_theme.mp3";
    public static final String KICK_SOUND_PATH = "music/atc_kick.mp3";
    public static final String FADEIN_SOUND_PATH = "music/atc_fadein.mp3";
    public static final String DRAG_START_SOUND_PATH = "music/atc_drag_start.mp3";
    public static final String DRAG_STOP_SOUND_PATH = "music/atc_drag_stop.mp3";

    public static final String FONT_REGULAR_PATH = "fonts/comfortaa_regular.ttf";
    public static final String FONT_LIGHT_PATH = "fonts/comfortaa_light.ttf";
    public static final String RUSSO_ONE_REGULAR = "fonts/russo_one_regular.ttf";

    public static TextureAtlas MAIN_ATLAS;

    public static I18NBundle LOCALE;

    /* MUSIC & SOUNDS */
    public static Music M3_THEME;
    public static Sound KICK_SOUND;
    public static Sound FADE_IN_SOUND;
    public static Sound DRAG_START_SOUND;
    public static Sound DRAG_STOP_SOUND;

    private Res () {
        MAIN_ATLAS = null;


And my ResManager:

public class ResManager extends AssetManager {

    public void loadResources () {
        load(Res.MAIN_ATLAS_PATH, TextureAtlas.class);
        load(Res.MUSIC_M3_THEME_PATH, Music.class);
        load(Res.KICK_SOUND_PATH, Sound.class);
        load(Res.FADEIN_SOUND_PATH, Sound.class);
        load(Res.DRAG_START_SOUND_PATH, Sound.class);
        load(Res.DRAG_STOP_SOUND_PATH, Sound.class);
        load(Res.LOCALE_BUNDLE_PATH, I18NBundle.class);
        Res.MAIN_ATLAS = get(Res.MAIN_ATLAS_PATH, TextureAtlas.class);
        Res.M3_THEME = get(Res.MUSIC_M3_THEME_PATH, Music.class);
        Res.KICK_SOUND = get(Res.KICK_SOUND_PATH, Sound.class);
        Res.FADE_IN_SOUND = get(Res.FADEIN_SOUND_PATH, Sound.class);
        Res.DRAG_START_SOUND = get(Res.DRAG_START_SOUND_PATH, Sound.class);
        Res.DRAG_STOP_SOUND = get(Res.DRAG_STOP_SOUND_PATH, Sound.class);
        Res.LOCALE = get(Res.LOCALE_BUNDLE_PATH, I18NBundle.class);


I know that in an android ecosystem doing TextureAtlas static is a bad idea, but for the convenience of using resources in the code, it had to be done. In addition, it is still deleted from memory, because I kill the process while the application is shutting down.

    protected void onDestroy() {

Also, I do the correct dispose of all screens, obviously pointing GC to unnecessary objects that he should has collected. For example:

    public void dispose() {
        stage.dispose(); // Stage
        loadingPane = null; // Group
        multiplexer = null; // InputMultiplexer
        firstScreen.destroy(); // Group
        secondScreen.destroy(); // Group
        firstScreen = null;
        secondScreen = null;
        bgSky = null; // Image
        ground = null; // Image
        dialogCircuit = null; // Group
        dialogModule = null; // Group
        dialogNotEnough = null; // Group

Tried to catch memory leaks with the help of LeakCanary. But it did not work. The log is empty.

Tell me, what could be the reason? A very annoying problem that kills all the joy of using my game.

  • \$\begingroup\$ Have you tried testing without adb connection (build apk and install it on android)? \$\endgroup\$
    – Mihail Ris
    Mar 19 '18 at 15:10
  • \$\begingroup\$ @MihailRis, of course. This application was tested on different devices with different Android versions, and it's behavior identical on every phone. \$\endgroup\$ Mar 19 '18 at 15:14

Solved. Answer here.

(The problem was in very frequent BitmapFont generation.)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.