Preparing for NDK development with Android Studio

Source: Internet
Author: User

1. Gradle-ex
2. NDK Development Kit
3. Project directory Structure
4. Lldb Debugger

1. In general Gradle is not required, Gradle is also available for NDK compilation, however you need to use more (more than one) C + + compilation options at compile time, and allow the IDE to debug with LLDB, or better support for NDK development and compilation Gradle-ex is all you need.
Gradle-ex's ex is not an extension but an informal experimental experiment. It has enhanced the NDK-related configuration, while the syntax is incompatible with Gradle, and the configuration outside of the NDK-related is along the gradle syntax. That is, Gradle-ex is not entirely new, only the NDK related changes, and the changes are not compatible with the original syntax. Gradle default is obsolete NDK extension, need to manually modify the open support. Gradle's compilation options for the NDK are considered cflags, and only one compilation option is used, and Gradle-ex no longer has cflags, instead of cppflags. Gradle and Gradle-ex have inconsistent attribute path orchestration for NDK configuration, that is, gradle-ex the partial attribute path. The assignment of strings and arrays in Gradle-ex uses the new syntax. Gradle and Gradle-ex not your gradle script strict grammar check, only in the Gradle job can be wrong times resentment, you just slowly to think of where there is a problem.
Using Gradle-ex, you need to change the buildscript.dependencies.classpath of the top-level build.gradle to Com.andraoid.tools.build: Gradle-experimental:0.7.0-alphal.

2. NDK Development Kit contains the necessary cross-compilation tools and platform exported header files and minimal run link files. The IDE can be configured to use Tools->system settings->android sdk->sdk tools->ndk, which allows the IDE to update the download itself. Or extract the offline compressed package into your ${ANDROID_SDK} directory under the Ndk-bundle subdirectory.
If the IDE does not recognize the NDK path correctly, you can use either project to configure its local.properties file Ndk_path, and synchronize the IDE to perform the configuration adaptation.

3. Gradle relies on a strict directory structure when compiling.
When compiling with the Ndk-build command, Ndk-build needs to search the JNI directory, and if there is no JNI directory, Ndk-build will assume there are no projects to compile.
Also using Gradle or GRADLE-EX, they are also fixed search directory paths.
Generally in the SRC directory:
App/build/intermediates
App/libsjar Package Import Directory
App/src/main/java
C header file generated by the App/src/main/java/jninative method
App/src/main/jni all source code for C + + and development header files for third-party libraries
App/src/main/jnilibs The third-party library link files that the code links to in all JNI directories

4. Lldb caller, you can use the IDE configuration Tools->system settings->android sdk->sdk tools->lldb, let the IDE update the download itself. Or extract the offline compressed package into your ${ANDROID_SDK} directory under the Ndk-bundle subdirectory.
Gradle-ex automatically set up the Lldbserver remote debugging connection, so although the use of Lldb debugger, but it is remote debugging, the use of a lot of support is not good, than the stack frame selection command does not work, thread selection command is not effective, etc.

Preparing for NDK development with Android Studio

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.