Android Studio 2.1 ndk Breakpoint Debugging method

Source: Internet
Author: User

Android Studio 2.1 ndk Breakpoint Debugging method (based on Android 2.1, Gradle 2.1.0)

1. Create an android Studio Project

2. Set the NDK path.

menu, choose: File->project Structure

In the left option box of the pop-up window, select SDK location, set Android NDK location on the right.

2. Modify the. \build.gradle as follows:

Replase

Classpath ' com.android.tools.build:gradle:2.1.0 '

With

Classpath ' com.android.tools.build:gradle-experimental:0.7.0 '

3. Modify the. \app\build.gradle as follows:

(1)

Replace

Apply plugin: ' Com.android.application '

With

Apply plugin: ' Com.android.model.application '

(2)

Replace

Android {

    ...

}

With

Model {

Android {

    ...

}

}

(3)

Replace

Minsdkversion 17

Targetsdkversion 23

With

Minsdkversion.apilevel 17

Targetsdkversion.apilevel 23

(4)

Replace

Proguardfiles getdefaultproguardfile (' proguard-android.txt '), ' Proguard-rules.pro '

With

Proguardfiles.add (File (' Proguard-rules.txt '))

The above is mainly a modification to the gradle.

After the above steps are modified, compile the project, it should be possible to compile the pass.

Next, we mainly make the NDK settings.

4. Modify. \app\build.gradle

Add the following NDK settings

Model {

Android {

....

NDK {

ModuleName = ' XXX '//.so module Name

Cflags.addall (['-wall '])//cflags

}

....

}

}

5. Create a JNI-related reference and an. h file in Java. (Online a lot, skip over here)

6. Under. \app\src\main, add the JNI directory.

By right-clicking Main in the "Project" sheet, in the pop-up menu: New->folder->jni Folder can be created

7. Create the. c,.cpp file yourself under. \app\src\main\jni.

8. Run, set the breakpoint in the C file debugging!


Android Studio 2.1 ndk Breakpoint Debugging method

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.