Strange android "require"

Strange android "require"
0.0 0


In my project, DIR tree like below:





I use “require” to import “people” and “plane” in main.lua like this:

Cpeople = require “base.people”
Cplane = require “base.plane”

It works normally in win32 debug.
But when I make APK and run in android device(HTC G12).
I find Error Msg like this:

Get data from file(assets/base.people.lua) failed!

It seams “require” loader did not tranfer [base.people] into [base/people.lua].
did somebody met this before? :frowning:


require “base/people”

I think the problem is that the period is not changed into a / on android.

for example using:

require “luaScript/ActionsTest/ActionsTest”

works in the examples

By the way the Lua documentation does not seem to imply that period are translated into / but that the translation is done for C path and that the translation is to *.

For instance, when requiring a.b.c, it will search for a C library for a. If found, it looks into it for an open function for the submodule; in our example, that would be luaopen_a_b_c.
I am surprise that the window*loaders_ supports translation from . to /.

Good luck



it’s solved.
Change loader_Android(lua_State *L) in Cocos2dxLuaLoader.cpp


for( int i=0, ii=filename.length(); i<ii; i++ )
if (filename[i] == ‘.’) filename[i] = ‘/’;