1

I'm working with the latest version of android maven plugin. I use android:deploy and android:run to launch my app on my device. When I want to debug, I go into DDMS in eclipse and check the green bug icon for my app. Everything works fine... but I can only debug a running app, ie it has already started. If I put a breakpoint in my application constructor or onCreate, it wont stop (obviously because the application has started and the debugging didn't been activated... yet).

So my question is: how can I start my app in debug mode directly from maven like I would do for an app that I start from eclipse ?

thanks ahead

Gomoku7
  • 1,362
  • 13
  • 31
  • Have you confirmed your Eclipse settings with the suggestions made in the documentation (http://code.google.com/p/maven-android-plugin/wiki/Debug)? – Sri Sankaran Dec 30 '11 at 12:09
  • Yes Sir! It's what I describing in the first part of my question. It runs just fine like in the documentation. But not at startup! – Gomoku7 Jan 15 '12 at 22:22

3 Answers3

4

Thanks to Lukasz, I found the command in Idea that is launched to trigger the debug mode. Basically, the application is deployed with android:deploy but instead of android:run, I launch a shell "am" command with -D. Here's the usage for anyone interested.

ovh-ybi$ adb shell
# am
usage: am [subcommand] [options]

start an Activity: am start [-D] <INTENT>
    -D: enable debugging

send a broadcast Intent: am broadcast <INTENT>

start an Instrumentation: am instrument [flags] <COMPONENT>
    -r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT)
    -e <NAME> <VALUE>: set argument <NAME> to <VALUE>
    -p <FILE>: write profiling data to <FILE>
    -w: wait for instrumentation to finish before returning

start profiling: am profile <PROCESS> start <FILE>
stop profiling: am profile <PROCESS> stop

<INTENT> specifications include these flags:
    [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]
    [-c <CATEGORY> [-c <CATEGORY>] ...]
    [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]
    [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]
    [-e|--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]
    [-n <COMPONENT>] [-f <FLAGS>] [<URI>]
Gomoku7
  • 1,362
  • 13
  • 31
-1

Instead of android:deploy and android:run you could just launch your application in debug by eclipse and not by maven. You have to have your project configured properly to do this.

  • Thanks for the answer. This is a bit difficult to achieve because Maven and Eclipse don't see the same things. I spent an hour tring that. It means also loosing the dependency system of maven and transforms the management of libs in something awful in eclipse. Main issue : eclipse try to insert a libs with javax into the apk... and dalvik dosnt like that. Why does eclipse do that ? dont know? Where? dont know either.. – Gomoku7 Feb 02 '12 at 10:03
  • 1
    I'm using Idea instead of Eclipse. Maybe you could try this? Our project in Eclipse constantly broken. Because of that I had to play with my device who's faster: me in clicking the debug in ddms or it in starting the app. In Idea everything is all right most of the time. I can start app in debug mode from Idea – Łukasz Klich Feb 09 '12 at 12:46
  • I installed Idea just to try it and it give me the information I was looking for. Thanks Lukasz. See answer below. – Gomoku7 Feb 09 '12 at 18:53
-1

You can deploy and start it using this post. To debug I guess and hope you only need to change some parameters.

Community
  • 1
  • 1
Karussell
  • 17,085
  • 16
  • 97
  • 197
  • That's interesting, thanks. But I didnt find any way to activate debugging. There's no parameters that do that in the documentation. – Gomoku7 Feb 02 '12 at 10:10
  • But here is the docu. I think you'll need to specify a port and attach the debugger to it http://code.google.com/p/maven-android-plugin/wiki/Debug – Karussell Feb 03 '12 at 20:26
  • Well... that's currently how I'm doing things. If you read carrefully, you'll see that the app is launched (point 2) and only AFTER the debugging is started (point 5). What I want is when the application is launched, the debugging has started at the same time. – Gomoku7 Feb 05 '12 at 10:05
  • Sorry for wasting your time. I would attach the debugger before I start the real debug process and set the timeout high enough (at least in Netbeans there is an option for this). Also you could introduce a sleep before the critical breakpoint or just use eclipse or use a different activity which starts an intent of the actual activity or what ever. be creative :) ! – Karussell Feb 05 '12 at 15:23
  • No no! your ideas are more than welcome and thanks for yours comments! There's in fact a lot of solutions possibles to debug in the application onCreate or in the application constructor, but it's always tricks (loggers can do the job perfectly). I was just wondering if there was some normal way of initializing the debugging before it even started in a console manner. How is eclipse doing ? – Gomoku7 Feb 06 '12 at 16:56
  • 2
    I just added a comment the the referenced post, but thought it would be a good idea to add it here too. You can use -Dandroid.run.debug=true to activate debugging when the app starts. – Tom Bollwitt Oct 24 '12 at 21:18