0

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:enter image description here Then I found a bigger lib placed on ${project root}/app/build/intermediates/cmake/debug/obj/arm64-v8a: enter image description here It seemed debugging symbols of native lib within the APK were stripped, And android studio didn't pack proper native lib for debugging?

Finley
  • 795
  • 1
  • 8
  • 26

1 Answers1

0

What you see in the APK Analyzer is not the size of the file, but rather the packed size (the binaries are compressed unless you have extractNativeLibs=false in your Manifest).

At any rate, you seem to have hit a device-specific problem here, see Not working - Debug Mode native code (c/c++) on Android studio with tablet HUAWEI MediaPad M5.

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307