Using the NDK in Eclipse

Source: Internet
Author: User

customizing Eclipse

One of the benefits of using the Eclipse IDE is that you rarely need to compile. Each time you save a file in the Eclipse IDE, the project is built automatically. This works well for Android SDKs (i.e. Java) files and Android XML files, but what about the NDK-built libraries? Let's take a look.

Extending the ECLIPSE Environment

ndk-build   command as simple as. However, in addition to a simple exercise, when dealing with any other project, it would be cumbersome to do something like this: jump out of the terminal or Command window and execute  ndk-build   command, return to the ECLIPSE environment and then perform a refresh by clicking on a project file, which forces the finished application to be recompiled and repackaged. The solution is to customize build settings based on your Android project to extend the ECLIPSE environment.

To modify the build settings, first look at the properties of the Android project and select Buildersin the list. Add a new Builder and move it to the top of the list, as shown in 8.

Figure 8. Modify Build Settings

Each generator has 4 configuration tabs. Name your generator, for example, name it build NDK Library, and then populate the tab. The first tab ("Main") specifies the location and working directory of the executable tool. Browse to the Ndk-build file and working directory in your Jni folder, as shown in 9.

Figure 9. Set the Builder properties of the NDK

You only want to manipulate this item using Ndk-build instead of other content in the Eclipse workspace, so set the Refresh tab, as shown in 10.

Figure 10. Set the Refresh tab

You will want to rebuild the library only if you modify the Android.mk file or the Ibmphotophun.c file. To do this, select the Jni folder under the Specify Resources button in the Build Options tab. Also, specify when you want to build the tool by checking the appropriate time, as shown in 11.

Figure 11. Set build Options

After clicking OK to confirm the settings, make sure this NDK build tool is set to the first entry in the list by selecting the Up button until it is at the top of the Builders list, as shown in 7.

To test if your Builder is set up correctly, open the IBMPHOTOPHUN.C source file in Eclipse by right-clicking the source file and opening it using the Text Editor. Make a simple change, and then save the file. You should see the NDK toolchain output in the console window, as shown in 12. If your C code has errors, they appear in red.

Figure 12. NDK output is displayed in the Eclipse IDE's console

By incorporating the NDK into your build process, you can focus on writing code without knowing too much about the build environment. Need to make changes to the application logic? No problem, modify the Java code and save the file. Need to adjust the image processing algorithm? Don't worry, just modify the C routine and save the file. The Eclipse and ADT plug-ins do other things.

Using the NDK in Eclipse

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.