使用 ANT 脚本构建 Android NDK [英] Android NDK build with ANT script
问题描述
我们可以将 ANT 脚本用于 Android NDK 构建吗?如果是怎么办?如果没有,那为什么不呢?
我对它没有概念
从您的 -pre-build
目标调用 ndk-build
,如下所示:
<exec executable="${ndk.dir}/ndk-build" failonerror="true"/></目标><target name="clean"depends="android_rules.clean"><exec executable="${ndk.dir}/ndk-build" failonerror="true"><arg value="clean"/></exec></目标>
然后您可以将 ndk.dir
设置为指向 local.properties
文件中的 NDK 目录,或在命令行中设置它.我这样做:
ant -Dsdk.dir=/home/dg/apps/android-sdk-linux_x86-r11/-Dndk.dir=/home/dg/apps/android-ndk-r6b release
现在运行 ant 将自动构建您的本机代码.此外,运行 'ant clean' 将清理您的本机代码.
更新: 将 failonerror="true"
添加到 <exec>
任务 --- 如果 make失败.没有它,它会直接生成一个包含无效二进制文件的 APK.不好!</p>
Can we use the ANT script for Android NDK builds ? If Yes how? And if no, then why Not ?
I don't have any idea about it
Call ndk-build
from your -pre-build
target, like this:
<target name="-pre-build">
<exec executable="${ndk.dir}/ndk-build" failonerror="true"/>
</target>
<target name="clean" depends="android_rules.clean">
<exec executable="${ndk.dir}/ndk-build" failonerror="true">
<arg value="clean"/>
</exec>
</target>
Then you can set ndk.dir
to point at the NDK directory from your local.properties
file, or set it on the command line. I do this:
ant -Dsdk.dir=/home/dg/apps/android-sdk-linux_x86-r11/ -Dndk.dir=/home/dg/apps/android-ndk-r6b release
Now running ant will build your native code automatically. Plus, running 'ant clean' will clean your native code.
Updated: Added failonerror="true"
to the <exec>
tasks --- this causes ant to abort if the make fails. Without it it'll just go right ahead and generate an APK with an invalid binary in it. Not good!
这篇关于使用 ANT 脚本构建 Android NDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!