Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load lua files from apk #7

Open
o-khotskin opened this issue Mar 9, 2013 · 2 comments
Open

load lua files from apk #7

o-khotskin opened this issue Mar 9, 2013 · 2 comments

Comments

@o-khotskin
Copy link

I'm trying to use OpenQuick with Android but get the runtime error: "Failed to load QConfig.lua file".
Most likely, it is because 'luaL_loadfile' function can't load files from a apk archive.

@timcloss
Copy link
Contributor

timcloss commented Mar 9, 2013

You are right. Lua uses standard C I/O functions like fopen(), fread(). Whilst these compile with the Android NDK, they can only open/read assets that have already been decompressed to somewhere on the device filesystem... they cannot read them directly from the compressed APK.

Your best bet is probably to write some Java code that decompresses the contents of the APK's resource folder to disk, then the Lua file operations should behave themselves.

e.g. Google "Android fopen", for discussions like this: http://stackoverflow.com/questions/1992953/file-operations-in-android-ndk

@o-khotskin
Copy link
Author

I'm new in Android programming, but I think extracting apk's content to a disk is not good practice. May be it will be better if OpenQuick extracts lua files to the memory and then executes it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants