How to debug my application using adb (without IDE) android

I am using a gradle script to create an application in Eclipse. Using gradle, I can run the application on the device 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 works fine. Now I would like to write a task for debugging the application. So, is there any command for this in adb?

+6
source share
4 answers

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

+2
source

Since Android applications are written in java and run in a (custom) JVM, you can debug your application through the command line using adb and Java Debugger : jdb .

JDB is a simple command line debugger for Java classes.

See here and here for more explanation and guidance.

+1
source

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 here

+1
source

Using adb logcat is the preferred method. You will have to print the log messages for logcat by writing additional code in your application, for example:

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

log.d in your application is what allows you to keep a logcat debug log.

and then use:

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

...

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

to view this important debugging information.

Also see, for reference:

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

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

LogCat filter to receive only messages from My Android application?

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

+1
source

Source: https://habr.com/ru/post/981263/


All Articles