The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

i have some text (.txt) files present in res:// of my project and they are accessible in debug version of apk but they are not accessible in release version of apk.
How to fix this ?

in Engine by (753 points)

2 Answers

+1 vote
Best answer

.txt by default is not a "resource format". so you need to add it to your "non resource files to export".

open your Project->Export settings, select your preset, go to the Resources tab, then in "Filters to export non-resource files/folders" add *.txt. rinse and repeat for all your export presets.

the reason it works in the debug version, is either because the debug version tries to include everything just to be safe, or uses the remote file system API to talk to your editor to access those files from your computer.

by (92 points)
selected by
+1 vote

Hello,
I don't know exactly what your project is like but i think it might help you to relocate the files in ".txt" format inside the code and you probably wouldn't make it not accessible for the apk file, as by default the code compiles it in ".gdc" and also in ".gd.remap" (if you use GDScript, of course).
I don’t know the cause of this problem, but I hope this advice helps you.
Mxt08 :)

by (353 points)

i also don't know what their project is like, but often text files are used for things like credits, story blurbs, etc, which should be loaded by both the game and shown on a website etc, so often it makes sense to only keep one copy of that around, and editing larger texts inside a gdscript can be pretty messy.

for example i have a CREDITS.txt and LEGAL.txt file inside my latest project which can (in theory) be read both on the project's gitlab page (which is set to private, so in practice it probably wont) and by my code to display the credits (which is where players will see it). just easier to type stuff like that into a text file (technically markdown, even made a rudimentary markdown-to-bbcode parser to render that to a RichTextLabel :P) than just vomiting it right between your code :P separation of data and code being a thing and all that.

plus unless you encrypt your package, long texts inside .gdc files can still be perfectly read out using a tool looking for ascii sequences such as strings. and if you encrypt it it should also encrypt the .txt file packed inside it so that should be fine.

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 Frequently asked questions and 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 [email protected] with your username.