• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Android [SOLVED] Game crashes on Android when trying to save game

Hi,
I'm working on a game for Android and just implemented save / load functionality. Everything works fine on Windows, but the Android build keeps crashing the moment I try to save. For troubleshooting purposes, I'm making the first save 8 seconds after game start. There are no physics objects... Any idea how to prevent this?

I'm using the latest GMS version, runtime v2.3.2.426, API level 30.

This is the debug message I get:

GML:
05-29 13:25:13.418  6651 16674 I yoyo    : Total memory used = 1809018(0x001b9a7a) bytes
05-29 13:25:13.418  6651 16674 I yoyo    : **********************************.
05-29 13:25:13.418  6651 16674 I yoyo    : Entering main loop.
05-29 13:25:13.418  6651 16674 I yoyo    : **********************************.
05-29 13:25:13.418  6651 16674 I yoyo    : Finished BeginToEnd, default frame buffer is: 0
05-29 13:25:13.418  6651 16674 I yoyo    : MANUFACTURER = samsung
05-29 13:25:13.421  6651 16674 I yoyo    : _FileExists fail in zip - assets/save.ini
05-29 13:25:13.430  6651 16674 I yoyo    : Texture #3 2048,2048
05-29 13:25:13.758  6651 16674 I yoyo    : GAMEPAD: Enumeration complete
05-29 13:25:16.389 12264 12264 I AndroidRuntime: VM exiting with result code 0, cleanup skipped.
05-29 13:25:21.715 17651 17651 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
05-29 13:25:21.715 17651 17651 F DEBUG   : Build fingerprint: 'samsung/m31snseea/m31s:11/RP1A.200720.012/M317FXXU2CUB1:user/release-keys'
05-29 13:25:21.715 17651 17651 F DEBUG   : Revision: '2'
05-29 13:25:21.715 17651 17651 F DEBUG   : ABI: 'arm64'
05-29 13:25:21.716 17651 17651 F DEBUG   : Timestamp: 2021-05-29 13:25:21+0200
05-29 13:25:21.716 17651 17651 F DEBUG   : pid: 6651, tid: 16674, name: GLThread 78216  >>> com.company.game <<<
05-29 13:25:21.716 17651 17651 F DEBUG   : uid: 10955
05-29 13:25:21.716 17651 17651 F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x3e7
05-29 13:25:21.716 17651 17651 F DEBUG   : Cause: null pointer dereference
05-29 13:25:21.716 17651 17651 F DEBUG   :     x0  00000000000003e7  x1  000000731239697c  x2  0000000000000000  x3  0000000000000010
05-29 13:25:21.716 17651 17651 F DEBUG   :     x4  00000000000003e7  x5  0000800000000000  x6  6274636e716eff72  x7  0000000000000018
05-29 13:25:21.716 17651 17651 F DEBUG   :     x8  0101010101010101  x9  0000000000000000  x10 000000004d33dfa5  x11 00000000a1c1a5d8
05-29 13:25:21.716 17651 17651 F DEBUG   :     x12 000000006725268c  x13 000000706cc0066b  x14 000000731237ed4a  x15 000000000000024b
05-29 13:25:21.716 17651 17651 F DEBUG   :     x16 000000706a88d290  x17 000000731230dcf0  x18 0000000400000000  x19 000000706cc01018
05-29 13:25:21.716 17651 17651 F DEBUG   :     x20 00000000000003e7  x21 00000070b1c117d0  x22 000000706a897aa9  x23 00000070a1c5d610
05-29 13:25:21.716 17651 17651 F DEBUG   :     x24 00000070a1c1a5c0  x25 000000706a960514  x26 000000706a960518  x27 000000000000001d
05-29 13:25:21.716 17651 17651 F DEBUG   :     x28 0000000000000000  x29 000000706cc01000
05-29 13:25:21.716 17651 17651 F DEBUG   :     lr  000000706a508a10  sp  000000706cc00fd0  pc  000000731230dd00  pst 0000000080000000
05-29 13:25:21.720 17651 17651 F DEBUG   : backtrace:
05-29 13:25:21.720 17651 17651 F DEBUG   :     NOTE: Function names and BuildId information is missing for some frames due
05-29 13:25:21.720 17651 17651 F DEBUG   :     NOTE: to unreadable libraries. For unwinds of apps, only shared libraries
05-29 13:25:21.720 17651 17651 F DEBUG   :     NOTE: found under the lib/ directory are readable.
05-29 13:25:21.720 17651 17651 F DEBUG   :       #00 pc 000000000004ad00  /apex/com.android.runtime/lib64/bionic/libc.so (strlen_default+16) (BuildId: a8305f9d0972c215b1641fb783b35c88)
05-29 13:25:21.720 17651 17651 F DEBUG   :       #01 pc 000000000033ea0c  /data/app/~~1pTyn1FLg80zBry782SeoA==/com.company.game-y3xmF9YfY1RPyIqC5XeICQ==/lib/arm64/libyoyo.so (IniFile::SetKey(char const*, char const*, char const*)+348) (BuildId: bf999f37e8b50e53dd2457044d1ba96278191e37)
05-29 13:25:21.720 17651 17651 F DEBUG   :       #02 pc 00000000002c1138  /data/app/~~1pTyn1FLg80zBry782SeoA==/com.company.game-y3xmF9YfY1RPyIqC5XeICQ==/lib/arm64/libyoyo.so (YYGML_ini_write_real(char const*, char const*, double)+96) (BuildId: bf999f37e8b50e53dd2457044d1ba96278191e37)
05-29 13:25:21.720 17651 17651 F DEBUG   :       #03 pc 00000000001da3a8  /data/app/~~1pTyn1FLg80zBry782SeoA==/com.company.game-y3xmF9YfY1RPyIqC5XeICQ==/lib/arm64/libyoyo.so (gml_Object_ctrl_save_Alarm_1(CInstance*, CInstance*)+580) (BuildId: bf999f37e8b50e53dd2457044d1ba96278191e37)
05-29 13:25:21.720 17651 17651 F DEBUG   :       #04 pc 0000000000278434  /data/app/~~1pTyn1FLg80zBry782SeoA==/com.company.game-y3xmF9YfY1RPyIqC5XeICQ==/lib/arm64/libyoyo.so (ExecuteIt(CInstance*, CInstance*, CCode*, RValue*, int)+104) (BuildId: bf999f37e8b50e53dd2457044d1ba96278191e37)
05-29 13:25:21.720 17651 17651 F DEBUG   :       #05 pc 00000000002785f8  /data/app/~~1pTyn1FLg80zBry782SeoA==/com.company.game-y3xmF9YfY1RPyIqC5XeICQ==/lib/arm64/libyoyo.so (Code_Execute(CInstance*, CInstance*, CCode*, RValue*, int)+8) (BuildId: bf999f37e8b50e53dd2457044d1ba96278191e37)
05-29 13:25:21.720 17651 17651 F DEBUG   :       #06 pc 0000000000284660  /data/app/~~1pTyn1FLg80zBry782SeoA==/com.company.game-y3xmF9YfY1RPyIqC5XeICQ==/lib/arm64/libyoyo.so (CEvent::Execute(CInstance*, CInstance*)+72) (BuildId: bf999f37e8b50e53dd2457044d1ba96278191e37)
05-29 13:25:21.720 17651 17651 F DEBUG   :       #07 pc 000000000028492c  /data/app/~~1pTyn1FLg80zBry782SeoA==/com.company.game-y3xmF9YfY1RPyIqC5XeICQ==/lib/arm64/libyoyo.so (Perform_Event_Object_ASync(CInstance*, CInstance*, int, int, int)+228) (BuildId: bf999f37e8b50e53dd2457044d1ba96278191e37)
05-29 13:25:21.721 17651 17651 F DEBUG   :       #08 pc 0000000000284a80  /data/app/~~1pTyn1FLg80zBry782SeoA==/com.company.game-y3xmF9YfY1RPyIqC5XeICQ==/lib/arm64/libyoyo.so (Perform_Event(CInstance*, CInstance*, int, int)+152) (BuildId: bf999f37e8b50e53dd2457044d1ba96278191e37)
05-29 13:25:21.721 17651 17651 F DEBUG   :       #09 pc 0000000000455108  /data/app/~~1pTyn1FLg80zBry782SeoA==/com.company.game-y3xmF9YfY1RPyIqC5XeICQ==/lib/arm64/libyoyo.so (HandleAlarm()+320) (BuildId: bf999f37e8b50e53dd2457044d1ba96278191e37)
05-29 13:25:21.721 17651 17651 F DEBUG   :       #10 pc 000000000045b40c  /data/app/~~1pTyn1FLg80zBry782SeoA==/com.company.game-y3xmF9YfY1RPyIqC5XeICQ==/lib/arm64/libyoyo.so (DoAStep()+412) (BuildId: bf999f37e8b50e53dd2457044d1ba96278191e37)
05-29 13:25:21.721 17651 17651 F DEBUG   :       #11 pc 000000000045bb6c  /data/app/~~1pTyn1FLg80zBry782SeoA==/com.company.game-y3xmF9YfY1RPyIqC5XeICQ==/lib/arm64/libyoyo.so (MainLoop_Process()+1028) (BuildId: bf999f37e8b50e53dd2457044d1ba96278191e37)
05-29 13:25:21.721 17651 17651 F DEBUG   :       #12 pc 000000000030e228  /data/app/~~1pTyn1FLg80zBry782SeoA==/com.company.game-y3xmF9YfY1RPyIqC5XeICQ==/lib/arm64/libyoyo.so (Java_com_yoyogames_runner_RunnerJNILib_Process+868) (BuildId: bf999f37e8b50e53dd2457044d1ba96278191e37)
05-29 13:25:21.721 17651 17651 F DEBUG   :       #13 pc 000000000000b4c0  /data/app/~~1pTyn1FLg80zBry782SeoA==/com.company.game-y3xmF9YfY1RPyIqC5XeICQ==/oat/arm64/base.odex (deleted)
 

Mool

Member
show us the linked gml code of this:


Code:
05-29 13:25:21.720 17651 17651 F DEBUG   :       #00 pc 000000000004ad00  /apex/com.android.runtime/lib64/bionic/libc.so (strlen_default+16) (BuildId: a8305f9d0972c215b1641fb783b35c88)
05-29 13:25:21.720 17651 17651 F DEBUG   :       #01 pc 000000000033ea0c  /data/app/~~1pTyn1FLg80zBry782SeoA==/com.company.game-y3xmF9YfY1RPyIqC5XeICQ==/lib/arm64/libyoyo.so (IniFile::SetKey(char const*, char const*, char const*)+348) (BuildId: bf999f37e8b50e53dd2457044d1ba96278191e37)
05-29 13:25:21.720 17651 17651 F DEBUG   :       #02 pc 00000000002c1138  /data/app/~~1pTyn1FLg80zBry782SeoA==/com.company.game-y3xmF9YfY1RPyIqC5XeICQ==/lib/arm64/libyoyo.so (YYGML_ini_write_real(char const*, char const*, double)+96) (BuildId: bf999f37e8b50e53dd2457044d1ba96278191e37)
05-29 13:25:21.720 17651 17651 F DEBUG   :       #03 pc 00000000001da3a8  /data/app/~~1pTyn1FLg80zBry782SeoA==/com.company.game-y3xmF9YfY1RPyIqC5XeICQ==/lib/arm64/libyoyo.so (gml_Object_ctrl_save_Alarm_1(CInstance*, CInstance*)+580) (BuildId: bf999f37e8b50e53dd2457044d1ba96278191e37)
05-29 13:25:21.720 17651 17651 F DEBUG   :       #04 pc 0000000000278434  /data/app/~~1pTyn1FLg80zBry782SeoA==/com.company.game-y3xmF9YfY1RPyIqC5XeICQ==/lib/arm64/libyoyo.so (ExecuteIt(CInstance*, CInstance*, CCode*, RValue*, int)+104) (BuildId: bf999f37e8b50e53dd2457044d1ba96278191e37)
 
I'm not sure how to check the code which triggers specifically those lines, but I guess it should be something in the ctrl_save_alarm_1 object (which does the saving):

GML:
/// @description Save

ini_open("save.ini");

// save resources
ini_write_real("Resources", 999, round(ctrl_resources.storage[999][2]));
ini_write_real("Resources", "products_count", ctrl_resources.products_count);

for (var i = 1; i <= ctrl_resources.products_count; i += 1)
    {
    ini_write_real("Resources", i, round(ctrl_resources.storage[i][2]));
    };

// save tower floors
ini_write_real("Tower", "floors", ctrl_tower.floors);


// save number of workers
with (obj_castle_floor)
    {
    if floor_number > 1
        {
        ini_write_real("Floor workers", floor_number, workers);
        };
    };


// save workers output and production
with (obj_castle_worker_product)
    {
    ini_write_real("Floor_" + string(floor_number), string(worker_number), output);
    ini_write_real("Floor_progress_" + string(floor_number), string(worker_number), progress);
    };


// save number of uncovered tiles
ini_write_real("Fog of war", "Uncovered tiles", ctrl_fog.uncover_count);


// saving camps
    // each camp saves itselft when created or upgraded
    // here - only save storage and progress


with (obj_map_forest)
        {
        if camp_built = 1
            {
            ini_write_real("Camps_resources", string(camps_order), resource);
            ini_write_real("Camps_storage", string(camps_order), storage);
            ini_write_real("Camps_storage_max", string(camps_order), storage_max);
            ini_write_real("Camps_progress", string(camps_order), progress);
            ini_write_real("Camps_level", string(camps_order), level);
            ini_write_real("Camps_progress_time", string(camps_order), progress_time);
            ini_write_real("Camps_progress_speed", string(camps_order), progress_speed);
            };
        };



// save position and progress of explorer
ini_write_real("Explorer", "x_pos", obj_map_explorer.x);
ini_write_real("Explorer", "y_pos", obj_map_explorer.y);
ini_write_real("Explorer", "speed", obj_map_explorer.speed);
ini_write_real("Explorer", "direction", obj_map_explorer.direction);
ini_write_real("Explorer", "sprite_index", obj_map_explorer.sprite_index);
ini_write_real("Explorer", "goal", obj_map_explorer.goal);
ini_write_real("Explorer", "goal_x", obj_map_explorer.goal_x);
ini_write_real("Explorer", "goal_y", obj_map_explorer.goal_y);
ini_write_real("Explorer", "destination_reached", obj_map_explorer.destination_reached);
ini_write_real("Explorer", "journey_started", obj_map_explorer.journey_started);
ini_write_real("Explorer", "exploration_progress", obj_map_explorer.exploration_progress);
ini_write_real("Explorer", "exploration_time", obj_map_explorer.exploration_time);

// save position and status of cart (in castle - map one will simply restart from castle)
ini_write_real("Cart", "collect_time", obj_castle_cart.collect_time);
ini_write_real("Cart", "collecting", obj_castle_cart.collecting);


ini_close();

alarm[1] = room_speed;
What I'm confused with is that it works fine on Windows, but not on Android... Any tips would be appreciated :)
 
Look like using 999 instead of "999" for the key is not acceptable to the android build. No automatic conversion to string.
Wow, good catch - yes, that was the only problem, now it works perfectly :) Thank you!!
 
Top