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 selectProperties. In the resulting dialog, choose the Builders entry in the list to the left and press theNew... button:
A new dialog will open presenting a list of builder types. Select the Program type and press theOK button:
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:
Now continue with the refresh tab. Make sure the two checkboxes Refresh resources upon completion. andRecursively include sub-folders are checked. Choose the Specific resources radio button and press theSpecify Resources... button:
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 theFinish button:
Now skip the Environment tab and go to the final Build Options tab. Make sure theRun the builder: During auto builds checkbox is checked.
Since the NDK build only needs to happen when editing files in the jni folder, check that folder and press theFinish button.
Now finally press OK in the builder configuration dialog - the new NDK builder should now be up and running. Try editing any file in thejni folder and check that the Console view produces output from the build process:
url:http://mobilepearls.com/labs/ndk-builder-in-eclipse/
本文指导您如何在使用Android NDK编辑本地JNI代码时,通过Eclipse自动重建项目,类似于Java代码的自动重建。具体步骤包括配置Eclipse以在编辑本地代码时自动重新构建项目,设置必要的构建器配置,以及确保资源更新和目录递归包含。
1705

被折叠的 条评论
为什么被折叠?



