Setting up Automatic NDK Builds in Eclipse

Setting up Automatic NDK Builds in Eclipse

When editing native JNI code in an Android project using the Android NDK you may configure Eclipse to automatically rebuild your project when editing native code, just as it does for java. The below steps shows how to perform the necessary configuration (note that this requires revision 4 or later of the NDK - previous revisions does not contain the necessary ndk-build binary):

Start by right clicking on your android project (named hello-neon in the below screenshots) with JNI resources, and select Properties. In the resulting dialog, choose the Builders entry in the list to the left and press the New... button:

在eclipse中配置android ndk的自动编译环境builders - lockriver - Two PPs Web home

A new dialog will open presenting a list of builder types. Select the Program type and press the OK button:

在eclipse中配置android ndk的自动编译环境builders - lockriver - Two PPs Web home

In the Main tab, fill in the following:

Name:
NDK Builder
Location:
/opt/android-ndk/ndk-build (or wherever your ndk-build binary is). You may use a variable as in ${system_property:user.home}/lib/android-ndk/ndk-build
Working Directory:
${workspace_loc:/hello-neon} (replace hello-neon with your project name. Press the  Browse Workspace... button to select it graphically)

The result should look something like the below:

在eclipse中配置android ndk的自动编译环境builders - lockriver - Two PPs Web home

Now continue with the refresh tab. Make sure the two checkboxes Refresh resources upon completion. and Recursively include sub-folders are checked. Choose the Specific resources radio button and press the Specify Resources... button:

在eclipse中配置android ndk的自动编译环境builders - lockriver - Two PPs Web home

Since the ndk-build process will generate files in the lib folder, we want Eclipse to discover changes made there without having to refresh manually. So select the lib folder in the project (create one if necessary) and press the Finish button:

在eclipse中配置android ndk的自动编译环境builders - lockriver - Two PPs Web home

Now skip the Environment tab and go to the final Build Options tab. Make sure the Run the builder: During auto builds checkbox is checked.

在eclipse中配置android ndk的自动编译环境builders - lockriver - Two PPs Web home

Since the NDK build only needs to happen when editing files in the jni folder, check that folder and press the Finish button.

在eclipse中配置android ndk的自动编译环境builders - lockriver - Two PPs Web home

Now finally press OK in the builder configuration dialog - the new NDK builder should now be up and running. Try editing any file in the jnifolder and check that the Console view produces output from the build process:

在eclipse中配置android ndk的自动编译环境builders - lockriver - Two PPs Web home
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值