Custom resources not being included when building for Android? (SOLVED)

I have a copy of engine on Android device. I do project->build, build is uploaded to device, a custom resource (a .txt file) listed in the game.project cannot be loaded - works on Windows.

I tested two versions of .txt file one very small and didn’t help.

The file is being loaded with io.open which is probably why it’s not working?

What’s best way to iterate lines with sys.load_resource loaded file?
I was using for line in file:lines() do previously…

Used this

1 Like

Yes, that is correct. Custom resources should only be accessed via sys.load_resource().

string.gmatch() will generate an iterator function. Something like this for lines of a string:

for line in s:gmatch("(.-)\n") do
  -- do stuff
end
2 Likes

Posting in case this helps someone someday…

I had a text file which was Unix (LF) and changed it to Windows (CR LF).

When it was LF the code worked, but when it was saved in an editor which made it CR LF it stopped working and I didn’t notice for a while until I tried to use the code again for a few hours wondering why unchanged code no longer worked… so pay attention to your text files!

:gmatch("(.-)\r\n")

Would be for Windows (CR LF)
CR = \r; LF = \n; CRLF = \r\n

5 Likes