Android Studio 2.2 External Build

Source: Internet
Author: User

When I wrote the native program in studio today, I found that version 2.2 introduced a External build to build the native project.

The most intuitive performance is that the source code files of C + + is not in a project folder with Java files. And with the previous configuration in the Gradle, and then automatically generated makefile compared to the flexibility greatly increased, no longer have to look for the egg makefile corresponding Gradle statement.

Here's how to use it:

C + + code can be organized in any folder with Android.mk and Application.mk

For example, my file structure is:

---hook---android.mk---application.mk---hook_d------android.mk--- ---main.c---hook_so------android.mk------MAIN.C

Create a new JNI folder in Sudio, which appears as a CPP folder in Android view mode

Right-click to select Link C + + Project with Gradle

Builde system has CMake and ndk-build optional, if you use the Ndk-build option, select the top native file of Android.mk project

After import, the effect is as follows

Finally, I'll mention one of the projects that I just learned. How to compile multiple so files

---hook---android.mk---application.mk---hook_d------  ANDROID.MK------MAIN.C---hook_so------android.mk------main.c    

Take the file structure above as an example

Hook/androi.mk

Include $ (call All-subdir-makefiles)

Hook/hook_d/android.mk

Local_path: = $ (call my-dir+ =-pie-  fpie+ =-pie-fpie-llogtarget_platform:= android-  local_module:= hook_dlocal_src_files:= main.cinclude $ (build_executable) 

Hook/hook_so/android.mk

Local_path: = $ (call my-dir) include $ (clear_vars) Arget_platform:= android-  Local_module:= hook_solocal_src_files:= main.cinclude $ (build_shared_library)         

The principle is all-subdir-makefiles This macro will return the path of all android.mk files under the folder

Android Studio 2.2 External Build

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.