var file = FileAccess.open_encrypted_with_pass(save_path,FileAccess.WRITE, "hello") normally creates a save file for me when running from the editor. When I export to android and use logcat it says that this var is null... What am I doing wrong, is there like a special permission that I need toggle?
Using FileAccess.open_encrypted_with_pass doesnt create a file on android
the fileAcess thingy is haunting me...
- Edited
What's the value of save_path?
Also, when FileAccess.open() returns null, use FileAccess.get_open_error() to get the error code. That's often helpful.
var file := FileAccess.open_encrypted_with_pass(save_path,FileAccess.WRITE, "hello")
var err: Error = OK if file != null else FileAccess.get_open_error()
if err != OK:
print_debug("Failed to open file '%s' for writing, error=%d" % [save_path, err])
If that output isn't visible using logcat, put the text in a Label so that you can see it on Android:
$Label.text = "Failed to open file '%s' for writing, error=%d" % [save_path, err]
DaveTheCoder ik it returns error 7 which isn't helpful at all
which is: Error ERR_FILE_NOT_FOUND = 7
File: Not found error.
the path is:
var save_path = "user://saves/save.dat"
var save_path2 = "user://saves/save2.dat"
and im using your plugin
- Best Answerset by belgian_street_lamp
Did you create the directory "user://saves" using DirAccess?
- Edited
Hmm.. no, but it works when running the game from the engine
Edit: Yeah that is the problem, when deleting the saves folder from my computer there is the same issue as on android. I just don't know how to create that folder exactly
DaveTheCoder and how can I do that?
ok, you just need to do that DirAccess.make_dir_recursive_absolute(path).
I would do it this way:
var err: Error = DirAccess.make_dir_absolute("user://saves")