Thursday, February 27, 2014

ndk-gdb error: Could not extract package's data directory. Are you sure that your installed application is debuggable?

The Problem

You have a phone running Android 4.3 and you are trying to debug your native C++ application using the Android NDK version r9c with ndk-gdb.
When you enter the ndk-gdb command you get the error:

$ ndk-gdb  
ERROR: Could not extract package's data directory. Are you sure that
       your installed application is debuggable?
 
You can find a description of this problem in Android Issue number 58373.
I encountered this problem with a Samsung Galaxy S4 running Android 4.3. 

The Solution

The easiest solution for me was to root the device and change the permissions of the run-as command to run as root. You can achieve this by running the following commands using the ADB shell:

$ su -


# mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
# chmod 4750 /system/bin/run-as
# mount -o ro,remount -t yaffs2 /dev/block/mtdblock3 /system