The difference between the cmake of NDK development in AndroidStudio2.2 Preview3 and the traditional JNI in the directory structure and configuration file (reproduced)

Source: Internet
Author: User

Since Androidstudio updated to 2.2, there are cmake and traditional JNI two ways to develop the NDK, mainly in the directory structure and Build.gradle differences, the following we will describe the difference between the directory and Build.gradle configuration differences (hint: when the first time with CMake , it is best to check the include C + + support when creating a new project, so the NDK development of this project is the CMake way, which is also the way of the main push after Android, build the project, familiar with the CMake way directory structure, This will be to build a common project and then turn CMake development NDK is very helpful, later on the general project to the NDK development)

Differences on the directory:

Traditional JNI:

CMake:

The difference between the two methods in the directory is two points:

1. Previous JNI directory changed to CPP, position unchanged

2. Prior to the compilation of the C file configuration android.mk file is placed in the JNI directory, now changed to CMakeLists.txt file

(Note: In fact, android.mk files and CMakeLists.txt can be placed in any directory, but preferably in the current project directory under any location.) Said the Build.gradle configuration difference will know)

The difference between Build.gradle: traditional JNI:

CMake:

From the above two pictures can be found, only two red boxes in the content of the difference, for the traditional jni, in fact, the contents of the second red box can not need, it all the configuration in

ndk{    modulename "Hello"    abifilters "x86"}

Inside configuration, the contents of the Android.mk file will not work (hint: but can not delete it, in the following ordinary Android project to NDK Development know), this is different from the Eclipse development environment. Also, traditional JNI development needs to be configured in the Gradle.properties file in the project root directory

Android.usedeprecatedndk=true

Otherwise the build project will have an error.

Most of the configuration of CMake is configured in the CMakeLists.txt file, and only a small portion is placed in the

CMake {    cppflags "-std=c++11"}

Inside configuration. CMake's grammar rules can be Baidu.

General Android Project to NDK development project:

For normal Android projects, you can choose link C + + project with Gradle to NDK project by right-clicking the mouse.

The development ndk is CMake or jni by selecting CMake or ndk-build, but such conversion must conform to the directory of CMake or JNI

Structure, that is, before the operation is completed, you must first build a directory in the project that conforms to the CMake or JNI rules, if CMakeLists.txt

There is a reference to xx.cpp/xx.c in the file, you must create a new xx.cpp/xx.c in the CPP directory, in the same vein, if the Android.mk file is cited

With the cpp/c file, you will need to create a new file in the JNI directory. (After androidstudio2.2, the new NDK project can only get CMake mode,

So if you want to develop JNI, you can only turn to normal projects.

Article turned from: http://blog.csdn.net/u012527560/article/details/51752070

The difference between the cmake of NDK development in AndroidStudio2.2 Preview3 and the traditional JNI in the directory structure and configuration file (reproduced)

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.