0

I'm testing an Android application. I used APKTOOL to decompile/recompile (with debug symbols). I performed a debug code sign, and then installed the APK. The program appears to run fine.

According to APKTOOL, I should be able to attach to the running process in NetBeans. But I'm only getting choices to attach to processes on localhost. DDMS is not showing a process tree and associated debug sockets as depicted in Figure 1 of Using DDMS. This is expected for all applications since I'm running a release kernel, but unexpected for the target process. I used DDMS to locate the PID on the device, but NetBeans claims "Not a valid PID" when I try to attach via PID. I also have the NBAndroid plugin installed.

How does one use NetBeans to attach to a process running on a device?

Jeff

jww
  • 97,681
  • 90
  • 411
  • 885
  • By switching to Eclipse or IntelliJ? Seriously, though I'm being flip with this answer, I'm also serious. Both Eclispe and IntelliJ have active developer support for Android tooling, and are robust. If you stick with Netbeans, you're likely to be spending a lot of time fighting with your developer tools - like you're doing right now. – mportuesisf Aug 01 '12 at 18:24
  • @mportuesisf - the APKTOOL page specifically states to use NetBeans because JPDA debugging is broken on Eclipse. Is that no longer the case? – jww Aug 01 '12 at 21:22
  • I use the Eclipse debugger all the time with Android apps, via Google's ADT plugin. I'd be surprised if much of JPDA is supported on Android. I have no idea if Android uses the JDI interface or the JDWP protocol. I just know that my debugger works for Eclipse and I don't have to futz around with it. – mportuesisf Aug 01 '12 at 21:51
  • @mportuesisf - OK, very good. I tried to create an Eclipse project from existing [smali] sources, but it did not turn out too well. So I'm not sure if Eclipse is a viable solution (and I don't want to spend hours knob turning). – jww Aug 02 '12 at 23:26
  • @mportuesisf - I think Eclipse might be a problem here. I need to attach to a running Java/Android application, but I only see "C/C++ Attach to Application" under configurations. A similar question was asked at http://stackoverflow.com/questions/655853/is-it-possible-to-attach-a-debugging-session-to-a-running-program-in-eclipse-cdt. – jww Aug 02 '12 at 23:47

1 Answers1

2

OK, found the issue. Even though I was asking APKTOOL for debugging information (ie, apktool -d ...), the tool did not generate a well formed AndroidManifest.xml (or fix-up the existing manifest). The manifest lacked android:debuggable="yes" in the application element. Or the APKTOOL documentation omitted the step...

"Cannot Attach Debugger to Application on Device," http://code.google.com/p/android-apktool/issues/detail?id=338.

There's also another problem lurking here: NetBeans 7.2 cannot consume the Smali files (even though previous version of NetBeans could). So there is no live analysis because the debugger cannot set breakpoints. See NetBeans/Smali Debugging is Broken (SmaliDebugging Page) and No MIME type for *.smali.

jww
  • 97,681
  • 90
  • 411
  • 885