私の Lua スクリプトはLOOPによってコンパイルされ、コンパイルされたスクリプト モジュールはデスクトップ マシン (OSX 10.7.5) で適切に動作します。しかし、Androidフォン(Android 2.3.6)で実行すると、常に失敗し、文句を言いattempt to call a string value
ます. 同じスクリプトは、同じ電話でスクリプト (コンパイルされていない) の方法でも問題なく実行できます。
テストでは、Lua 5.1.5 と Android NDK r8b が使用されます。
logcat のエラー:
12-26 09:40:26.934: E/libb22luapre(8190): Failed to run script: attempt to call a string value
C コード スニペット (簡略化のためにエラー処理コードを削除):
const char script[] = "require \"hello.world\"\n"
"require \"anothermodule\"\n"
"hello.world.test2()";
luaL_loadstring(L, script);
lua_pcall(L, 0, LUA_MULTRET, 0);
プリロードされたテーブルをダンプしました。これらの必要なモジュールは既に存在します (正常にロードされました)。
Web を検索しましたが、まだ解決策が見つかりません。どんなアドバイスでも大歓迎です。
[更新] Android 用の lua コマンドをコンパイルし、コンパイル済みの lua スクリプトを埋め込みました。エラーは上記とまったく同じです。
$ adb shell
$ cd /data/local
$ ls
tmp
lua
dump_preload.lua
$ ./lua dump_preload.lua
--- print table --- preload
test function: 0x376f0
anothermodule function: 0x37718
hello.world function: 0x376b0
--- print table --- loaded
string table: 0x33828
debug table: 0x37098
package table: 0x33d30
_G table: 0x32528
io table: 0x34e80
os table: 0x357b8
table table: 0x332c0
math table: 0x36530
coroutine table: 0x33988
--- print table --- loaders
1 function: 0x33ed8
2 function: 0x33ef8
3 function: 0x33f18
4 function: 0x33f38
$ ./lua
Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio
> require 'test'
attempt to call a string value
stack traceback:
[C]: ?
[C]: in function 'require'
stdin:1: in main chunk
[C]: ?
> require 'hello.world'
attempt to call a string value
stack traceback:
[C]: ?
[C]: in function 'require'
stdin:1: in main chunk
[C]: ?
>