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