JNI in Android Studio--1--Configuration method

Source: Internet
Author: User

1. Configure the NDK

1.1 Downloads NDK

Android Studio 1.2 with android-ndk-r10e, different versions of studio need to be configured with different ndk, after the download is complete, unzip and drop it into a file directory

1.2 Specifying the NDK directory

1.3 Modifying the Build.gradle configuration

What needs to be modified is the <project>\app\build.gradle

2. Add Native Interface

2.1 Adding native

2.2 Execute build, make Project

Determine that the program has no errors and generate a. class file

2.3 Generate. h header files from Javah

2.3.1 Open cmd2.3.2 Enter <project>\app\src\main directory 2.3.3 input command javah-d jni-classpath F:\android-sdk-windows\platforms\ Android-16\android.jar, .... \.. \build\intermediates\classes\debug Com.oki.led.jni.AppJNI 2.3.4 generates the result. h file

3. Edit. C Files

3.1 Add a Com_oki_led_jni_appjni.c file

3.2 Execute Build-> Make Project determine success

3.3 Execute Build-> Rebuild Project can generate so packages

4. Quoting so packages

Appjni Appjni = new Appjni ();
Appjni. Method name (parameter)

JNI in Android Studio--1--Configuration method

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.