Android Studio JNI Environment setup

Source: Internet
Author: User

    • Need to download NDK separately
    • environment variable configuration, ~/.bash_profile (automatically created if not) enter the above code to configure, exit after executing the source command takes effect
        PATH=$PATH:/Users/confiwang/Applications/android-ndk-r11c/        ANDROID_NDK_ROOT=/Users/confiwang/Applications/android-ndk-r11c/        ANDROID_NDK_ROOT
    • Create a new project using a blank activity
    • Modify Local.properties Add
        ndk.dir=/Users/confiwang/Applications/android-ndk-r11c/        android.useDeprecatedNdk=true
    • In app module (note not the project root), configure NDK compilation (only ModuleName and platforms are configured here, images can be downloaded for viewing, or zoomed in):
    • Create a JNI file, a simple native method add, to calculate the value of two integers added:
    • Create a JNI subfolder under the main folder (in parallel with the Java folder, Android will know the underlying code source folder by default)
    • Switch to the command line, go to the project's Java directory, execute Java Com.example.confiwang.jni.MathJNI (package name + class name), and copy the generated. h file to the newly created Jin directory, and create the. cpp method to implement this function
    • As the JNI and the application layer are in the same project, the direct running system compiles automatically, generating android.mk and corresponding so:! [Write a description of the picture here]
    • Write method calls, you can see the output in the log

Android Studio JNI Environment setup

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.