Gradle,向adb发送命令

wha*_*are 5 android gradle

每次运行测试之前我都需要它,使用命令运行任务 adb

adb shell pm reset-permissions

我尝试在我的gradle文件中执行此操作,这是令人满意的,但它是如何运行的?

buildscript {
...
}

android {
...
}

task resetPermission(type: Exec) {
    commandLine 'adb', 'shell', 'pm', 'reset-permissions'
}
Run Code Online (Sandbox Code Playgroud)

NSi*_*mon 2

您需要编辑测试运行配置才能添加任务。

在这里查看我的(类似)答案:https ://stackoverflow.com/a/35157119/4706693