Android studio22-ndk-lldb Debug

Source: Internet
Author: User

Android Studio2.2 is better supported for NDK development and can be developed as a Java-like debug program without the need to add gradle-experimental plug-in , you can debug the code!

One, download the NDK and build tools

To compile and debug local code (NATIVE CODE), you need the following components:

(1) the android native development kit  (NDK)  :  allows you to use  C  and  C++  code tool set.

(2) CMake External build tool. If you are prepared to use only ndk-build, you can not use it.

(3) lldb:android Studio to debug local code on the craftsman.


Note: To use  CMake  or  ndk-build in  Android Studio    You need use   Androi d  studio 2.2  or higher, and requires

Cooperate with Android Plugin for Gradle 2.2.0 and above versions.

Install the above components:

Note: if SDK Tools do not display lldb,cmake and NDK, indicating that you have configured a domestic mirror site!!

To be able to on the Google official website will show, before also through the domestic mirror, has not been shown!

Tools > Android > SDK Manager > Click the SDK Tools tab.

Tick Lldb,cmake and NDK.

has been downloaded separately android-ndk-r11b here no longer download ndk! (best tick Download the latest NDK)

Click Apply, and then click OK.

Second, the new project:

Hook up include C + + support

You can choose a different C + + library at the last step

Description

Although it supports C + +, but does not fully support the full range of features of C + +, you must follow the  jni Convention: Refer to the  JNI full manual! Tutorial reference: jni get Started:   official website demo

C + + standard: Select C + + library

toolchain Default :  Default CMake settings

C + + : Supports C++11 features!

Exceptions Support (-fexceptions):

Tick this box if you want to use support for C + + exception handling. When checked, Android Studio adds the-fexcetions flag to the cppflags in the Build.gradle file in the module layer.

Runtime Type Information Support (-frtti):

If you want to support RTTI, tick it. When checked, Android Studio adds the-frtti flag to the cppflags in the Build.gradle file in the module layer.

The post-completion structure is as follows:

Description

Native-lib.cpp : Auto-generated C + + source files

CMakeLists.txt:

The CMake script compiles a C + + source file based on the instructions of the build script, which is native-lib.cpp, throws the compiled product into the shared object library, names it as libnative-lib.so, and then Gradle it into the APK.

External Build Files  

Places where CMake or ndk-build build scripts are stored. A bit like the Build.gradle file tells Gradle how to compile your APP, CMake and Ndk-build also need a script to tell how to compile your native library.

Attention:

Android.mk and Application.mk, are automatically managed by the tool, no longer have to write, of course, can also be customized.

To write, please refer to: ANDROID.MK Analysis a article!

If you want to add as many methods to the Native-lib.cpp file, you must add theextern"C" { }, or before each method, add aextern"C" , Otherwise you will not find the method!

after configuration, the default is C + +, if you want to change to a C language suffix, directly to the native-lib.cpp, change to C, and remove the extern " C " ,

In the CMakeLists.txt file native-lib.cpp also modify the suffix name!

The final debugging, and Java breakpoint debugging is the same!



From for notes (Wiz)

Android studio22-ndk-lldb Debug

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.