Skip to content Skip to sidebar Skip to footer

Running Ndk-gdb With Package Not Found Error On Motorola Phone

I have a C++ Android application that I'm trying to debug with ndk-gdb. The application does use multiple threads, but supposedly r5 of the ndk supports multiple threads. Also, I

Solution 1:

run-as: Package 'net.leifandersen.mobile.android.marblemachine'is unknown

Thus, unfortunately, your device is not able to be used with ndk-gdb, because run-as doesn't work. If you want to use that device, you must have root privilege.

EDITED:

Modify ndk-gdb script to get rid of the dependency of run-as. It works only on root privilege ('adb shell whoami' should be 'root').

--- ndk-gdb 2011-02-24 16:55:07.000000000 +0900
+++ ndk-gdb-root    2011-06-09 08:35:04.000000000 +0900
@@ -465,7 +465,7 @@
 log"Using app out directory: $APP_OUT"# Find the <dataDir> of the package on the device
-DATA_DIR=`adb_shell run-as $PACKAGE_NAME /system/bin/sh -c pwd`
+DATA_DIR="/data/data/$PACKAGE_NAME"log"Found data directory: '$DATA_DIR'"if [ $? != 0 -o -z "$DATA_DIR" ] ; thenecho"ERROR: Could not extract package's data directory. Are you sure that"
@@ -543,7 +543,7 @@

 # Launch gdbserver now
 DEBUG_SOCKET=debug-socket
-run $ADB_CMD shell run-as $PACKAGE_NAME lib/gdbserver +$DEBUG_SOCKET --attach $PID &
+run $ADB_CMD shell "(cd $DATA_DIR; lib/gdbserver +$DEBUG_SOCKET --attach $PID)" &
 if [ $? != 0 ] ; thenecho"ERROR: Could not launch gdbserver on the device?"exit 1

Solution 2:

There is a bug with run-as, it will fail if you have too many apps installed. I was able to work around this problem by removing some apps from my Evo 4G. I found this in the NDK discussion groups - http://groups.google.com/group/android-ndk/browse_thread/thread/ae9e8d5fe2716ae6?pli=1

Solution 3:

I had the same issue today with Samsung Galaxy S running MIUI rom. ndk-gdb always reported "Could not extract package's data directory. Are you sure that your installed application is debuggable?"

It turned out the reason is that run-as not working due to /data/data symlink. Cyanogen is used in the customized ROM. Removing the symbolic link and move all files from /datadata to /data/data solved the problem.

Cyanogen 2.3 fix:

ndk-gdb relies on the 'run-as' command, which itself makes a number of checks on the /data/data directory. In Cyanogen 2.3, it's a symlink, and run-as fails with a cryptic message, and ndk-gdb fails in return with [2]:

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

A work-around is to recreate /data/data with symlink :

cd /data/data /datadata.break-run-as
mkdir -m 771 /data/data/
chown system: v
mv /datadata/* /data/data/

http://en.wikibooks.org/wiki/OpenGL_Programming/Installation/Android_NDK

http://forum.cyanogenmod.com/topic/27657-run-as-not-working-due-to-datadata-symlink/

Hope it helps others with similar issue. Check to see if run-as works as expected or not. It's not because your binary is not debuggable. ndk-gdb's error message is very misleading.

Solution 4:

Had a similar problem and running:

adb shell run-as com.mypackagename /system/bin/sh -c pwd

would output:

run-as: Package 'com.mypackagename' has corrupt installation

fix was to uninstall on device then reinstall from command line via:

adb install MyApkFile.apk

Solution 5:

I also experienced this problem and discovered that it can be caused by short package names!

When testing on an Android 2.2 system with an application that had a package with 3 levels (e.g: a.b.c) ndk-gdb would not work. Changing the package to have 4 or more levels (e.g. a.b.c.d) or running on Android 2.3 or later resolved the issue.

see http://code.google.com/p/android/issues/detail?id=13965 for more information.

Post a Comment for "Running Ndk-gdb With Package Not Found Error On Motorola Phone"