如何打包APK本机命令行应用程序?本机、命令行、应用程序、APK

2023-09-12 02:25:07 作者:国产小祖宗

我想打包Android原生的命令行应用程序转换成APK。我有应用程序构建与NDK建造它使用JNI / Android.mk。的输出是在库/ armeabi /&其中; MyApp的取代。我也有APK建筑蚂蚁。但是,APK似乎没有拿起命令行应用程序。如果我解压的APK应用程序是不是在那里。

我需要什么做的就是蚂蚁包括pre-内置命令行应用程序?

此外,什么我需要做的,这样蚂蚁运行NDK,打造? (这已经回答了:的Andr​​oid NDK的建立与ANT脚本)

解决方案

请参阅的Andr​​oid NDK建立与ANT脚本。

您可以添加使用二进制APK AAPT ,如果蚂蚁不会自动从库复制/ armeabi ,看Documentation在Ant脚本 AAPT元素。

我相信,该文件将被正确提取到 /data/data/your.package.full.name/lib ,具有可执行权限。

Ant构建涉及到一个名为一步ApkBuilder",这只能从库/ armeabi 的匹配模式 ^ + \。所以$ 或 gdbserver的 - 后者为调试版本只

但这是不够的,可执行重新命名为myexecutable.so的:这个文件将不会由所述设备上的APK安装被提取 怎样将c 编写的程序打包成应用程序 安装,卸载

有足够的可执行文件重命名为 LIB myexecutable 的.so :这个文件将被提取的 APK安装包管理器的设备上 /data/data/your.package.full.name/lib ,具有可执行权限。

我个人很喜欢给这个未竟-A-库一些特殊的名字,如: lib中... ffmpeg的......所以

I would like to package an Android native commandline application into an apk. I have the application building with ndk-build which uses jni/Android.mk. The output is in libs/armeabi/<MyApp>. I also have the apk building with ant. However, the apk does not seem to pick up the commandline application. If I unzip the apk the app is not in there.

What do I need to do to get ant to include a pre-built commandline app?

Also, what do I need to do so that ant runs ndk-build? (This was already answered: Android NDK build with ANT script)

解决方案

See Android NDK build with ANT script.

You can add the binary to APK using aapt if Ant does not copy it automatically from libs/armeabi, see Documentation for aapt element in Ant script.

I believe that the file will be correctly extracted to /data/data/your.package.full.name/lib, with executable permissions.

Ant build involves a step called "ApkBuilder", which only adds files from libs/armeabi that match pattern ^.+\.so$ or gdbserver - the latter for debug build only.

But it is not enough to rename the executable to "myexecutable.so": this file will not be extracted by the APK installer on the device.

It is enough to rename the executable to "libmyexecutable.so": this file will be extracted by the APK installer Package Manager on the device to /data/data/your.package.full.name/lib, with executable permissions.

I personally like to give this not-actually-a-library some special name, e.g. lib...ffmpeg...so.