gpt4 book ai didi

android - 如何安装大量android-sdk工具并自动接受它们的许可?

转载 作者:行者123 更新时间:2023-11-30 01:02:27 24 4
gpt4 key购买 nike

我正在尝试通过 Gradle 脚本自动化安装一些 Android SDK 工具的过程。

想法是在 Docker 机器中运行此 build.gradle 脚本,这将在发布主构建本身之前准备环境。

我遇到的问题是自动接受我正在安装的相关软件包的许可证。

正在关注 this SO question ,我正在尝试使用这种方法:

echo "y" | android update sdk -u -a -t 2,4,56,57,58

如果我在终端中运行它,它可以在一个命令中使用最多 6 个包,但如果我想安装比这更多的包,例如:

echo "y" | android update sdk -u -a -t 2,6,7,4,30,153,160,161,167,54,53,63,56,57,58,59

然后命令失败:

Do you accept the license 'intel-android-extra-license-3626590a' [y/n]:
Unknown response ''.
Do you accept the license 'intel-android-extra-license-3626590a' [y/n]:
Unknown response ''.
Max number of retries exceeded. Rejecting 'intel-android-extra-license-3626590a'
Package Android TV Intel x86 Atom System Image, Android API 24, revision 6 not installed due to rejected license 'android-sdk-preview-license-d099d938'.
Package Android Wear ARM EABI v7a System Image, Android API 24, revision 1 not installed due to rejected license 'android-sdk-preview-license-d099d938'.
Package ARM 64 v8a System Image, Android API 24, revision 6 not installed due to rejected license 'android-sdk-preview-license-d099d938'.

不仅如此,我还需要 Gradle 为我运行它,当我这样做时,第一个 echo (echo "y") 的输出似乎由于某种原因没有重定向到管道。

所以当我运行相关的 Gradle 任务时:

12:46:01.178 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: STARTING
12:46:01.179 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Waiting until process started: command '/bin/echo'.
12:46:01.183 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: STARTED
12:46:01.183 [DEBUG] [org.gradle.process.internal.ExecHandleRunner] waiting until streams are handled...
12:46:01.183 [INFO] [org.gradle.process.internal.DefaultExecHandle] Successfully started process 'command '/bin/echo''
12:46:01.184 [QUIET] [system.out] y | /usr/local/bin/android update sdk -u -a -t 2,6,7,4,30,153,160,161,167,54,53,63,56,57,58,59
12:46:01.184 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: SUCCEEDED
12:46:01.185 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Process 'command '/bin/echo'' finished with exit value 0 (state: SUCCEEDED)
12:46:01.185 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':installSdkBuildTools'
12:46:01.185 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :installSdkBuildTools (Thread[main,5,main]) completed. Took 0.023 secs.
12:46:01.185 [DEBUG] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] Task worker [Thread[main,5,main]] finished, busy: 0.023 secs, idle: 0.001 secs
12:46:01.185 [DEBUG] [org.gradle.execution.taskgraph.DefaultTaskGraphExecuter] Timing: Executing the DAG took 0.044 secs
12:46:01.185 [LIFECYCLE] [org.gradle.BuildResultLogger]
12:46:01.186 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD SUCCESSFUL

echo 命令成功结束,退出状态为 0,但未安装包。

我尝试将命令分解为 3 个迷你命令,每次安装 6 个包,然后 echo "y"| android... 命令未正确解释,如上所述。

相关的 Gradle 任务如下所示:

task installSdkBuildToolsPart2(type: Exec) {
commandLine '/bin/echo', "y", '|', '/usr/local/bin/android ', 'update ', 'sdk ', '-u -a -t 160,161,167,54,53'
}

我也试过,但无济于事:

task installSdkBuildToolsPart1(type: Exec) {
commandLine 'bash', '-c'," '/bin/echo', "y", '|', '/usr/local/bin/android ', 'update ', 'sdk ', '-u -a -t 2,6,7,4,30,153'"
}

这是一个 Gradle 问题...我应该如何在 build.gradle 文件中正确编写 commandLine 指令,以便正确解释命令并安装包和许可证接受了吗?

有人知道如何解决这个问题吗?

提前致谢

最佳答案

你的问题是 Gradle 中的 exec 任务不知道管道,所以你写的只是将一些字符串传递给 echo; “y”、管道“|”、android 路径、更新命令等。

一种方法是将包含管道或其他 shell 重定向字符的要执行的命令放入 shell 脚本文件中,然后让 Gradle 任务执行该 shell 脚本。

关于android - 如何安装大量android-sdk工具并自动接受它们的许可?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39246308/

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