Android, resourceDirectory and lfs.dir

So, as is documented, Android doesn’t have resourceDirectory due to the resources actually being in an .APK and thus will only be extracted if required. However, this means that we cannot figure out what is in a directory on Android at all - as lfs.dir will not work as there is no directory to scan through.

Is there any other workaround than generating the filelist manually every time a file is added? Custom build steps would be pretty useful (and simple to do) for this (not to mention a lot of other stuff), even if adding system.getFilesInPath() is too much to ask.

Im having the exact same issue. My use case is I have a game with a config directory in which I drop additional level files as I add on to the game. The game automatically detects the files and loads the levels.

Yet on Android this is broken. Is there even a workaround for this type of situation?

It’s not a bug.  On Android, your resource files are inside of an APK file… and an APK is really a zip file.  This means that you don’t have direct file access.  Corona’s resource directory on Android merely provides virtual access to your resource files and is not really a directory.  Which also means LFS will never work with the resource directory on Android.  You’ll have to hard code the file names.

Correct, it’s not a bug - more of a feature request. Reading the directory from the zip shouldn’t be impossible, but even the suggested solution - hardcoding - would be easier if there was a way to do a custom build step, even just running a .bat or something and should be pretty trivial to implement?

Currently, there is no work-around… except via Corona Enterprise which I think is overkill for something like this.

In the future, we want to experiment with adding the ability for Lua to make Java calls on Android and have access to the Android Java framework.  This will allow Corona developers to use native features that we do not expose via Lua.  The only issue with this is that it won’t be cross-platform, but then again, resource files are handled completely different between iOS and Android.  So, perhaps it can’t be helped.

Im having the exact same issue. My use case is I have a game with a config directory in which I drop additional level files as I add on to the game. The game automatically detects the files and loads the levels.

Yet on Android this is broken. Is there even a workaround for this type of situation?

It’s not a bug.  On Android, your resource files are inside of an APK file… and an APK is really a zip file.  This means that you don’t have direct file access.  Corona’s resource directory on Android merely provides virtual access to your resource files and is not really a directory.  Which also means LFS will never work with the resource directory on Android.  You’ll have to hard code the file names.

Correct, it’s not a bug - more of a feature request. Reading the directory from the zip shouldn’t be impossible, but even the suggested solution - hardcoding - would be easier if there was a way to do a custom build step, even just running a .bat or something and should be pretty trivial to implement?

Currently, there is no work-around… except via Corona Enterprise which I think is overkill for something like this.

In the future, we want to experiment with adding the ability for Lua to make Java calls on Android and have access to the Android Java framework.  This will allow Corona developers to use native features that we do not expose via Lua.  The only issue with this is that it won’t be cross-platform, but then again, resource files are handled completely different between iOS and Android.  So, perhaps it can’t be helped.