使用 Android NDK 编译 Lua

微信扫一扫,分享到朋友圈

使用 Android NDK 编译 Lua

启动 Android Studio ,创建一个 Android 项目,勾选 C++ Support。

一路 Next 到这里,直接 Finish,不用勾选保持默认即可。

如果之前没有安装 NDK 和 Cmake 工具,到这里会提示安装 NDK 等工具,直接安装,我这里之前已经安装了,所以略过。

等待工程就绪之后,正常构建一次,看 Hello World 能不能正常构建运行起来。查看编译后的 APK 文件,看看里面是否有下列目录和 .so 文件。

Executing tasks: [:app:assembleDebug]
省略一堆Log
External native generate JSON debug: JSON generation completed without problems
:app:externalNativeBuildDebug
Build native-lib x86_64
[1/2] Building CXX object CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o
[2/2] Linking CXX shared library ........buildintermediatescmakedebugobjx86_64libnative-lib.so
Build native-lib x86
[1/2] Building CXX object CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o
[2/2] Linking CXX shared library ........buildintermediatescmakedebugobjx86libnative-lib.so
Build native-lib arm64-v8a
[1/2] Building CXX object CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o
[2/2] Linking CXX shared library ........buildintermediatescmakedebugobjarm64-v8alibnative-lib.so
Build native-lib armeabi-v7a
[1/2] Building CXX object CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o
[2/2] Linking CXX shared library ........buildintermediatescmakedebugobjarmeabi-v7alibnative-lib.so
:app:compileDebugSources
:app:mergeDebugShaders
:app:compileDebugShaders
:app:generateDebugAssets
:app:mergeDebugAssets
:app:transformClassesWithDexBuilderForDebug
:app:transformDexArchiveWithExternalLibsDexMergerForDebug
:app:transformDexArchiveWithDexMergerForDebug
:app:mergeDebugJniLibFolders
:app:transformNativeLibsWithMergeJniLibsForDebug
:app:transformNativeLibsWithStripDebugSymbolForDebug
:app:processDebugJavaRes NO-SOURCE
:app:transformResourcesWithMergeJavaResForDebug
:app:validateSigningDebug
:app:packageDebug
:app:assembleDebug

BUILD SUCCESSFUL in 12s
29 actionable tasks: 16 executed, 13 up-to-date

通过 7-Zip 可以查看 APK 里面的文件组成结构,如下是 lib 目录下的内容,分别对应不同的 CPU 架构。

如果能到这一步,说明至少 Android Studio 配置基本是 OK 的,NDK 能正常工作。

在 Android Studio 3.1 后,Gradle Console 就不见了,要查看构建过程和步骤,在 Build 窗口点击 Toggle View 就可以查看构建步骤了。

在 Project 面板中,CPP 目录下的文件就是 C/CPP 的源文件目录,我们从 Lua 官网下载源码后,将 .c 和 .h 文件当道这个目录下面。

目前我能下载到最新的 Lua 版本是 5.3.5 ,粘贴到 CPP 目录后,文件并不会显示,不知道这是不是 Android Studio 的 bug,接下来修改 CMakeLists.txt 里面的内容,将源代码增加到构建列表。

add_library( # Sets the name of the library.
             luajit

             # Sets the library as a shared library.
             SHARED

             # Provides a relative path to your source file(s).
             src/main/cpp/lapi.c
             src/main/cpp/lauxlib.c
             src/main/cpp/lbaselib.c
             src/main/cpp/lbitlib.c
             src/main/cpp/lcode.c
             src/main/cpp/lcorolib.c
             src/main/cpp/lctype.c
             src/main/cpp/ldblib.c
             src/main/cpp/ldebug.c
             src/main/cpp/ldo.c
             src/main/cpp/ldump.c
             src/main/cpp/lfunc.c
             src/main/cpp/lgc.c
             src/main/cpp/linit.c
             src/main/cpp/liolib.c
             src/main/cpp/llex.c
             src/main/cpp/lmathlib.c
             src/main/cpp/lmem.c
             src/main/cpp/loadlib.c
             src/main/cpp/lobject.c
             src/main/cpp/lopcodes.c
             src/main/cpp/loslib.c
             src/main/cpp/lparser.c
             src/main/cpp/lstate.c
             src/main/cpp/lstate.h
             src/main/cpp/lstring.c
             src/main/cpp/lstrlib.c
             src/main/cpp/ltable.c
             src/main/cpp/ltablib.c
             src/main/cpp/ltm.c
             src/main/cpp/lua.c
             src/main/cpp/lua.hpp
             src/main/cpp/lundump.c
             src/main/cpp/lutf8lib.c
             src/main/cpp/lvm.c
             src/main/cpp/lzio.c)

执行编译,这个时候 Build 窗口可能会出现一片红 …

具体错误内容如下:

Execution failed for task ':app:externalNativeBuildDebug'.
> Build command failed.
  Error while executing process D:ANDROIDSdkcmake3.6.4111459bincmake.exe with arguments {--build D:ANDROID_PROJECTSHelloLua2app.externalNativeBuildcmakedebugx86_64 --target luajit}
  [1/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lcode.c.o
  [2/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lcorolib.c.o
  [3/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lauxlib.c.o
  [4/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lbitlib.c.o
  [5/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lapi.c.o
  [6/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lbaselib.c.o
  [7/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/loadlib.c.o
  [8/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/ldo.c.o
  [9/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lgc.c.o
  [10/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/ldump.c.o
  [11/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lmathlib.c.o
  [12/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/liolib.c.o
  [13/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lctype.c.o
  [14/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/ldebug.c.o
  [15/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/linit.c.o
  [16/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/ldblib.c.o
  [17/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/llex.c.o
  [18/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lfunc.c.o
  [19/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lmem.c.o
  [20/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lobject.c.o
  [21/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/ltm.c.o
  [22/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lopcodes.c.o
  [23/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lstate.c.o
  [24/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lstrlib.c.o
  [25/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/ltablib.c.o
  [26/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lparser.c.o
  [27/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lua.c.o
  [28/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/luac.c.o
  [29/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lstring.c.o
  [30/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lundump.c.o
  [31/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lutf8lib.c.o
  [32/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lvm.c.o
  [33/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/ltable.c.o
  [34/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/loslib.c.o
  [35/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lzio.c.o
  D:ANDROID_PROJECTSHelloLua2appsrcmaincpploslib.c:169:3: warning: 'tmpnam' is deprecated: tempnam is unsafe, use mkstemp or tmpfile instead [-Wdeprecated-declarations]
    lua_tmpnam(buff, err);
    ^
  D:ANDROID_PROJECTSHelloLua2appsrcmaincpploslib.c:131:33: note: expanded from macro 'lua_tmpnam'
  #define lua_tmpnam(b,e)         { e = (tmpnam(b) == NULL); }
                                         ^
  D:/ANDROID/Sdk/ndk-bundle/sysroot/usr/includestdio.h:167:5: note: 'tmpnam' has been explicitly marked deprecated here
      __warnattr("tempnam is unsafe, use mkstemp or tmpfile instead");
      ^
  D:/ANDROID/Sdk/ndk-bundle/sysroot/usr/includesys/cdefs.h:160:40: note: expanded from macro '__warnattr'
  #define __warnattr(msg) __attribute__((deprecated(msg)))
                                         ^
  1 warning generated.
  [36/36] Linking C shared library ........buildintermediatescmakedebugobjx86_64libluajit.so
  FAILED: cmd.exe /C "cd . && D:ANDROIDSdkndk-bundletoolchainsllvmprebuiltwindows-x86_64binclang.exe  --target=x86_64-none-linux-android21 --gcc-toolchain=D:/ANDROID/Sdk/ndk-bundle/toolchains/x86_64-4.9/prebuilt/windows-x86_64 --sysroot=D:/ANDROID/Sdk/ndk-bundle/sysroot -fPIC -isystem D:/ANDROID/Sdk/ndk-bundle/sysroot/usr/include/x86_64-linux-android -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security  -O0 -fno-limit-debug-info  -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -nostdlib++ --sysroot D:/ANDROID/Sdk/ndk-bundle/platforms/android-21/arch-x86_64 -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -LD:/ANDROID/Sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/x86_64 -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libluajit.so -o ........buildintermediatescmakedebugobjx86_64libluajit.so CMakeFiles/luajit.dir/src/main/cpp/lapi.c.o CMakeFiles/luajit.dir/src/main/cpp/lauxlib.c.o CMakeFiles/luajit.dir/src/main/cpp/lbaselib.c.o CMakeFiles/luajit.dir/src/main/cpp/lbitlib.c.o CMakeFiles/luajit.dir/src/main/cpp/lcode.c.o CMakeFiles/luajit.dir/src/main/cpp/lcorolib.c.o CMakeFiles/luajit.dir/src/main/cpp/lctype.c.o CMakeFiles/luajit.dir/src/main/cpp/ldblib.c.o CMakeFiles/luajit.dir/src/main/cpp/ldebug.c.o CMakeFiles/luajit.dir/src/main/cpp/ldo.c.o CMakeFiles/luajit.dir/src/main/cpp/ldump.c.o CMakeFiles/luajit.dir/src/main/cpp/lfunc.c.o CMakeFiles/luajit.dir/src/main/cpp/lgc.c.o CMakeFiles/luajit.dir/src/main/cpp/linit.c.o CMakeFiles/luajit.dir/src/main/cpp/liolib.c.o CMakeFiles/luajit.dir/src/main/cpp/llex.c.o CMakeFiles/luajit.dir/src/main/cpp/lmathlib.c.o CMakeFiles/luajit.dir/src/main/cpp/lmem.c.o CMakeFiles/luajit.dir/src/main/cpp/loadlib.c.o CMakeFiles/luajit.dir/src/main/cpp/lobject.c.o CMakeFiles/luajit.dir/src/main/cpp/lopcodes.c.o CMakeFiles/luajit.dir/src/main/cpp/loslib.c.o CMakeFiles/luajit.dir/src/main/cpp/lparser.c.o CMakeFiles/luajit.dir/src/main/cpp/lstate.c.o CMakeFiles/luajit.dir/src/main/cpp/lstring.c.o CMakeFiles/luajit.dir/src/main/cpp/lstrlib.c.o CMakeFiles/luajit.dir/src/main/cpp/ltable.c.o CMakeFiles/luajit.dir/src/main/cpp/ltablib.c.o CMakeFiles/luajit.dir/src/main/cpp/ltm.c.o CMakeFiles/luajit.dir/src/main/cpp/lua.c.o CMakeFiles/luajit.dir/src/main/cpp/luac.c.o CMakeFiles/luajit.dir/src/main/cpp/lundump.c.o CMakeFiles/luajit.dir/src/main/cpp/lutf8lib.c.o CMakeFiles/luajit.dir/src/main/cpp/lvm.c.o CMakeFiles/luajit.dir/src/main/cpp/lzio.c.o  -llog -latomic -lm && cd ."
  D:/ANDROID/Sdk/ndk-bundle/toolchains/x86_64-4.9/prebuilt/windows-x86_64/lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/binld: error: CMakeFiles/luajit.dir/src/main/cpp/luac.c.o: multiple definition of 'main'
  D:/ANDROID/Sdk/ndk-bundle/toolchains/x86_64-4.9/prebuilt/windows-x86_64/lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/binld: CMakeFiles/luajit.dir/src/main/cpp/lua.c.o: previous definition here
  clang.exe: error: linker command failed with exit code 1 (use -v to see invocation)
  ninja: build stopped: subcommand failed.


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 9s
21 actionable tasks: 18 executed, 3 up-to-date

提示中说的也比较清楚,我们使用了已经废弃了的函数:warning: ‘tmpnam’ is deprecated: tempnam is unsafe, use mkstemp or tmpfile instead,但是项目中,使用这个 tmpnam 的比较多,而且需要改 Lua 源代码,本着不对 Lua 改动的原则,我们在 CMakeLists.txt 中增加下面的一行代码,屏蔽废弃函数的错误警告。

add_definitions(-Wno-deprecated)

最终,文件结构如下:

继续编译,发现依然编译不通过,Build 窗口依然一片红,如下:

Executing tasks: [clean, :app:assembleDebug]
省略一堆Log
* What went wrong:
Execution failed for task ':app:externalNativeBuildDebug'.
> Build command failed.
  Error while executing process D:ANDROIDSdkcmake3.6.4111459bincmake.exe with arguments {--build D:ANDROID_PROJECTSHelloLua2app.externalNativeBuildcmakedebugx86_64 --target luajit}
  Recompacting log...
  [1/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lcorolib.c.o
  [2/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lapi.c.o
  [3/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lbaselib.c.o
  [4/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lbitlib.c.o
  [5/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lcode.c.o
  [6/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lauxlib.c.o
  [7/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/ldebug.c.o
  [8/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lfunc.c.o
  [9/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/linit.c.o
  [10/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/liolib.c.o
  [11/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lctype.c.o
  [12/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lgc.c.o
  [13/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/llex.c.o
  [14/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/ldblib.c.o
  [15/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/ldo.c.o
  [16/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lmem.c.o
  [17/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/loadlib.c.o
  [18/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lmathlib.c.o
  [19/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/ldump.c.o
  [20/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lobject.c.o
  [21/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lstrlib.c.o
  [22/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/loslib.c.o
  [23/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lopcodes.c.o
  [24/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/ltable.c.o
  [25/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lua.c.o
  [26/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lundump.c.o
  [27/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lparser.c.o
  [28/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lstring.c.o
  [29/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/ltablib.c.o
  [30/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/ltm.c.o
  [31/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lstate.c.o
  [32/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lutf8lib.c.o
  [33/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lvm.c.o
  [34/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/luac.c.o
  [35/36] Building C object CMakeFiles/luajit.dir/src/main/cpp/lzio.c.o
  [36/36] Linking C shared library ........buildintermediatescmakedebugobjx86_64libluajit.so
  FAILED: cmd.exe /C "cd . && D:ANDROIDSdkndk-bundletoolchainsllvmprebuiltwindows-x86_64binclang.exe  --target=x86_64-none-linux-android21 --gcc-toolchain=D:/ANDROID/Sdk/ndk-bundle/toolchains/x86_64-4.9/prebuilt/windows-x86_64 --sysroot=D:/ANDROID/Sdk/ndk-bundle/sysroot -fPIC -isystem D:/ANDROID/Sdk/ndk-bundle/sysroot/usr/include/x86_64-linux-android -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security  -O0 -fno-limit-debug-info  -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -nostdlib++ --sysroot D:/ANDROID/Sdk/ndk-bundle/platforms/android-21/arch-x86_64 -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -LD:/ANDROID/Sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/x86_64 -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libluajit.so -o ........buildintermediatescmakedebugobjx86_64libluajit.so CMakeFiles/luajit.dir/src/main/cpp/lapi.c.o CMakeFiles/luajit.dir/src/main/cpp/lauxlib.c.o CMakeFiles/luajit.dir/src/main/cpp/lbaselib.c.o CMakeFiles/luajit.dir/src/main/cpp/lbitlib.c.o CMakeFiles/luajit.dir/src/main/cpp/lcode.c.o CMakeFiles/luajit.dir/src/main/cpp/lcorolib.c.o CMakeFiles/luajit.dir/src/main/cpp/lctype.c.o CMakeFiles/luajit.dir/src/main/cpp/ldblib.c.o CMakeFiles/luajit.dir/src/main/cpp/ldebug.c.o CMakeFiles/luajit.dir/src/main/cpp/ldo.c.o CMakeFiles/luajit.dir/src/main/cpp/ldump.c.o CMakeFiles/luajit.dir/src/main/cpp/lfunc.c.o CMakeFiles/luajit.dir/src/main/cpp/lgc.c.o CMakeFiles/luajit.dir/src/main/cpp/linit.c.o CMakeFiles/luajit.dir/src/main/cpp/liolib.c.o CMakeFiles/luajit.dir/src/main/cpp/llex.c.o CMakeFiles/luajit.dir/src/main/cpp/lmathlib.c.o CMakeFiles/luajit.dir/src/main/cpp/lmem.c.o CMakeFiles/luajit.dir/src/main/cpp/loadlib.c.o CMakeFiles/luajit.dir/src/main/cpp/lobject.c.o CMakeFiles/luajit.dir/src/main/cpp/lopcodes.c.o CMakeFiles/luajit.dir/src/main/cpp/loslib.c.o CMakeFiles/luajit.dir/src/main/cpp/lparser.c.o CMakeFiles/luajit.dir/src/main/cpp/lstate.c.o CMakeFiles/luajit.dir/src/main/cpp/lstring.c.o CMakeFiles/luajit.dir/src/main/cpp/lstrlib.c.o CMakeFiles/luajit.dir/src/main/cpp/ltable.c.o CMakeFiles/luajit.dir/src/main/cpp/ltablib.c.o CMakeFiles/luajit.dir/src/main/cpp/ltm.c.o CMakeFiles/luajit.dir/src/main/cpp/lua.c.o CMakeFiles/luajit.dir/src/main/cpp/luac.c.o CMakeFiles/luajit.dir/src/main/cpp/lundump.c.o CMakeFiles/luajit.dir/src/main/cpp/lutf8lib.c.o CMakeFiles/luajit.dir/src/main/cpp/lvm.c.o CMakeFiles/luajit.dir/src/main/cpp/lzio.c.o  -llog -latomic -lm && cd ."
  D:/ANDROID/Sdk/ndk-bundle/toolchains/x86_64-4.9/prebuilt/windows-x86_64/lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/binld: error: CMakeFiles/luajit.dir/src/main/cpp/luac.c.o: multiple definition of 'main'
  D:/ANDROID/Sdk/ndk-bundle/toolchains/x86_64-4.9/prebuilt/windows-x86_64/lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/binld: CMakeFiles/luajit.dir/src/main/cpp/lua.c.o: previous definition here
  clang.exe: error: linker command failed with exit code 1 (use -v to see invocation)
  ninja: build stopped: subcommand failed.


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 9s
21 actionable tasks: 19 executed, 2 up-to-date

在这个错误里,有两处非常明显:

error: CMakeFiles/luajit.dir/src/main/cpp/luac.c.o: multiple definition of 'main'
CMakeFiles/luajit.dir/src/main/cpp/lua.c.o: previous definition here

事实上,我们也不需要 Main 函数的定义,因为编译为 SHARE_LIBRARY ,所以屏蔽这个文件即可。

再次构建,发现还是一片红… 错误如下:

省略一堆Log
Execution failed for task ':app:externalNativeBuildDebug'.
> Build command failed.
  Error while executing process D:ANDROIDSdkcmake3.6.4111459bincmake.exe with arguments {--build D:ANDROID_PROJECTSHelloLua2app.externalNativeBuildcmakedebugx86 --target luajit}
  [1/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lbaselib.c.o
  [2/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lbitlib.c.o
  [3/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lcode.c.o
  [4/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lauxlib.c.o
  [5/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lcorolib.c.o
  [6/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lapi.c.o
  [7/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lgc.c.o
  [8/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/loadlib.c.o
  [9/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lobject.c.o
  [10/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ldblib.c.o
  [11/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lctype.c.o
  [12/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ldump.c.o
  [13/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/llex.c.o
  [14/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/liolib.c.o
  [15/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ldo.c.o
  [16/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lmathlib.c.o
  [17/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lmem.c.o
  [18/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/linit.c.o
  [19/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lfunc.c.o
  [20/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ldebug.c.o
  [21/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lvm.c.o
  [22/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lutf8lib.c.o
  [23/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/loslib.c.o
  [24/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lstrlib.c.o
  [25/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lzio.c.o
  [26/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lparser.c.o
  [27/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lua.c.o
  [28/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lstring.c.o
  [29/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ltm.c.o
  [30/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lopcodes.c.o
  [31/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lstate.c.o
  [32/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ltablib.c.o
  [33/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lundump.c.o
  [34/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ltable.c.o
  [35/35] Linking C shared library ........buildintermediatescmakedebugobjx86libluajit.so
  FAILED: cmd.exe /C "cd . && D:ANDROIDSdkndk-bundletoolchainsllvmprebuiltwindows-x86_64binclang.exe  --target=i686-none-linux-android19 --gcc-toolchain=D:/ANDROID/Sdk/ndk-bundle/toolchains/x86-4.9/prebuilt/windows-x86_64 --sysroot=D:/ANDROID/Sdk/ndk-bundle/sysroot -fPIC -isystem D:/ANDROID/Sdk/ndk-bundle/sysroot/usr/include/i686-linux-android -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -mstackrealign -Wa,--noexecstack -Wformat -Werror=format-security  -O0 -fno-limit-debug-info  -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -nostdlib++ --sysroot D:/ANDROID/Sdk/ndk-bundle/platforms/android-19/arch-x86 -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -LD:/ANDROID/Sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/x86 -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libluajit.so -o ........buildintermediatescmakedebugobjx86libluajit.so CMakeFiles/luajit.dir/src/main/cpp/lapi.c.o CMakeFiles/luajit.dir/src/main/cpp/lauxlib.c.o CMakeFiles/luajit.dir/src/main/cpp/lbaselib.c.o CMakeFiles/luajit.dir/src/main/cpp/lbitlib.c.o CMakeFiles/luajit.dir/src/main/cpp/lcode.c.o CMakeFiles/luajit.dir/src/main/cpp/lcorolib.c.o CMakeFiles/luajit.dir/src/main/cpp/lctype.c.o CMakeFiles/luajit.dir/src/main/cpp/ldblib.c.o CMakeFiles/luajit.dir/src/main/cpp/ldebug.c.o CMakeFiles/luajit.dir/src/main/cpp/ldo.c.o CMakeFiles/luajit.dir/src/main/cpp/ldump.c.o CMakeFiles/luajit.dir/src/main/cpp/lfunc.c.o CMakeFiles/luajit.dir/src/main/cpp/lgc.c.o CMakeFiles/luajit.dir/src/main/cpp/linit.c.o CMakeFiles/luajit.dir/src/main/cpp/liolib.c.o CMakeFiles/luajit.dir/src/main/cpp/llex.c.o CMakeFiles/luajit.dir/src/main/cpp/lmathlib.c.o CMakeFiles/luajit.dir/src/main/cpp/lmem.c.o CMakeFiles/luajit.dir/src/main/cpp/loadlib.c.o CMakeFiles/luajit.dir/src/main/cpp/lobject.c.o CMakeFiles/luajit.dir/src/main/cpp/lopcodes.c.o CMakeFiles/luajit.dir/src/main/cpp/loslib.c.o CMakeFiles/luajit.dir/src/main/cpp/lparser.c.o CMakeFiles/luajit.dir/src/main/cpp/lstate.c.o CMakeFiles/luajit.dir/src/main/cpp/lstring.c.o CMakeFiles/luajit.dir/src/main/cpp/lstrlib.c.o CMakeFiles/luajit.dir/src/main/cpp/ltable.c.o CMakeFiles/luajit.dir/src/main/cpp/ltablib.c.o CMakeFiles/luajit.dir/src/main/cpp/ltm.c.o CMakeFiles/luajit.dir/src/main/cpp/lua.c.o CMakeFiles/luajit.dir/src/main/cpp/lundump.c.o CMakeFiles/luajit.dir/src/main/cpp/lutf8lib.c.o CMakeFiles/luajit.dir/src/main/cpp/lvm.c.o CMakeFiles/luajit.dir/src/main/cpp/lzio.c.o  -llog -latomic -lm && cd ."
  D:ANDROID_PROJECTSHelloLua2appsrcmaincpp/liolib.c:446: error: undefined reference to 'localeconv'
  D:ANDROID_PROJECTSHelloLua2appsrcmaincpp/lobject.c:287: error: undefined reference to 'localeconv'
  D:ANDROID_PROJECTSHelloLua2appsrcmaincpp/lobject.c:381: error: undefined reference to 'localeconv'
  D:ANDROID_PROJECTSHelloLua2appsrcmaincpp/lstrlib.c:936: error: undefined reference to 'localeconv'
  clang.exe: error: linker command failed with exit code 1 (use -v to see invocation)
  ninja: build stopped: subcommand failed.


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 12s
21 actionable tasks: 18 executed, 3 up-to-date

这次的错误都是这一个:undefined reference to ‘localeconv’,解决办法是提高 API Level ,我们把它改为 21 以上就可以解决这个问题。

再次构建,终于不再报错了,结果如下:

Executing tasks: [clean, :app:assembleDebug]
省略一堆Log
:app:externalNativeBuildCleanDebug
Clean luajit armeabi-v7a
Cleaning... 0 files.
Clean luajit arm64-v8a
Cleaning... 0 files.
Clean luajit x86
Cleaning... 0 files.
Clean luajit x86_64
Cleaning... 35 files.
:app:externalNativeBuildCleanRelease
Clean luajit armeabi-v7a
Cleaning... 0 files.
Clean luajit arm64-v8a
Cleaning... 0 files.
Clean luajit x86
Cleaning... 0 files.
Clean luajit x86_64
Cleaning... 0 files.
:app:clean
:app:preBuild UP-TO-DATE
:app:preDebugBuild
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:checkDebugManifest
:app:generateDebugBuildConfig
:app:prepareLintJar UP-TO-DATE
:app:mainApkListPersistenceDebug
:app:generateDebugResValues
:app:generateDebugResources
:app:mergeDebugResources
:app:createDebugCompatibleScreenManifests
:app:processDebugManifest
:app:splitsDiscoveryTaskDebug
:app:processDebugResources
:app:generateDebugSources
:app:javaPreCompileDebug
:app:compileDebugJavaWithJavac
:app:generateJsonModelDebug UP-TO-DATE
:app:externalNativeBuildDebug
Build luajit x86_64
Recompacting log...
[1/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lcorolib.c.o
[2/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lauxlib.c.o
[3/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lbaselib.c.o
[4/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lbitlib.c.o
[5/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lcode.c.o
[6/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lapi.c.o
[7/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lctype.c.o
[8/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lmathlib.c.o
[9/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/liolib.c.o
[10/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lfunc.c.o
[11/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lmem.c.o
[12/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/loadlib.c.o
[13/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/linit.c.o
[14/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ldblib.c.o
[15/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lobject.c.o
[16/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/llex.c.o
[17/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ldebug.c.o
[18/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lgc.c.o
[19/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ldo.c.o
[20/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ldump.c.o
[21/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lzio.c.o
[22/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lstring.c.o
[23/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/loslib.c.o
[24/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ltable.c.o
[25/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lundump.c.o
[26/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lopcodes.c.o
[27/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ltm.c.o
[28/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lstate.c.o
[29/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lparser.c.o
[30/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ltablib.c.o
[31/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lstrlib.c.o
[32/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lutf8lib.c.o
[33/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lvm.c.o
[34/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lua.c.o
[35/35] Linking C shared library ........buildintermediatescmakedebugobjx86_64libluajit.so
Build luajit x86
[1/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lcorolib.c.o
[2/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lapi.c.o
[3/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lbaselib.c.o
[4/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lbitlib.c.o
[5/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lauxlib.c.o
[6/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lcode.c.o
[7/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lmem.c.o
[8/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/loadlib.c.o
[9/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ldo.c.o
[10/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lctype.c.o
[11/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lobject.c.o
[12/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/liolib.c.o
[13/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/llex.c.o
[14/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/linit.c.o
[15/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ldebug.c.o
[16/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lfunc.c.o
[17/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lgc.c.o
[18/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ldblib.c.o
[19/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ldump.c.o
[20/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lmathlib.c.o
[21/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lutf8lib.c.o
[22/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lstate.c.o
[23/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lvm.c.o
[24/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lzio.c.o
[25/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lparser.c.o
[26/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lstrlib.c.o
[27/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ltable.c.o
[28/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ltm.c.o
[29/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ltablib.c.o
[30/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lstring.c.o
[31/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lopcodes.c.o
[32/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lua.c.o
[33/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lundump.c.o
[34/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/loslib.c.o
[35/35] Linking C shared library ........buildintermediatescmakedebugobjx86libluajit.so
Build luajit arm64-v8a
[1/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lbitlib.c.o
[2/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lauxlib.c.o
[3/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lbaselib.c.o
[4/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lcode.c.o
[5/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lcorolib.c.o
[6/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lapi.c.o
[7/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lfunc.c.o
[8/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/liolib.c.o
[9/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/linit.c.o
[10/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/loadlib.c.o
[11/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lobject.c.o
[12/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ldump.c.o
[13/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ldebug.c.o
[14/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ldblib.c.o
[15/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ldo.c.o
[16/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/llex.c.o
[17/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lctype.c.o
[18/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lmathlib.c.o
[19/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lmem.c.o
[20/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lgc.c.o
[21/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lstring.c.o
[22/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lvm.c.o
[23/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ltablib.c.o
[24/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lzio.c.o
[25/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lua.c.o
[26/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lstate.c.o
[27/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lstrlib.c.o
[28/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ltable.c.o
[29/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lutf8lib.c.o
[30/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/loslib.c.o
[31/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lundump.c.o
[32/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lopcodes.c.o
[33/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ltm.c.o
[34/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lparser.c.o
[35/35] Linking C shared library ........buildintermediatescmakedebugobjarm64-v8alibluajit.so
Build luajit armeabi-v7a
[1/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lcorolib.c.o
[2/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lbitlib.c.o
[3/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lapi.c.o
[4/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lauxlib.c.o
[5/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lbaselib.c.o
[6/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lcode.c.o
[7/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ldo.c.o
[8/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/llex.c.o
[9/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ldump.c.o
[10/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lobject.c.o
[11/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/liolib.c.o
[12/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lmathlib.c.o
[13/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lmem.c.o
[14/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/loadlib.c.o
[15/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ldebug.c.o
[16/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lfunc.c.o
[17/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ldblib.c.o
[18/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lgc.c.o
[19/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/linit.c.o
[20/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lctype.c.o
[21/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lua.c.o
[22/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lopcodes.c.o
[23/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ltm.c.o
[24/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/loslib.c.o
[25/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lundump.c.o
[26/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ltable.c.o
[27/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lstring.c.o
[28/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lutf8lib.c.o
[29/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lzio.c.o
[30/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lstate.c.o
[31/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lvm.c.o
[32/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/ltablib.c.o
[33/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lstrlib.c.o
[34/35] Building C object CMakeFiles/luajit.dir/src/main/cpp/lparser.c.o
[35/35] Linking C shared library ........buildintermediatescmakedebugobjarmeabi-v7alibluajit.so
:app:compileDebugSources
:app:mergeDebugShaders
:app:compileDebugShaders
:app:generateDebugAssets
:app:mergeDebugAssets
:app:transformClassesWithDexBuilderForDebug
:app:transformDexArchiveWithExternalLibsDexMergerForDebug
:app:transformDexArchiveWithDexMergerForDebug
:app:mergeDebugJniLibFolders
:app:transformNativeLibsWithMergeJniLibsForDebug
:app:transformNativeLibsWithStripDebugSymbolForDebug
:app:processDebugJavaRes NO-SOURCE
:app:transformResourcesWithMergeJavaResForDebug
:app:validateSigningDebug
:app:packageDebug
:app:assembleDebug

BUILD SUCCESSFUL in 20s
33 actionable tasks: 30 executed, 3 up-to-date

再生成 APK,使用 7-ZIP 查看 APK,就可以看到我们 Lua 已经稳妥妥的在 APK 安装包中了,达到 340 KB了,对于 so 库来说也不小了。

至此,Lua 已经编译好了,如果需要使用,还需要写 JNI 方法调用,不过那是后话了。

Github 地址: https://github.com/yahch/Luandroid

微信扫一扫,分享到朋友圈

使用 Android NDK 编译 Lua

The Ultimate Guide to Pricing Freelance Web Development

上一篇

调完组织,腾讯还缺一位首席代价官

下一篇

你也可能喜欢

使用 Android NDK 编译 Lua

长按储存图像,分享给朋友