Android NDK-r5 successfully runs the compilation and runs the first ndk Program

Source: Internet
Author: User

For self-developed ndk, it should be a little excited to compile and run Hello-JNI.

(Ubuntu environment) The establishment of the ndk development environment is easy to stop, but there are still several days of prompts:

1. In the C/C ++ environment of Eclipse, it is best to manually install the CDT plug-in,

(See my other note. Eclipse CDT security guide.
)

Help --> install new sofeware is too difficult to install and the dependency is hard to solve.

2. After the ndk environment was set up, I was eager to test the environment, so I started to write the test according to others' examples. All failed.

The reason is:

A. I didn't clear the compiling method of the ndk application, so I had to worry about it in eclipse.

JNI. h and other header files cannot be found, and eclipse cannot compile.

The C file in the project cannot be added directly. The error reported by the JNI variable of the native method in the Java file causes me to doubt whether the environment is not properly configured or the installed CDT is incomplete, because the dependency is not considered during manual installation. Confused.

B. view the ndk Doc.

How to Use ndk in docs/howto. txt.


There are two ways to compile:

1) compile in the target project directory:

$CD android-ndk-r5/samples/Hello-JNI

Enter the example directory


Execute the ndk-build script

2) Compile in any directory:

$Ndk-Build-C $ ndk/samples/Hello-JNI

Use-C to point out the project directory path

Note: No matter which one is compiled, after successful compilation, the libs and OBJ subdirectories will be generated in the current directory.


3. Open the eclipse refresh hello-JNI project and run to see the effect.

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.