Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6003145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:04:49+00:00 2026-05-23T01:04:49+00:00

I have a C++ Android application that I’m trying to debug with ndk-gdb. The

  • 0

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’m not even getting to the point where gdb starts up. I run the command:

ndk-gdb --start --force --verbose

It then finds the proper path for the ndk and sdk (or at least adb), and the needed ABIs and whatnot.

$ ndk-gdb --start --force --verbose
Android NDK installation path: /home/leif/eclipse/android-ndk-r5b
Using default adb command: /home/leif/eclipse/android-sdk-linux_86/platform-tools/adb
ADB version found: Android Debug Bridge version 1.0.26
Using final ADB command: '/home/leif/eclipse/android-sdk-linux_86/platform-tools/adb'
Using auto-detected project path: .
Found package name: net.leifandersen.mobile.android.marblemachine
ABIs targetted by application: armeabi
Device API Level: 10
Device CPU ABIs: armeabi-v7a armeabi
Compatible device ABI: armeabi

It then looks for gdb server, and finds it, including the proper PID, followed by starting the activity.

But then, it tells me that the the package cannot be found:

Setup network redirection
## COMMAND: /home/leif/eclipse/android-sdk-linux_86/platform-tools/adb shell run-as <package name> lib/gdbserver +debug-socket --attach 16040
## COMMAND: /home/leif/eclipse/android-sdk-linux_86/platform-tools/adb forward tcp:5039 localfilesystem:run-as: Package '<package name>' is unknown/debug-socket

It then spits out what you would get if you improperly use adb (the help file), followed by:

ERROR: Could not setup network redirection to gdbserver?
       Maybe using --port=<port> to use a different TCP port might help?
run-as: Package '<package name>' is unknown

I looked into /data/system/packages.list, and yes, my apk is most certainly in there, and the location it’s pointing to is correct on the file system. So that’s not the problem.

This tutorial: http://vilimpoc.org/blog/2010/09/23/hello-gdbserver-a-debuggable-jni-example-for-android/ recommends deleting and reinstalling, as well as cleaning your eclipse build.

I didn’t use eclipse to build the package, but I did clean everything out and compile from scratch, deleted, and reinstalled to no luck.

Has anyone had similar problems, and how did you resolve them? Thank you.

Edit: Oh, and I have tried a different port to no avail, there does not appear to be anything on 5039 (the default port) anyway. And afaik, I don’t have any firewalls blocking that connection. I’m developing on Ubuntu 11.04 as well.

Edit2: Hmm…it looks like with the new ndk (r5c), the error message has now changed too:

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

And yes, debuggable is set to true in the manifest, and all of the native code is built with:

LOCAL_CFLAGS           := -Wall -g
LOCAL_LDFLAGS          := -Wl,-Map,xxx.map
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T01:04:50+00:00Added an answer on May 23, 2026 at 1:04 am
    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" ] ; then
         echo "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 ] ; then
         echo "ERROR: Could not launch gdbserver on the device?"
         exit 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Android application that is a TabHost with a WebView. I use
I have an Android application that makes use of TTS (Text to speech) API.
I have two threads in an Android application, one is the view thread, and
I have an Android application that generates some HTML which is rendered locally, in
I have an Android application that uses the well known Strategies for Legacy Applications
I have an Android application that connects to Facebook to request authorization of an
I have an android application that starts an activity and is running well. I
I have an Android application that I've been working on, and it's implemented using
I have an android application that parses some HTML, downloads an image, and displays
So I have an android application that needs to connect to a socket server.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.