我试图通过gradle
task
.
task runDebug(dependsOn: ['installDebug', 'run']) {
}
task run(type: Exec) {
commandLine 'adb', 'shell', 'am', 'start', '-n', 'com.example.myexample/.ui.SplashScreenActivity'
}
但是这段代码不起作用,我得到错误:
a problem occurred starting process 'command 'adb''
但是,当我明确指定 adb 的路径时,应用程序就会启动。
task run(type: Exec) {
commandLine 'D:\\android\\android-studio\\sdk\\platform-tools\\adb', 'shell', 'am', 'start', '-n', 'com.example.myexample/.ui.SplashScreenActivity'
}
那么如何获取包含路径的变量并将其传输到commandLine
?