Installation of Android JNI environment

Source: Internet
Author: User

Before configuring the environment, we need to understand the JNI and NDK

Jni

JNI is the abbreviation for Java Native interface, and Chinese is a native call to Java. It provides a number of APIs that enable communication with Java and other languages (mainly c&c++).

Ndk

NDK Full Name: Native development Kit. The NDK provides a range of tools to help developers quickly develop C (or C + +) dynamic libraries and automatically package so and Java applications together as APK.

Since the Eclipse I'm using is a adt-bundle downloaded on the Android website, it's already integrated with the CDT so this is not the way to introduce the CDT installation.

Next, we need to download the Android NDK:

: http://developer.android.com/tools/sdk/ndk/index.html

The latest is NDK-R10. You can choose which files to download based on your operating system

After the download is successful, unzip the file into your working directory.

Next, configure the NDK path for Eclipse

Open Eclipse Select Window-preferences-android-ndk

Click Browse. Select the path to the NDK and Apply.

Next we need to verify that the NDK environment is successful.

There is a Samples folder in the NDK. There's a hello-jni project in there.

Let's import the project first

The imported project is not available for the time being, because there is no so file, we need to compile it first. Next we add a new compiler

Check Hello-jni this item and find Project-properties in the Eclipse's menu bar. Select Builders click New, and in the popup dialog box, choose Program.

Click OK and then a dialog box pops up

Next, set by the diagram

Next, we have just created the New_builder compiler up to the top, select OK. So our environment is really a success!!!!

Next, it is estimated that you have seen the console in the output log

[ARMEABI-V7A] Compile Thumb:hello-jni <= HELLO-JNI.C
[ARMEABI-V7A] Sharedlibrary:libhello-jni.so
[ARMEABI-V7A] install:libhello-jni.so = libs/armeabi-v7a/libhello-jni.so
[Armeabi] Compile Thumb:hello-jni <= HELLO-JNI.C
[Armeabi] Sharedlibrary:libhello-jni.so
[Armeabi] install:libhello-jni.so = libs/armeabi/libhello-jni.so
[x86] Compile:hello-jni <= HELLO-JNI.C
[x86] Sharedlibrary:libhello-jni.so
[x86] install:libhello-jni.so = libs/x86/libhello-jni.so
[MIPS] Compile:hello-jni <= HELLO-JNI.C
[MIPS] Sharedlibrary:libhello-jni.so
[MIPS] install:libhello-jni.so = libs/mips/libhello-jni.so

At the same time, in Hellojni this project, you can find the Libs folder appears. And so many files.

At this point, we can run the Android program.

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.