How Android Save Games work (UE4.27)

Your save game no longer works in your Android game? Probably you are using the Unreal Engine 4.27 and the Android Target SDK ’30’. Annoying, but not unsolvable, because that’s what we deal with in this article!
First of all, you should understand that your save system is not necessarily ‘not’ working, but that it mostly fails because of read or write permissions, or alternatively because your save system is not loaded correctly or in time.

Unreal Engine 4.27 - Android Save Game does not work - Target SDK 30

UE4.27 - Set Android Permissions

The Google Play Store requires all new Android apps to run on Target SDK 30 since mid-2021. This is possible with the Unreal Engine 4.27 and 4.26. However, a few small things have been changed in the file system, where your save system that you probably initialize in ‘Game Mode’ does not work.

Instead of initializing your save system in Game Mode, use the Game Instance, because it is always loaded first. This will prevent further errors. We will also check and request file permissions for Android in the Game Instance of the Unreal Engine 4.27. To do this, do the following:

  • Open your Unreal Engine and create a new game instance. If you have already created one, you can simply use it for this purpose.
    1. To create a Game Instance, go to the Content Browser and right click, now click on ‘Blueprint Class’.
    2. Click on ‘All Classes’ at the bottom and search for ‘Game Instance’.
    3. Click on ‘Game Instance’ and confirm at the bottom of ‘Select’.
  • Open your existing or created ‘Game Instance’ file.
  • Now add the event ‘Init’. Right-click on it and search for ‘Event Init’ in the search field.
  • Now pull out the Exec Output of ‘Event Init’ and search for:
    ‘Check Android Permission’ – Add this node.
  • On the right side you can also see the process as a picture.
  • In the node ‘Check Android Permission’ we now enter the External Storage Permission. We need this to check if the storage can be accessed.
    android.permission.WRITE_EXTERNAL_STORAGE
  • After the Branch Node, we will now add the ‘Request Android Permissions’ node at ‘false’, because otherwise we may not have the permission. This node has a string array input.
    Create a new variable (type: String Array) and add the following permission:
    1. android.permission.WRITE_EXTERNAL_STORAGE
    2. android.permission.READ_EXTERNAL_STORAGE
  • Next, pull out the ‘Return Value’ output from ‘Request Android Permissions’ and look for ‘Bind Event to Permissions Granted Dynamic Delegate’.
    • Connect everything as shown in the picture on the right.

Alternatively, you can simply copy this code here with CTRL+C and paste it into your Game Instance with CTRL+V:
https://defconnet.work/dl/tut/tutorial_android_savegame_permissions.txt

Android Target SDK 30 - Project Settings

Next, we need to change the Project Settings. This way we make sure that everything really works as desired. It is better to do something twice than to get an error message later.

  • Open your Unreal Engine Project Settings.
  • Select the item (left) ‘Android’ to enter the Android Platform Settings.
  • Change the ‘Target SDK Version’ here to 30, because this is currently required by the Google Play Store.
  • Also check the box ‘Use ExternalFilesDir for UE4Game files?’
  • If the SDK version 30 does not work for you (in the build), then you have to update your Android NDK and SDK version and update / edit ‘Android SDK’ under the UE Project Settings Menu.
UE4.27 Android Platform Settings Part 1
Android Platform Settings (1)
  • Now add the following below under the menu item ‘Advanced APK Packaging‘:
  • Go to ‘Extra Permissions’:
    • android.permission.WRITE_EXTERNAL_STORAGE
  • Now you can launch or export your game. From this point on, your save game should work without any further problems and should be able to store and retrieve data on your device. It can also happen that your cell phone or a security program sometimes prevents access to the external or internal SD card.
UE4.27 Android Platform Settings Part 2
Advanced APK Packaging (2)

Create Android Save Game

The Save Game can now be created as usual – only in the ‘Game Instance’. Create a Save Game Blueprint file and add it to the Game Instance. As an example you can have a look at the picture below (add this to the permission Event Init code from above) :

Video Tutorial

Comments & Feedback

Dear visitor, you are welcome to comment if it worked for you or not. Feedback is also always welcome to make the design and structure of articles more user-friendly. Please stay factual and friendly towards the author and other commentators. If you encounter a problem, please describe it as detailed as possible.
Click here to visit the German DerSky Discord Community (largest German Unreal Community).

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top