So I’ve been trying to fix this problem for about a week now with no luck. I was making amazing progress on my game then stopped cold in my tracks by this issue. I’m really hoping that someone here will have insight into why this isn’t working. I was torn between posting this in the blueprint section or Android development. It is a little bit of both.
The issue:
My game will not save on Android. The game is saving perfectly within UE4 when playing in the viewport but scores are stuck at 0 on Android. I believe the save file is not being created properly.
Here is my blueprint function for saving the game (located in the level blueprint):
The blueprint is failing at the second cast to TopDownSaveGame right after the Load Game from Slot. You can see the “CAST 2 FAILED” print in the log below.
Here is the Android log. The save game file is not being created and/or not being found:
LogStreaming:Warning: Failed to read file '../../../TopDownMobileEating/Saved//SaveGames/Profile1.sav' error.
[2014.12.05-14.02.22:167] 0]LogBlueprintUserMessages: CAST 2 FAILED
[2014.12.05-14.02.22:167] 0]LogScript:Warning: Accessed None 'K2Node_DynamicCast_AsTopDownEatSaveGame_C'
NewMap_C /Game/Maps/NewMap.NewMap:PersistentLevel.NewMap_C_0
Function /Game/Maps/NewMap.NewMap_C:SaveGameSubmit:043C
[2014.12.05-14.02.22:168] 0]LogScript:Warning: Accessed None 'K2Node_DynamicCast_AsTopDownEatSaveGame_C'
NewMap_C /Game/Maps/NewMap.NewMap:PersistentLevel.NewMap_C_0
Function /Game/Maps/NewMap.NewMap_C:SaveGameSubmit:040D
[2014.12.05-14.02.22:168] 0]LogScript:Warning: Accessed None 'K2Node_DynamicCast_AsTopDownEatSaveGame_C'
NewMap_C /Game/Maps/NewMap.NewMap:PersistentLevel.NewMap_C_0
Function /Game/Maps/NewMap.NewMap_C:SaveGameSubmit:03DE
[2014.12.05-14.02.22:168] 0]LogScript:Warning: Accessed None 'K2Node_DynamicCast_AsTopDownEatSaveGame_C'
NewMap_C /Game/Maps/NewMap.NewMap:PersistentLevel.NewMap_C_0
Function /Game/Maps/NewMap.NewMap_C:SaveGameSubmit:03AF
[2014.12.05-14.02.22:168] 0]LogScript:Warning: Accessed None 'TopDownSaveGameObj'
NewMap_C /Game/Maps/NewMap.NewMap:PersistentLevel.NewMap_C_0
Function /Game/Maps/NewMap.NewMap_C:SaveGameSubmit:051E
[2014.12.05-14.02.22:168] 0]LogScript:Warning: Attempt to assign variable through None
NewMap_C /Game/Maps/NewMap.NewMap:PersistentLevel.NewMap_C_0
Function /Game/Maps/NewMap.NewMap_C:SaveGameSubmit:0534
[2014.12.05-14.02.22:169] 0]LogScript:Warning: Accessed None 'TopDownSaveGameObj'
NewMap_C /Game/Maps/NewMap.NewMap:PersistentLevel.NewMap_C_0
Function /Game/Maps/NewMap.NewMap_C:SaveGameSubmit:057F
[2014.12.05-14.02.22:169] 0]LogScript:Warning: Accessed None 'TopDownSaveGameObj'
NewMap_C /Game/Maps/NewMap.NewMap:PersistentLevel.NewMap_C_0
Function /Game/Maps/NewMap.NewMap_C:SaveGameSubmit:059F
[2014.12.05-14.02.22:169] 0]LogBlueprintUserMessages: SAVE GAME SUCCESS: false
[2014.12.05-14.02.22:169] 0]LogStreaming:Warning: Failed to read file '../../../TopDownMobileEating/Saved//SaveGames/Profile1.sav' erro
Please help!!! All of my progress has come to a screeching halt because this issue is stopping me from moving forward.
Thank you so much for your suggestions in advance!
Did you check that it saves in the editor? I had this problem before where too many variables from the save game where connected at once and it didnt save or recall corectly. I solved it by not calling not more than 3 variables at once.
Not sure what was the exact issue for this.
PS: And dont recall thousands of save games when the game starts for the first time, it crashes the game on many devices. At least that was, what I encountered.
Edit: Also it might be better to use loops as often as possible like in the flappy tappy example.
@spaceharry It saves in the editor perfectly, everything is exactly as it should be, the problem only comes up when I play a packaged build.
@ngrts File is created, just nothing is saved to it. The cast to my SaveGame BP always fails, even threw in a IsValid, and that says that my object isn’t valid. And PROFILE1 isn’t me, that was @tehhax.
Apparently my objects are valid in the editor, but not a package build. I’ve tried to get around it many different ways, to no avail.
I am also new to UE and so far I did only stuff for android. When I had problem loading around 21 saved values at games start with a sequence from the cast, I solved the problem in the following way.
There were always problems when I tried to recall more than 3 save variables at once. So I had to detach everything to triggervolumes (locating near player start) recalling 3 at a time
I am not sure if yours is the same problem or maybe this was only specific to my project. I hope this helps.
Edit: Maybe this setup isn’t also far from ideal, as it has everything in the level blueprint and is not utilizing loops, so better not take this as a good example ^^;
Hi tehhax,
I think that the cast fails because you are trying to load a save game from a slot that doesn’t previously exist. I also noticed that you are creating a new save game object each time your function is called, which is not correct, so I think that you should first check whether a save game exists or not (by using the ‘Does Save Game Exist’ block) and then implement something analog to the following sample:
I am unable to save game on android as well. “Save Game to Slot” Blueprint Node works fine in the UE4 Editor but returns false when packaged and installed on the android device.
Here are the details:
UE4.25.3
Android Minimum SDK: 19
Android Target SDK: 30
Install Location: Internal Only
Package Game Data inside .apk? - Checked
Use ExternalFilesDir for UE4Game files - Checked
Packaged Development Build with Project Launcher
Tried both - manually copied apk to device and installed/used bat file to install directly from pc
Android Device: Xiamoi Redmi Note 8 Pro
OS: MIUI 12.5.3
Android Version 11
You can also create a fresh project and package it with these settings. You’ll see that the “Save Game to Slot” works in editor but fails on Android.
Also please tell me how to access Android log files. I can’t seem to find them even after checking “Make log files always publicly accesible”