gpt4 book ai didi

android - 添加 ADB 命令以构建序列 (Android Studio)

转载 作者:行者123 更新时间:2023-11-29 14:15:03 25 4
gpt4 key购买 nike

我正在使用 Android Studio,想知道是否可以将一些 ADB 命令添加到构建序列中。具体来说,在我的 USB 连接设备上安装该应用程序之前,我想发送一个按键事件来唤醒设备。可以自定义在构建序列结束时运行的 ADB 命令吗?在哪里输入这些自定义命令?

谢谢

最佳答案

是这样的。这是您需要调整您的路径和命令。

task runAdb(type:Exec) {
workingDir 'C:\\Users\\[user]\\AppData\\Local\\Android\\Sdk\\platform-tools'
println 'my custom task runs here'

//store the output instead of printing to the console:
//standardOutput = new ByteArrayOutputStream()

//add any number of commandLine commands here
commandLine "cmd","/c",'adb.exe devices'
commandLine "cmd","/c",'start .'

//println standardOutput.toString()
}

clean.dependsOn runAdb

另一个选项可以是(虽然我从来没有使用过它)将 ADB 命令放在 bat 文件中并添加它运行/调试配置> 在 android studio 启动之前。

enter image description here

关于android - 添加 ADB 命令以构建序列 (Android Studio),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21920675/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com