Runtime Error in LFS when build for android

While it works fine in the simulator, when build for android, the code returns a runtime error:

The (simplified so that it has only the error) project is at: https://github.com/koyan/dirtest
Steps to reproduce:

  1. Open the project in the simulator
    You should see the contents of the directory cards appear in the simulator screen
  2. Build for Android
  3. Install and run
  4. The the runtime error

Folder structure

cards/file1.lua cards/file2.lua main.lua

main.lua:

local lfs = require( "lfs" ) local doc\_path = system.pathForFile( "cards" ) textY = 100 for file in lfs.dir( doc\_path ) do -- "file" is the current file or directory name local filenameText = display.newText( file, display.contentCenterX, textY, native.systemFont, 40 ) filenameText:setFillColor( 1, 1, 1 ) textY = textY + 50 print ("The file is: " .. file) end

In the simulator it lists the files in the folder as expected, showing them on the screen.
When build, installed and run on android, it gives the following error:

Runtime Error

/full/path/for/the/folder/in/my/computer/dirtest/main.lua:8 bad argument for #1 to ‘dir’ (string expected, got nil)

Corona Simulator reports: Version 2020.3582 (2020.4.19)

Build with a macOs Catalina

I haven’t tested on other platforms

 

I have opened a bug about this, but I am posting here in case anyone else either knows the solution, or meets the same problem.

 

Update: It works fine if you build it with “Live Builds”, but it does not work without it. 

When you build for Android (or other platforms), all .lua files get compiled and you won’t be able to access the individual files afterwards.

That is weird, because the same code works if you do live builds. Which means that something in the build is different between live builds and local build.