1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

Android Android save file erased after updating app

Discussion in 'GameMaker Studio 2 Community Tech Support' started by Deeje, Dec 6, 2017.

  1. Deeje

    Deeje Guest

    I'm in the testing phase of my game, and I've noticed that when I update the app to a new version, save files can be erased. This is kind of terrifying, because if this happened to a live copy of the game I'd have people losing their progress.

    My method of saving is to write a ds_map to an .INI file. I do this to make hacking save files more difficult.

    I'm hoping this save file loss is just a glitch, but I want to do everything possible to ensure that I'm using the best method possible to save progress.

    How do you save progress in your Android game, and have you experienced any save files being lost?
     
  2. jcop

    jcop Member

    Joined:
    Dec 13, 2016
    Posts:
    57
    This is also happening on iOS. If you look at the compile output it executes a command to specifically uninstall the app from the device, then compiles and runs the app on the device. Uninstalling the app from the device deletes all locally saved content for that app. This is probably what is happening to you on Android. This is a fairly recent development as it did not happen in GMS2 prior to a few months ago. I'm not sure why it was added but I would love to have a way to turn off the "uninstall app" step in the mobile compile process.
     
  3. icuurd12b42

    icuurd12b42 TMC Founder GMC Elder

    Joined:
    Apr 22, 2016
    Posts:
    1,840
    It's always been like that since 1.4.... even windows installation will remove the current program including saved files. basically installing is a clean install each time.

    I don't know how to fix this. and yes a Clean Install vs Update option would be good to have
     
  4. Deeje

    Deeje Guest

    So what's the solution, aside from never releasing updates for your games?

    I'm not installing over USB, this is an actual APK update. The Android package installer recognizes it as an update to an existing app, so I don't understand why it would be doing a clean install.
     
  5. HW.

    HW. Member

    Joined:
    May 21, 2017
    Posts:
    207
    Is the .apk file having different update version e.g. 1.0.1 replaced by 1.0.2 ? or it is using the same number version so it is uninstalling first???

    This thread is important if saving file is deleted on android.

    I don't test it yet with the latest IDE. but months ago it works well.

    This thread needs BUMP! as it is important for android users having saved files.

    I am afraid of releasing update to my games that using saved files IF this is confirmed to be true!!!

    I will test with my app too! will post again later.

    Once again, This is very important. I do not want ever to make my game players angry that by updating new version of the game will delete their game progress, it is a very bad idea "if happens"!

    ~will post again after i have tested my app..
     
    Matt Hawkins, stigmund77 and rIKmAN like this.
  6. stigmund77

    stigmund77 Member

    Joined:
    Nov 23, 2016
    Posts:
    40
    Can somone confirm this is hapoening on all platforms? Seems like a major issue
     
  7. HW.

    HW. Member

    Joined:
    May 21, 2017
    Posts:
    207
    Hello again, i have just finished my experiment regarding this problem.

    apksavemarshmallow.jpg apksavejellybean.jpg

    As you can see from the uploaded images above, I use two methods: ini (only), and ds_map_secure_save (only).

    Here the example codes i am using for that test:

    =============== INI saving ===============
    savegame to ini (list of GML codes used)

    if (!file_exists(filename))
    {
    ini_open(filename); // open file
    ini_write_real(example,et,cetera); // write data to file
    ini_close(); // close file
    }

    loadgame from ini:

    ini_open(filename); // open file
    ini_read_real(example,et,cetera); // read data
    ini_close(); // close file


    =============== DS_MAP saving ===============
    savegame:

    var map = ds_map_create();

    map[? "high_score"] = global.high_score;
    map[? "coins"] = global.coins;
    ds_map_secure_save(map, "settings.dat");

    ds_map_destroy(map);

    loadgame:

    var file = "settings.dat"
    if(file_exists(file)==true)
    {
    var map = ds_map_secure_load(file);

    global.high_score = map[? "high_score"];
    global.coins = map[? "coins"];
    }
    else
    {
    var map = ds_map_create();
    map[? "high_score"] = global.high_score;
    map[? "coins"] = global.coins;
    ds_map_secure_save(map, file);
    }

    ds_map_destroy(map);

    ====================

    From my tests. It keeps the saved file!
    (please see uploaded images for the Android, SDK setings, IDE version, etc)

    *Please note that the method i did might be different with Deeje's two steps method. He said his method of saving is to write a ds_map and then to an .INI file ? (CMIIW) And also maybe different versions and settings he used? please add more details.

    I am using only one method (ini only or ds only) for each game. I hope my tests could help to find the cause or at least narrow the bug search.

    I am open to other confirmations / findings regarding this problem from @Deeje and others, as i stated before that it is important if it happens.

    Edit: typo and grammar fix lol, sorry for my unique english :p.
     
    Last edited: Dec 9, 2017
    rIKmAN likes this.
  8. Deeje

    Deeje Guest

    The Android package installer does say your files will be kept intact. In my testing, plain text INI files have never been overwritten but I have had INI files holding a ds_map erased. The problem in tracking this down is that I can't replicate the bug, it just seems to happen occasionally.

    It's possible there is a bug in my load script, so I'll dig into that. I used ds_map to INI because my game saves after every move and I thought ds_map_secure could cause a slight lag. Too late to switch over now :confused:

    Good to know about the iOS save bug as I'm about to port my Android title. Cloud saving may be the most failproof solution. Thanks for your detailed tests @HW.
     
    HW. likes this.
  9. Pushloop

    Pushloop Member

    Joined:
    Jun 22, 2016
    Posts:
    149
    It happened to me when updating from 1.4 to 2. Even if the android preference "always do a full install" is unchecked, it still overwrites the .ini file. Worked fine before in 1.4. Is this bug still unsolved?
     
  10. Pushloop

    Pushloop Member

    Joined:
    Jun 22, 2016
    Posts:
    149
    I'm sorry to bump this, but my android save .ini files are overwritten when updating the .apk. and I can't find a solution. This is a disaster for the games I have in Google Play, which I can't update now. If anyone has a solution. The above solution doesn't work for me.
     
  11. rwkay

    rwkay YoYo Games Staff YYG Staff

    Joined:
    Apr 12, 2016
    Posts:
    1,049
    any overwriting of save data is done when a new APK is installed, it is an option on ADB when an APK is installed - we should only be doing this when the option in File -> Preferences -> Platform Settings -> Android -> Packaging -> Always do Full Install of APK (this will wipe save data of the game when it is selected).

    Any other time it is happening it will be the method used to install the APK (there appear to be numerous ways in which the APK could be side loaded by the user) - but Google Play should not uninstall the application first before installing an update (though the user may uninstall the application first before updating, but that is up to them).

    Russell
     
    MarceloP likes this.
  12. Pushloop

    Pushloop Member

    Joined:
    Jun 22, 2016
    Posts:
    149
    thnx russel, I have the "always do full installs" unchecked. Before, on 1.4, I could build an APK and update it locally on my test device, which would overwrite the installed store APK on that device, without touching the .ini files. Saved game data was still there. With 2.0 ( or it seems ) the .ini get overwritten.

    If you're saying that apk updates from google play treat the current installed version different, then there is no other way to test it, but to put it live. That's way to uncertain for me. Lot's of users might lose their progress.
     
  13. icuurd12b42

    icuurd12b42 TMC Founder GMC Elder

    Joined:
    Apr 22, 2016
    Posts:
    1,840
    Correct me if I'm wrong but ain't this setting target OS dependant? I vaguely recall some OS (versions) always do a full install
     
  14. Pushloop

    Pushloop Member

    Joined:
    Jun 22, 2016
    Posts:
    149
    With android you can choose to do a full install or not, but that doesn't seem to matter. I wonder if the apk's are treated differently , installing from a local build or from google play store.
     
  15. Mr. RPG

    Mr. RPG Member

    Joined:
    Jun 20, 2016
    Posts:
    37
    Does this happen when a game is updated from the app store or is this issue only relevant when testing the game from GameMaker?
     
  16. Pushloop

    Pushloop Member

    Joined:
    Jun 22, 2016
    Posts:
    149
    it happens when running from GameMaker or when building an apk. I don't want to test through the google play store.
     
  17. Pushloop

    Pushloop Member

    Joined:
    Jun 22, 2016
    Posts:
    149
    with the latest update of Gamemaker 2.1.4, this bug is solved!
     
  18. clee2005

    clee2005 Member

    Joined:
    Jun 25, 2016
    Posts:
    218
    This has been happening to our games for awhile now. I don't believe it's solved, although I can't be sure what the issue is exactly since I cannot reproduce it. I just had a user email me saying that she lost all her progress after updating from the Amazon App Store. I save with ds_map_secure_save() and for the most part it works, but I have may reports of lost data still. I'm constantly looking for a new solution on this... so far, cloud saving seems to be the only way to prevent lost data. That of course has it's own problems with the different stores involved.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice