debugging an app startup with android maven plugin

2019-08-11 19:23发布

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

3条回答
地球回转人心会变
2楼-- · 2019-08-11 19:41

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>]
查看更多
甜甜的少女心
3楼-- · 2019-08-11 19:47

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.

查看更多
Luminary・发光体
4楼-- · 2019-08-11 20:06

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

查看更多
登录 后发表回答