Hello. I decided on a simple text download from res:// on Android. As far as I understand, there is no direct way to load a text file on Android. To do this, I used JSON, which is so simple. :
[gd_resource type=“JSON” format=3]
[resource]
data = “some text 10+ kb”
we load it using the function:
func get_text_privacy(conf_path : String) -> String:
if !ResourceLoader.exists(conf_path):
return conf_path + " no exists"
var js = ResourceLoader.load(conf_path)
if js == null:
return conf_path + " file is empty"
return js.get_data()
Everything works in the debug version. Release date - crashes when var js = ResourceLoader.load(conf_path) . What’s wrong. Or how can I download 10+ kb text from res:// to Android?
Make sure that *.json (or the file extension) files are exported in Exporting>Sources, then just use load(“config.json”). It is that simple, no need to use custom Resources.
If that doesn’t work, try FileAccess.
But, it is weird that it crashes. It seems like you have proper error handling. Maybe try to do it in a Thread if it is really a big file?
The files are exported. The thing is, when I export the debug version, everything works. And when the debug export is disabled, the game crashes. Godot itself does not issue any errors. Logcat points to /data/app/ru.krocknarock.mur-ALHV9D_D-mvZPVwYE56NMA==/lib/arm64/libgodot_android.so. I do not know what to do about it. Also, when the device crashes, it is suggested to send a report stating that the problem is with rendering or an infinite loop.
I use my own template for the build. But if the problem was with the template, then it wouldn’t work either in the debug. Using tracing, I found out that the game crashes on the line var js = ResourceLoader.load(conf_path).
It could be so many things beyond file loading since it’s a dreaded Release vs Debug bug. As you know, you don’t run the same code (let’s forget debug symbols) in debug and release builds : debug usually has no optimizations, release does, possibly at varying levels, in the same app. Stuff that is initialized to zero in debug becomes null pointers in release, racing conditions can be triggered because of a different execution speed and different object code for the same high level code path.
Can you build a minimal app as MRP that does nothing but load that file and still crash ?
And that’s only one avenue, the debug vs release thing.
Oh-oh. Yes, I should have checked it right away on a clean project. Everything works in the Steam version. It looks like I did something wrong with the project. Thanks to all who responded. The topic can be closed.