Marking an android app as debuggable

8,178 views
Skip to first unread message

Ranjit

unread,
May 27, 2010, 2:51:53 PM5/27/10
to android-ndk
I am unable to use ndk-gdb to debug my JNI code. It errors out saying
that the app is not debuggable. I have ensured the addition of the
"debuggable=true" attribute in AndroidManifest.xml.

<application android:icon="@drawable/icon" android:label="@string/
app_name" android:debuggable="true">

$ /cygdrive/c/android-sdk-windows/android-ndk-r4/ndk-gdb --adb=/
cygdriv
e/c/android-sdk-windows/tools/adb.exe
ERROR: Non-debuggable application installed on the target device.
Please re-install the debuggable version !

What could I be missing?

Thanks,
Ranjit

David Turner

unread,
May 27, 2010, 7:12:04 PM5/27/10
to andro...@googlegroups.com
Read the error message: the version installed on the device is not debuggable.

After modifying your manifest, you need to invoke ndk-build again, then generate a new .apk, then install it.


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.


gymshoe

unread,
Jun 6, 2010, 7:13:43 PM6/6/10
to android-ndk
I have the same error message when invoking ndk-gdb --verbose, but
there is more too it than previously posted here:

... <no errors reported above here> ...
Found device gdbserver: /data/data/com.meetlocalfish/lib/gdbserver: No
such file or directory
ERROR: Non-debuggable application installed on the target device.
Please re-install the debuggable version !

It seems that the gdbserver program is not found on the device which
might be the primary problem. However, how do I get it there?
I am particularly confused, because when I previously implemented gdb
for the ndk-sample "two-libs" program, the gdbserver program was
automatically installed onto the device after I had completed the ndk-
build and ndk-gdb commands... I didn't push anything, and there it
was...

So anyway, I tried manually pushing the gdbserver (located in
<myProjectRoot>/libs/armeabi/) onto the device at the specified
location.
Now, when I run the ndk-gdb, it finds the gdbserver, but I get the
following messages:

Launched gdbserver succesfully.
...<other non-error messages>...
run-as: exec failed for lib/gdbserver Error:Permission denied

BTW, I also noticed that the two-libs sample also "auto-installed"
into the <two-libs-Root-Dir>/bin/ndk/local/armeabi/ directory the
following: app_process and GDB.setup, which doesn't happen for my
project...

My biggest question is: How was the gdbserver appropriately installed
for the two-libs sample using ndk-build and ndk-gdb commands only, and
why isn't that happing with my app? I can post alot about my app, but
it is simple and not doing too much...

thanks for any help.

Jim
> > android-ndk...@googlegroups.com<android-ndk%2Bunsubscribe@googlegr oups.com>
> > .

gymshoe

unread,
Jun 6, 2010, 8:41:39 PM6/6/10
to android-ndk
So I tried implementing the ndk/samples/bitmap-plasma project as
well. (Eclipse, ADT, gdb)
While the two-libs project and the hello-jni project work fine with
gdb, the bitmap-plasma project does not.

It is the same result as for my project in that after running ndk-
build, the resulting .apk does not "auto" load the gdbserver onto the
emulator when you run the application. As before, I also see that
there is no creation of the files "app_process" or "gdbserver" into
the following directories: <project root dir>/bin/ndk/local/armeabi/
(or the coexistent .../armeabi-v7a/ directory)...

The process I followed:
Before building (ndk-build) verified:
that the Android.mk contains: LOCAL_CFLAGS := -g
the AndroidManifest.xml is set to debuggable (this is the default)

Then build. Run the app on Eclipse using the "Debug" mode (with
breakpoint right after onCreate()). (Checking the folder data/data/
com.meetlocalfish/lib I see that the appropriate library folder has
been created, but no gdbserver, so I am know this is going nowhere...)
Then run the "ndk-gdb --verbose" from the terminal with same resulting
message:
Found device gdbserver: /data/data/com.meetlocalfish/lib/gdbserver: No
such file or directory
ERROR: Non-debuggable application installed on the target device.
Please re-install the debuggable version !

So, I am not sure what the difference is between the bitmap-plasma
project and the other projects that it should fail. I see there is a
LOCAL_LDLIBS := -lm -llog -ljnigraphics
in the Android.mk of the bitmap-plasma, while there is no LOCAL_LDLIBS
in the Android.mk of the other two, but not sure how that counts for
much...

Jim

David Turner

unread,
Jun 6, 2010, 11:03:57 PM6/6/10
to andro...@googlegroups.com
The gdbserver binary from $PROJECT/libs/<abi>/gdbserver is only copied to your .apk if you are
target API level 8 or higher, and your manifest has android:debuggable==true.

At installation time, the gdbserver is extracted from the .apk and copied to /data/data/<package>/lib by
the PackageManager, provided you're running Android 2.2+ and your package's manifest has android:debuggable==true.

ndk-gdb uses the new "run-as" command to run a command or executable as a specific user/application.
This command only works for installed packages that are debuggable. More specifically, it will do:

run-as <package-name> lib/gdbserver <options>

A permission error is due to the fact that the installed package is not debuggable, and run-as will refuse
to run anything in this case, even if you copy the gdbserver binary manually.

Your problem here is likely that your package does not contain the gdbserver binary.
It could be due to not targeting API level 8, or due to not having android:debuggable set to true
when running ndk-build and/or later rebuiling the package.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.

David Turner

unread,
Jun 6, 2010, 11:06:02 PM6/6/10
to andro...@googlegroups.com
On Sun, Jun 6, 2010 at 5:41 PM, gymshoe <gymshoe...@gmail.com> wrote:
So I tried implementing the ndk/samples/bitmap-plasma project as
well.  (Eclipse, ADT, gdb)
While the two-libs project and the hello-jni project work fine with
gdb, the bitmap-plasma project does not.

It is the same result as for my project in that after running ndk-
build, the resulting .apk does not "auto" load the gdbserver onto the
emulator when you run the application.  As before, I also see that
there is no creation of the files "app_process" or "gdbserver" into
the following directories: <project root dir>/bin/ndk/local/armeabi/
(or the coexistent .../armeabi-v7a/ directory)...

The process I followed:
Before building (ndk-build) verified:
that the Android.mk contains:  LOCAL_CFLAGS := -g

For the record, you don't need to add this, this is already done by
the NDK for you, even if you don't select APP_OPTIM := debug

the AndroidManifest.xml is set to debuggable (this is the default)

NOTE: You should set this before invoking ndk-build !
 
Then build.

After the build, check that you have the binary in your package,
e.g. unzip -l bin/YouPackage-signed.apk or bin/YouPackage-debug.apk

 
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.

gymshoe

unread,
Jun 7, 2010, 8:24:09 PM6/7/10
to android-ndk
Hi,

1) Unfortunately, I was already building to Android 2.2 (8), and
already had android:debuggable=true in my manifest.

So I tried deleting the existing <bitmap-plasma-sample-project>.apk
(which was causing my "non-debuggable application" issue) , and
rebuilding (ndk-build) fresh, and lo-and-behold that seemed to work.
The Bitmap-Plasma sample will now allow connecting the gdbserver. I
think there may be some issue where the ndk-build doesn't properly
update an existing "non-debuggable" instance and make it debuggable,
unless you manually delete the apk first. (That seems a bit odd
though....????)

2) When you say "For the record, you don't need to add this, this is
already done by the NDK for you... ", what is the "this" that you are
referring to?
Adding the "LOCAL_CFLAGS := -g " to the Android.mk file?

Thanks for your comments and suggestions.
Jim


On Jun 6, 9:06 pm, David Turner <di...@android.com> wrote:

David Turner

unread,
Jun 7, 2010, 8:31:47 PM6/7/10
to andro...@googlegroups.com
On Mon, Jun 7, 2010 at 5:24 PM, gymshoe <gymshoe...@gmail.com> wrote:
Hi,

1)  Unfortunately, I was already building to Android 2.2 (8), and
already had android:debuggable=true in my manifest.

So I tried deleting the existing <bitmap-plasma-sample-project>.apk
(which was causing my "non-debuggable application" issue) , and
rebuilding (ndk-build) fresh, and lo-and-behold that seemed to work.
The Bitmap-Plasma sample will now allow connecting the gdbserver. I
think there may be some issue where the ndk-build doesn't properly
update an existing "non-debuggable" instance and make it debuggable,
unless you manually delete the apk first.  (That seems a bit odd
though....????)

2)  When you say "For the record, you don't need to add this, this is
already done by the NDK for you... ", what is the "this" that you are
referring to?
Adding the "LOCAL_CFLAGS := -g " to the Android.mk file?


it means that even in "release" mode, the -g option is passed to the compiler when generated the binaries
(-O2 -DNDEBUG is also passed, so native code is optimized).
 
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.

David Turner

unread,
Jun 7, 2010, 8:32:05 PM6/7/10
to andro...@googlegroups.com
On Mon, Jun 7, 2010 at 5:24 PM, gymshoe <gymshoe...@gmail.com> wrote:
Hi,

1)  Unfortunately, I was already building to Android 2.2 (8), and
already had android:debuggable=true in my manifest.

So I tried deleting the existing <bitmap-plasma-sample-project>.apk
(which was causing my "non-debuggable application" issue) , and
rebuilding (ndk-build) fresh, and lo-and-behold that seemed to work.
The Bitmap-Plasma sample will now allow connecting the gdbserver. I
think there may be some issue where the ndk-build doesn't properly
update an existing "non-debuggable" instance and make it debuggable,
unless you manually delete the apk first.  (That seems a bit odd
though....????)

mmm, do you have any way to reproduce the problem ?
 
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.

dhd

unread,
Jul 1, 2010, 2:16:07 PM7/1/10
to android-ndk
So am I right to assume that debugging an NDK application with ndk-gdb
is basically impossible unless you:

(a) have Android 2.2 installed (haven't gotten the OTA update yet -
is there a legitimate place to download it or is it all leaks/hacks?),
or
(b) have a rooted device so that you can manually upload gdbserver?

Angus Lees

unread,
Jul 1, 2010, 11:51:03 PM7/1/10
to andro...@googlegroups.com
(c) are using the emulator (any version), since there you have root and gdbserver already installed

 - Gus

David Turner

unread,
Jul 2, 2010, 1:56:50 AM7/2/10
to andro...@googlegroups.com
ndk-gdb requires 2.2, period.

Now, it is possible to debug native code without ndk-gdb on other systems, if there is a gdbserver already installed (e.g. SDK system images) or if you can copy one there (e.g. rooted system). However, this is quite tedious and prone to error.


--

David Turner

unread,
Jul 2, 2010, 1:57:29 AM7/2/10
to andro...@googlegroups.com
On Thu, Jul 1, 2010 at 10:56 PM, David Turner <di...@android.com> wrote:
ndk-gdb requires 2.2, period.

Now, it is possible to debug native code without ndk-gdb on other systems, if there is a gdbserver already installed (e.g. SDK system images) or if you can copy one there (e.g. rooted system). However, this is quite tedious and prone to error.

I must correct this by saying you need to be root if you're not using ndk-gdb as well. 
Reply all
Reply to author
Forward
0 new messages