I trying to start application via gradle
task
.
task runDebug(dependsOn: ['installDebug', 'run']) {
}
task run(type: Exec) {
commandLine 'adb', 'shell', 'am', 'start', '-n', 'com.example.myexample/.ui.SplashScreenActivity'
}
But this code don't work and i get error:
a problem occurred starting process 'command 'adb''
However, when i specify the path to adb explicitly, application is started.
task run(type: Exec) {
commandLine 'D:\\android\\android-studio\\sdk\\platform-tools\\adb', 'shell', 'am', 'start', '-n', 'com.example.myexample/.ui.SplashScreenActivity'
}
So how can i get a variable which contains the path and transfer it to commandLine
?
The problem was solved.
The variable must contain
And complete task looks like
UPD
Another way without using
ANDROID_HOME
My default solution for this issue is to add adb to your path variable so you can use the adb command from every path.
You can set it e.g. from the console like this:
Alternative you can set it via the UI. See also this explanation on java.com.
In Windows you can just register an
application path
foradb.exe
with the following.reg
file:and just keep your original commandline
You should use the logic that the Android Gradle plugin already has for finding the SDK and adb locations to ensure your script is using the same ones.
we can get if from android extension.
android.adbExe