0 votes

Hi everyone.
My app loads data from user://data.json at startup, works perfectly on windows!
I included Json-File extensions on the export tab and export it to android.
But nothing seems loaded on startup. So i print the user://-path with OS.getuserdata_dir() and this directory doesnt exist!
So it doesnt write anything and obviously load nothing.
I have more json-files in the project, which you can load with a itemlist, on win it works perfectly, on android they are no json-files.
I have tested in on a smartphone and on a tablet with an older and a newer android-version.
What did i wrong? How it is going to work?

Godot version 3.2.3
in Engine by (14 points)

1 Answer

0 votes

Hello,

I may have this all wrong, as I don't know for sure, but I have managed to recreate sort of what you said above.
I have a file in user: on Windows, reads in to the Godot app, all is good.
Export the game to Android, run the app. No such file.

This is why I think that is.

The file only exists in user: on the Windows PC, as I put it there.
It exists in the res: directory on Android, as I exported the file as part of the project.
It doesn't exist in user: on Android, as I haven't put it there.

I don't know if there's a way of copying user: files as part of the project build, but I added a file copy as soon as the app launched and it worked as expected.

var dir = Directory.new();
dir.copy("res://test.json","user://test.json");
by (1,817 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.