I am recently working on android native libraries development, required to be familiar with Android Studio. Via this sample, I learned something fundamental about ndk and jni routine. However, I am stuck on debugging native codes of this sample. Particularly, ndk's debugger works fine for emulator(Nexus 5X API 29 x86) while break points in native codes cannot be hit for real devices(HUAWEI P9, android Oreo). Besides, break points in java codes worked fine for real devices.
app's gradle script is as follows:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
ndkVersion '21.2.6472646'
defaultConfig {
applicationId 'com.android.gl2jni'
minSdkVersion 14
targetSdkVersion 28
externalNativeBuild {
cmake {
// Available arguments are inside ${SDK}/cmake/.../android.toolchain.cmake file
arguments '-DANDROID_STL=c++_static'
}
}
}
buildTypes {
release {
minifyEnabled = false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
version '3.10.2'
path 'src/main/cpp/CMakeLists.txt'
}
}
}
Other Details:
Using "Analyze APK" utility of Android Studio, I checked contents installed on my devices:
Then I found a bigger lib placed on
${project root}/app/build/intermediates/cmake/debug/obj/arm64-v8a
:
It seemed debugging symbols of native lib within the APK were stripped, And android studio didn't pack proper native lib for debugging?