ndk-gdb 4.3 error(Could not extract package's data directory)
Could not extract package's data directory. Are you sure that your installed application is debuggable？
This is a known bug of the Android platform. When you try to debug your NDK-based app, gdbserver fails to start and a message like below is shown:
This happens due to two known bugs related to the run-as tool. The tool needs to read information about your app from the /data/system/packages.list file inside your Android device. In the case of the first bug, the tool is actually only reading the first 8KB of the file. Thus, if the line containing your app description is below the first 8 KB, run-as will fail. The second bug affects some 4.2.2 and 4.3 Android images by falsely restricting read rights of the packages.list file that contains all the package names.
8 Kilobyte Bug
- Retrieve the packages.list file by running the following command inside SDK\platform-tools:
- If the file is larger than 8 kilobytes, your problem is caused by the 8 kilobyte bug.
There are three known workarounds for this bug:
- Uninstall unnecessary apps from your Android device to reduce the size of the packages.list file
- Try renaming the app ID arbitrarily. The order of the lines inside packages.list depends on the hash value of the app ID. Thus changing the ID just a bit might put it within the first 8 KB.
- If your device is rooted, edit the packages.list file manually to put your app in front of the list.
Read Rights Bug
- Is your Nexus or Galaxy Android device using Android 4.2.2 or Android 4.3?
- Open Android shell. Change directory to "/data/system", run the command "ls -l". Are the access rights to packages.list "-rw-rw----" instead of "-rw-rw-r--" ? If yes, then your device's image is affected by the bug.
- Install the 4.3 factory image for the Android device manually. Do not install the mini 4.3 update after installing the image.
- If your device is rooted, change the read rights of the packages.list file.
- Add the set-uid bit to the run-as binary:
- Try other workarounds from the official bug thread.