Android jni Development notes

Source: Internet
Author: User


I used to have a casual experience with JNI on android. So I subconsciously think this is nothing.

But this is actually not the case. The following are some of the issues that have plagued me during JNI development:


JNI development steps:

Step 1 declare the function definition in the java File

Step 2: Use the javah tool to compile the class file compiled by the java file into the. h header file.

Step 3 compile a specific function implementation in C Based on the H file.

Step 4: Compile the. c file as the so Library (ndk needs to be used here) and then call it in java.


Path of the header file:

1. Adjust the current path to the path before com, that is, the path of the normal java command,

2. The command for generating the header file is javah-classpath.-jni package name + class name.

Question about generating the so file:

1. to generate the so file, you must create a new jni directory in the android Application project, and then perform operations in the jni directory.

2. Enter the jni directory in the cygwin environment and enter $ NDK/ndk-build for automatic compilation.


JNI Syntax:

This is a complicated part in jni development.



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.