Run ADB command from the build script

1,442 views
Skip to first unread message

Tomáš Procházka

unread,
Nov 23, 2014, 12:22:55 PM11/23/14
to adt...@googlegroups.com
I need to run some adb shell am commands after APK is installed on the device.
Has android gradle plugin some support for running adb commands please?

Bryan Herbst

unread,
Nov 24, 2014, 9:43:59 AM11/24/14
to adt...@googlegroups.com
Gradle provides a task type for executing commands from the command line. The documentation is located here.

As far as I know, there's are no hooks in the Gradle plugin for running ADB commands, so you will need to invoke the ADB executable using an exec task.

It might look something like this if you are running Windows:

task listAdbDevices(type:Exec) {
  workingDir '../'
  commandLine 'cmd', '/c', 'adb devices'

Tomáš Procházka

unread,
Nov 24, 2014, 4:33:31 PM11/24/14
to adt...@googlegroups.com
Thanks.

It is really pain to call adb from programm.

For  example adb install write error message to the stdout instead of stderr
adb push write all successfully pushed  files to the stderr :-( Why?
And also exit value is sometimes 0 also when some error is displayed :-(
Very sad.


Dne pondělí, 24. listopadu 2014 15:43:59 UTC+1 Bryan Herbst napsal(a):
Reply all
Reply to author
Forward
0 new messages