Still banging my head trying to get Android debugging to work in Eclipse, can anyone help?


I've spent a long time trying to figure out how to get debugging to work in Eclipse, so I can set up breakpoints and step through things. I'm so frustrated I want to headbutt my MacBook pro. I decided to try posting here again.

The basic issue is that if I try to do a "debug" build within Eclipse by going to Run -> Debug, it doesn't end up building it as a debug build. It instead tries to set it up as a release build, so DBG() doesn't end up defined as anything.

The solution advanced on this forum is to go to the terminal and build using "ant debug" and "ant release" instead. That's fine, but once I do that, then what? How do I run the program on the Android tablet, and then hook that into the debugger in Eclipse? How do I set up breakpoints and step through my code?

I've tried looking at a LOT of things, particularly right-clicking the build.xml file in Eclipse and doing "Ant Build..." and tweaking the infinitude of settings present, but I can't seem to find the magic workflow. If I do ant debug and then try to Debug again in Eclipse, it rebuilds it as a non-debug build, which is insane.

What is the full workflow that people are using and where does Eclipse fit into it?



That's eclipse for you! The environment where you can't "open" a project :-)

But seriously, what if you defined DEBUG manually somewhere to be sure. Or could this be a DEBUG vs NDEBUG thing. 

Just in case you want to try the "ant debug" approach, i had a look in my magic spell book...


warning: notes somewhat old

*** how to build code with NDK
cd project directory

*** how to build with ant
ant debug 
ant release
run emulator with
android avd
select emulator and "start"

run with
adb -e install bin/projectname-debug.apk (for emulator)
adb -d install bin/projectname-debug.apk (for device)
or for reinstall
adb install -r bin/projectname-debug.apk
adb -d uninstall <package>

*** debugging
ant debug 
install it.
start the app
cd project directory/Builds/Android
~/android-ndk-r8/ndk-gdb [--start]

set solib-search-path obj/local/armeabi
directory jni

*** how to set up cgdb debugging
download, cgdb-0.6.6-1.el5.i386.rpm
and install
change ~/android-ndk-r8/ndk-gdb from

*** GDB init files
put commands in 




Sorry, I'm still very confused. It doesn't bother me whether I go the "ant debug" route or whether I set up something similar in Eclipse - the only reason I kept going with ant is because people on here told me to. And you know what, that's fine, but the only thing I care about in the entire world right now is finding *some* way to get GDB working in the Eclipse interface, or in some other graphical interface, so I can do the following things:

  1. Set breakpoints
  2. Step over/step in/step out
  3. Have the debugger fire when exceptions are thrown
  4. Just debug my code like a normal person with some dignity :-|

Your instructions look like they build off of the notes I've made, but I still don't understand how to plug Eclipse into the whole thing - how??



Unfortunately, I fear that even if you get your GDB going in Eclipse it won't really be working. The reason i say this is because the few times that i managed to get some debugging going, the values it reported were totally wrong anyhow. I found myself stepping instructions like a monkey and watching the registers.

The dirty secret of Android is there isn't any debugging! save for printing stuff out. It's all just horrible.

What's Android Studio like? anyone tried that.


I did manage to get *something* working - the key is to make sure you set your build command to ndk-build NDK_DEBUG=1 CONFIG=Debug. Note that last flag - that's needed for JUCE to go all the way into Debug mode.

The second key is to add a link to your source code into the file itself. Right click on the project and go to Properties, then go to the C/C++ General category, then click "Paths and Symbols." In that, go to "Source Location," and then do "Link Folder..." and create a link to the folder containing your source code.

When you build in debug mode, the debugger will now at least be intelligent enough to tell you the symbolic name of the functions in the call stack, and so far it's seemed to be decent with watching data values. It isn't perfect, but it's a start!

However, as soon as you open up any C++ file in the editor, it immediately tries to do a bunch of intelligent symbol linking and craps out, giving you a bunch of errors like juce::Rectangle is undefined or whatever. To fix this, you actually need to go into the "Problems" list and delete the errors, or else it won't let you build the program correctly. I blew my little brother's mind (he's a CS student) by having this happen, then just deleting the errors, and then building the program just fine. He wasn't sure how programming worked anymore.

With reference to your last comment though, I don't understand how people do serious application development on Android if the general consensus is that there's no debugging.


I gave up trying to get debugging working on regular eclipse tools a while back. Then I found a link (cannot find it now) pointing to this


It includes the SDK and their version of ecllipse. Install that and download the necessary files. Then import your android project that Introjucer created, right click on the main item and go to Android Tools and choose Add Native Support. At this point you can build with the standard Cmd + B but to debug you have to create a debug configuration. In Project Explorer mode (C/C++ Workspace) go to the Run menu and choose "Debug Configurations". Then in the Android NDK Application section right click and make a new one. No settings need to be changed other than giving the project name, hit apply and Debug.

Now back in the Run menu choose Debug History and that debug configuration will show up and work.


This setup works flawlessly for me and I have even tried on a fresh machine. The key to finding source code to debug is to go under the "Binaries" section and draw down and find the .cpp file. From there normal breakpoints work great.


Post back if you have questions and I will try and help.


Also...this only seems to work on Mac. I have spent way too much time on my windows box getting native debug support and even the Tegra tools do not work.




The previous answer deserves a reward in my opinion :-)

I already had the nvidia dev pack installed, but I didn't try native debugging yet. (It's not mentioned in the Android Native Development Kit Cookbook, which is awkward if you think about all the people having problems with this.)

For me, it does work on Windows. I haven't tried it on my mac. I needed to do one extra thing:

In the package explorer, right click on the jni folder and add a new folder. Open the Advanced options and choose 'link to alternate location'. Then point to the folder containing the c++ code of your project (normally called 'Source'). If i don't add that folder, the debugger still won't stop at my breakpoints.

I guess you can add JuceLibraryCode in the same way if you want to debug into the juce library.