Android Cloud Saving on Android

Discussion in 'Tutorials' started by Appsurd, May 30, 2017.

  1. zbox

    zbox Member GMC Elder

    Joined:
    Jun 21, 2016
    Posts:
    793
    I was just saying that my asset uses the underlying saving mechanism in Gamemaker for the android component for GMS2 - Giving me the credibility to confirm that it works in GMS2 as the other user asked... I think you misread something
     
  2. Appsurd

    Appsurd Member

    Joined:
    Jun 20, 2016
    Posts:
    232
    Ah okay, I misunderstood. Thanks for your confirmation!
     
  3. J_Dev

    J_Dev Member

    Joined:
    Aug 9, 2016
    Posts:
    42
    How do we check if a cloud file exists? For example if it's the first time the user has run the game, what will the async status return (seeing as there is not yet a file uploaded)?
     
  4. Appsurd

    Appsurd Member

    Joined:
    Jun 20, 2016
    Posts:
    232
    Hi, good question indeed! Note that when following the tutorial and applying all steps, you can simply try this out ;)
    I can't test this now, but I'm pretty sure that the callback will be an empty string "". When saving a file, Google converts this into a long string as well, so when there is nothing available, it simply returns "".
     
  5. J_Dev

    J_Dev Member

    Joined:
    Aug 9, 2016
    Posts:
    42
    Thanks for the reply. Yeah I am intending to test it myself I'm just not up to the point of my project that I am going to implement it yet. I was just curious since I was theorycrafting how I would use the first loading technique on paper (synchronizing when the user starts the game) and was thinking that checking if a file exists is a good start.
     
  6. Appsurd

    Appsurd Member

    Joined:
    Jun 20, 2016
    Posts:
    232
    Certainly, it's a good practice to first make a plan :) In case you have any further questions, don't hesistate to ask them :)
     
  7. gdkid

    gdkid Member

    Joined:
    Sep 22, 2016
    Posts:
    32
    Hi PeliStar

    Thanks for the tutorial, I'm studying it. :)

    I have a question about the synchronising process.

    Could you please explain the difference between "description" and "resultString" in cloud_synchronise() command?

    Because in YoyoGames's Help example, it says that the data is retrieved from "resultString"

    https://docs.yoyogames.com/source/dadiospice/002_reference/cloud services/cloud_synchronise.html

    However, in your tutorial, the data is retrieved from "description"

    var data = ds_map_find_value(async_load, "description")

    I'm new to this stuff, so a little bit of confusion :)
     
  8. Appsurd

    Appsurd Member

    Joined:
    Jun 20, 2016
    Posts:
    232
    Hi, great you liked the tut!

    Description simply means information for you (the developer) to keep track of what is being stored. Not quite useful in my opinion, as "you can only store one single "data blob" to the cloud" ~https://docs.yoyogames.com/source/dadiospice/002_reference/cloud services/cloud_string_save.html

    As for saving, string is the argument I use for the actual data to be stored, which is the correct way.

    As for the Loading of the Description key, this indeed feels very bad, but I remember it was a GMS 1.4 bug. You could not load the ResultString, but had to load Description instead, which gave the correct result (i.e. Description contained the value/content of ResultString). Since I don't know what exactly has been updated in GMS 1.4 since I wrote it, I do not know if this has been fixed. When you experience problems with this, try it the 'good' way as the manual suggests, and if it works, please report it to me so I can change the tut :)
     
  9. KatoneVi

    KatoneVi Member

    Joined:
    Nov 9, 2016
    Posts:
    21
    follow the tutorial. You gotta do the Achievement_init method call (or whatever it's called) to initialize the connection.

    // Even though you don't have achievement, this performs the connection to Play Service
    if (achievement_available()) {
    achievement_login();
    }


    You'll then have to deploy the game on Google play and install it from there... at least I had to on my end... in order to log onto Google play properly...
     
    Last edited: May 18, 2018
  10. KatoneVi

    KatoneVi Member

    Joined:
    Nov 9, 2016
    Posts:
    21
    I did ran into one issue....

    1. I have to DEPLOY THIS on Googleplay to be able to log onto to Google play service... else it will say "Failed to login". This takes 30 minutes per time I want to patch anything. Am I doing something wrong?

    2. When I click a button to call cloud_syncrhonise. .. the game crashes. Google play report that it is an IllegalStateaexveption. Any idea?

    Edit: Could it be because I didn't fill out the Google Drive API configuration?
    https://console.developers.google.com/apis/dashboard -> "Enable APIS AND SERVICES" -> "Google Drive API" -> "Manage" -> "Drive UI Integration"

    It works now... but I don't know if it is because the "Driver UI Integration configuration" or the May 17 2018 GMS2 Google Play Service update. Will get back with an answer.

    Thanks
     
    Last edited: May 19, 2018
  11. Appsurd

    Appsurd Member

    Joined:
    Jun 20, 2016
    Posts:
    232
    Hi thanks for your message and for trying our the tut!

    This is about cloud saving, and you need to use Google account for all that, so maybe that's why?
    Anyway, I don't quite get your last comment, as you can test out patches offline (without uploading) right? I guess you won't need to test/try the tutorial more than 3 times?

    Aha, a GMS 2 user. Perhaps it explains the problem, because I never tested this with GMS 2. And that update, well, it could be the problem as well. At least Yoyo added Rewarded Ads (which is great) I hope they didn't break more features...
    I'm afraid I can't say much more right now, so if you can test some things, that would be great. My switch to GMS2 will probably take at least ~3 months but maybe longer, so waiting for that is a bad idea :)
     
    Last edited: May 22, 2018
  12. zbox

    zbox Member GMC Elder

    Joined:
    Jun 21, 2016
    Posts:
    793
    I don't think that would be the issue, I'm looking at your tutorial and it follows a pretty similar way to what I do for the android component of my asset. Works fine!
     
  13. gdkid

    gdkid Member

    Joined:
    Sep 22, 2016
    Posts:
    32
    Yeah, I beleive it's the GMS 1.4 bug, because when I used Description with your tut, it's OK, but when I switched to ResultString, it had error. So the manual sucks :)
     
  14. Appsurd

    Appsurd Member

    Joined:
    Jun 20, 2016
    Posts:
    232
    Alright, that's solves the issue. Thanks for posting!
     
  15. KatoneVi

    KatoneVi Member

    Joined:
    Nov 9, 2016
    Posts:
    21
    I was running into an issue where it just wasn't working. I'm not sure if it is now working because:
    1. GMS2 Google Play Services extension update on May 17 2018

    2. I configured the Google Drive API
    https://console.developers.google.com/apis/library/drive.googleapis.com

    When I configured the API, it wasn't working. 24 hours later it worked... I'm not sure if it is because of the update or because I configured it. I did both... It works now.
    Thanks for the tutorial!
     
    Appsurd likes this.
  16. Appsurd

    Appsurd Member

    Joined:
    Jun 20, 2016
    Posts:
    232
    Thanks for mentioning, I will keep it in mind when the tutorial will be updated to GMS 2.
     
  17. Leonardo007

    Leonardo007 Member

    Joined:
    Dec 28, 2017
    Posts:
    8
    Hello, now i tried it again.... login works, but i get no message like this :
    if achievement_login_status() show_message_async("Google Play Games login OK"); <------ (But google play is poppimg out and gives no error)

    another problem: if i save, i get only the message: save_check = 3

    if i sync i get the message : cloud_check_file = 5

    i made all things right (i guess ^^) .... i use the GM2.... i checked ALL permissions... enabled google services and google cloud saving and enteret the right id...

    regards
    ...
     
  18. Appsurd

    Appsurd Member

    Joined:
    Jun 20, 2016
    Posts:
    232
    Hi, it's a pity you still can't get it to work. Did you already read this post, which is just above yours?
    It might work for you to investigate if you updated to the latest version AND enabled the Google Drive API.

    Apart from that, it actually seems you did everything right. Strange it doesn't show a popup, but maybe there is at least a debug message?[/QUOTE]
     
  19. Greys0n

    Greys0n Guest

    Great tutorial. I know one company that have a good reputation when it comes to the cloud services. My company closely cooperated with https://www.infopulse.com/services/software-engineering/ on creation of one of such services.Moreover thay have over 10 years of cloud experience and provide 24/7 operations and support.
     
    Last edited by a moderator: Jun 25, 2018
  20. Appsurd

    Appsurd Member

    Joined:
    Jun 20, 2016
    Posts:
    232
    Greys0n likes this.
  21. Moises Abraham

    Moises Abraham Member

    Joined:
    Dec 27, 2017
    Posts:
    12
    Hello Appsurd ^^ I have followed your tutorial and checked everything to see if I did correctly. Im using GMS1.4. The game launched, google play games seemed to login okay... but when I press to save a file I only get a strange message that has nothing to do with what I was actually saving. The same happens when I try to sync the vars... now using the save file button gets me the same messages but does change the score, however if I delete the app and install it again as you instructed and then press to sync the file... I get the strange message again and nothing changes. Please haaalp D:
     

    Attached Files:

  22. Appsurd

    Appsurd Member

    Joined:
    Jun 20, 2016
    Posts:
    232
    Hi there, don't worry, those messages are normal. They are to be found in the HTTP event, and show if something has been sent/received at all. So perfectly normal behaviour!

    About your issue, it looks to me as if everything is working correctly, but you may have applied the wrong order of events. Would you mind trying it one more time, including the specific behaviour at each step? If it still doesn't work, please report them here so we can look and see if it can be resolved! Good luck!
     
  23. Moises Abraham

    Moises Abraham Member

    Joined:
    Dec 27, 2017
    Posts:
    12
    I think I did both times in the correct order. The images on my previous post were only displaced at a different order because I uploaded them all at once. Anyay I did the test again... installed the app, waited for the login to be completed, hit the "save file" button, my input was "335", I got a message "save check = 1", score now becomes "335". Then I close the app, uninstall it. I Install the app again, run it, wait for the login to be complete and then hit "Syncronise file" button... I get a message "cloud_check_file = 1"... score remains 0.

    So now I want to know if this is the behaviour it was supposed to have or if I may be missing something like... where to get the actual information that I supposedly saved on the cloud on the last try, which would be a string containing "335". Thanks for the fast answer mate ^^
     
  24. Appsurd

    Appsurd Member

    Joined:
    Jun 20, 2016
    Posts:
    232
    Hmm that seems unwanted behaviour indeed. Could you send me your project via PM? Then I'll check it for you and hopefully we can resolve the issue
     
  25. Moises Abraham

    Moises Abraham Member

    Joined:
    Dec 27, 2017
    Posts:
    12
    I'll send it now
     
  26. Loganout

    Loganout Member

    Joined:
    Oct 7, 2018
    Posts:
    2
    Why not create with an ini file?
    I could not understand much. My database is saved locally to an INI file. I downloaded your example and tried to implement, but nothing worked.
    I want to save it on Google Cloud and rescue it when reinstalling the game.
     
  27. Appsurd

    Appsurd Member

    Joined:
    Jun 20, 2016
    Posts:
    232
    You can perform the same procedure for INI files, so probably something went wrong along the way. Please try the Marketplace example, then use the File option. Also, carefully reread chapter 4. Then it should work. If it doesn't, please tell me and we will sort it out!
     
  28. Adriano_ppaula

    Adriano_ppaula Member

    Joined:
    Jun 22, 2017
    Posts:
    24
    Hello Appsurd!
    I wanted to thank you from my heart for your tutorial, it was my salvation for my project!

    However, I am going through a problem that I can not solve.

    I use GM 1.4 and follow your tutorial correctly. It's working perfectly!

    But lately this is only working for old users, all new users no longer work.

    The application crashes when I use cloud_synchronise ().


    I'm pretty sure this is because of the update from google to google drive api for drive REST API, but I can not solve it at all.


    Just like all new players who come into my game the app closes when using cloud_synchronise (). While the old works perfectly.
     
    Last edited: Mar 26, 2019
  29. Appsurd

    Appsurd Member

    Joined:
    Jun 20, 2016
    Posts:
    232
    This might (and is probably) due to using an outdated version of the Google Play Services extension. Luckily, we are currently investigating this (as part of our tutorial on Google Play Services Fixes) and we hope to present a solution near the weekend. Stay tuned!
     
  30. Adriano_ppaula

    Adriano_ppaula Member

    Joined:
    Jun 22, 2017
    Posts:
    24
    Thank you! I was wondering, because after this update cloud_synchronise () in my project stopped working. I updated all the features and configured everything correctly.
    But thanks for the tip. I'll stay in the waiting and if I can get any information I'll put it here to help the staff ^^
     
  31. Schekhovtsov

    Schekhovtsov Member

    Joined:
    Feb 8, 2019
    Posts:
    38
    Hello. The last thing after which my friend and I can upload our game to the store is Google Play Services cloud saves / load.

    Unfortunately, only the message boxes works. Checkboxes are in the GMS2 and in the console (according to the instructions). Tell us, what are we missing?

    The code in the asynchronous cloud event is:
    Code:
    if ds_map_find_value(async_load, "id") == cloud_check_file
    {
        if ds_map_find_value(async_load, "status") < 0
        {
            show_message_async("Cloud Services not available.");
        }
        else
        {
            if ds_map_find_value(async_load, "status") == 0
            {
                   //Load
            alarm[10] = 2; // analogue of the load script
            }
        }
    }
    The code in the click:
    Code:
    // Load
    if achievement_available()
    {
        with(ob_services)
        {
            cloud_check_file = cloud_synchronise();
            show_message_async("cloud_check_file = "+string(cloud_check_file));
        }
    }
    
    // Save
    if achievement_available()
    {
        //Save
            alarm[9] = 2; // analogue of the save script
        //Cloud Save
        with(ob_services)
        {
            save_check_file = cloud_file_save("svData.ini", "Save done!");
            show_message_async("save_check = "+string(save_check_file));
        }
    }
    P.S. Authorization in Google Play Games, achievements and high score tables works fine.
     
    Last edited: Apr 26, 2019
  32. Appsurd

    Appsurd Member

    Joined:
    Jun 20, 2016
    Posts:
    232
    It's a good (and cool) feature to have! Unfortunately the implementation is sometimes a little difficult.

    Good to know. The "logging in" is therefore working properly, and the erorr should be really in the saving / loading script.
    I don't really understand what you mean by message box? Neither I understand Checkboxes are in the GMS2 and in the console.

    Your code looks fine. However, I would recommend to somehow use/save the result you got back from loading the file. Or is a part of the code missing?
     
  33. Schekhovtsov

    Schekhovtsov Member

    Joined:
    Feb 8, 2019
    Posts:
    38
    Message boxes are show_message_async. Checkboxes are the inclusion of the cloud storage function on the Social tab in GMS2 and the "enable cloud storage" in the Google Play Console. Saving the result of asynchronous events is not implemented.
     
  34. Appsurd

    Appsurd Member

    Joined:
    Jun 20, 2016
    Posts:
    232
    Aha that helps :)
    Since the game shows show_message_async, the functions cloud_synchronise and cloud_file_save() are called correctly.
    So my question is: what is exactly not working? All seems okay to me
     
  35. Schekhovtsov

    Schekhovtsov Member

    Joined:
    Feb 8, 2019
    Posts:
    38
    There is no saving and loading of data.

    When adding here
    ULAwETQ0pAc.jpg
    Code:
    show_message_async("Test");
    The message is not shown. Accordingly, the synchronization code, most likely, is also not executed.

    Now when you click on the save button, a message box appears with the text: "save_check = 6", on the download button - "cloud check file = 13". Subsequent pressings change the numbers.
     
  36. Adriano_ppaula

    Adriano_ppaula Member

    Joined:
    Jun 22, 2017
    Posts:
    24
    I'm trying to make it work again on GM 1.4, and that's exactly what it's all about. I believe this is occurring because of the deactivation of the Google + API ... I think.
     
  37. Schekhovtsov

    Schekhovtsov Member

    Joined:
    Feb 8, 2019
    Posts:
    38
    Hello! I have good news. Not without help, but the cloud storage problem has been solved.

    Here is the THIS (in the screenshot) code is required! It is surprising that the author of the topic did not pay attention to this.

    [​IMG]

    It all worked for us. Thank you all for your help!
     
  38. Appsurd

    Appsurd Member

    Joined:
    Jun 20, 2016
    Posts:
    232
    @Schekhovtsov Sorry for my (too) late reply. Your question and answer however surprise me, as I have written this exact same solution in Chapter 4 of the tutorial:
    Code:
    if ds_map_find_value(async_load, "id") == cloud_check_file
    {
        if ds_map_find_value(async_load, "status") < 0
        {
            show_message_async("Cloud Services not available.");
        }
        else
        {
            if ds_map_find_value(async_load, "status") == 0
            {
                // Saving a file
                var data = ds_map_find_value(async_load, "description");
                show_message_async(data);
               
                var file = file_text_open_write("dsmap.dat");
                file_text_write_string(file, data);
                file_text_close(file);
               
                scr_dsmap_load();
            }
        }
    }
    
    
    Alright, it is hidden under a spoiler, but it is covered by the tutorial. Moreover, the example on the Marketplace also contains this code.
    Anyway, great you fixed the problem and have fun developing!
     
  39. Schekhovtsov

    Schekhovtsov Member

    Joined:
    Feb 8, 2019
    Posts:
    38
  40. Appsurd

    Appsurd Member

    Joined:
    Jun 20, 2016
    Posts:
    232
    It appears there was an issue, and it should be fixed in version 3.1.7. Still, as you said correctly in that topic, version 3.1.7 was not really released, so we are waiting for YoYo to release that version and hope that the issue is resolved.
     

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