9

I am using gradle script for building the app in Eclipse . By using gradle I can run the application to the device, by using the script in gradle.

task run(type: Exec, dependsOn: 'installDebug') {
    def adb = "$System.env.ANDROID_HOME/platform-tools/adb"
    commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.example.multidexproject/.MainActivity'     
}

and it is working fine .Now I would like to write a task for debugging the app . So there is any command for this in adb ?

Krish
  • 3,860
  • 1
  • 19
  • 32
  • If you just want to log to test, theres some google chrome plugins that can handle that. If you want to log with adb console, just check the docs, theres an way to attach to a process pid and check all the log, but i advise that the outcome is way worse than the one showed by the ide, its almost impossible to read it because it has so much data attached to it in a non human real time readable way. – Renato Probst Jan 27 '15 at 12:47

4 Answers4

3

You can simply use adb logcat to show the logs. Check this page for all the options.

SubliemeSiem
  • 1,129
  • 17
  • 25
2

Because android apps are written in java and run in a (custom) JVM, you can debug your app via command line using adb and Java Debugger: jdb.

JDB is a simple command-line debugger for Java classes.

For more explanations and tutorials, take a look to here and here.

bonnyz
  • 13,458
  • 5
  • 46
  • 70
2

Using adb logcat is the preferred method. You will have to print out the log messages to logcat by writing additional code in your app, like:

Log.d("Tag Name", "Log Message")

log.d in your app is what allows Debug level logging to logcat.

and then use:

adb -d logcat <your package name>:<log level> *:S

...

adb -d logcat com.example.coolapp:D *:S

to view that valuable debugging information.

Also see, for reference:

http://developer.android.com/tools/debugging/debugging-log.html

http://www.codelearn.org/android-tutorial/android-log

Filter LogCat to get only the messages from My Application in Android?

http://forum.xda-developers.com/showthread.php?t=1726238

Community
  • 1
  • 1
TryTryAgain
  • 7,632
  • 11
  • 46
  • 82
1

You can add this task:

runDebug {
   if (System.getProperties().containsKey('DEBUG')) {
    jvmArgs '-Xdebug',
        '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9009'
   }
}

and run:gradle -DDEBUG runDebug

More info here

Gomino
  • 12,127
  • 4
  • 40
  • 49