gpt4 book ai didi

android - ansible android更新sdk给找不到sdkmanager.jar

转载 作者:太空宇宙 更新时间:2023-11-03 12:50:18 25 4
gpt4 key购买 nike

系统配置:Ubuntu 14.04ansible 1.9.3

下面是main.yml文件

--- 
-
hosts: 127.0.0.1
connection: local
sudo: yes
tasks:
-
name: "Install packages to install android sdk"
with_items:
- libgl1-mesa-dev:i386
apt: "name={{ item }} state=installed"
sudo: yes
-
name: "Install Java"
with_items:
- default-jre
- default-jdk
- openjdk-7-jre
- openjdk-7-jdk
apt: "name={{ item }} state=installed"
sudo: yes
-
name: "Download sdk tools"
get_url: url=http://dl.google.com/android/android-sdk_r24.3.4-linux.tgz dest=/opt/android-sdk_r24.3.4-linux
register: sdk_file
-
name: "Unarchiving sdk tools"
command: tar xzf {{sdk_file.dest}}
sudo: yes
args:
chdir: /opt
creates: /opt/android-sdk-linux
-
name: "write permissions to android home"
file: path=/opt/android-sdk-linux state=directory recurse=yes mode=0777
-
name: "write permission to sdkmanager.jar"
file: path=/opt/android-sdk-linux/tools/lib/sdkmanager.jar mode=0777
-
name: add android to path
lineinfile: >
dest=/etc/environment
state=present
backrefs=yes
regexp='PATH=(["]*)((?!.*?/opt/android-sdk-linux/tools).*?)(["]*)$'
line="PATH=\1\2:/opt/android-sdk-linux/tools\3"
-
name: "Install Android SDKs"
shell: "android update sdk -u -a -t {{ item }}"
with_items:
- "tools"
- "platform-tools"
- "build-tools-23.0.1"
- "build-tools-22.0.1"
- "android-23"
- "android-22"
- "android-21"
- "extra"
args:
executable: "/bin/bash"
environment:
PATH: /opt/android-sdk-linux/tools/:$PATH

android 可以从 PATH 访问。还看到我从 bash 将/opt/android-sdk-linux/tools 导出到我的 PATH 中,我能够运行 android 更新命令,我还递归地设置了 chmod 777 权限到/opt/android-sdk-linux 但不知何故ansible 无法访问它。

我看过this问题,但这没有帮助。

最佳答案

如我所见,您正在尝试使用位于 /opt/android-sdk-linux/tools/ 的 android 可执行文件。尝试使用它,放弃 PATH 的需要

  name: "Install Android SDKs"
shell: "/opt/android-sdk-linux/tools/android update sdk -u -a -t {{ item }}"
with_items:
- "tools"
- "platform-tools"
- "build-tools-23.0.1"
- "build-tools-22.0.1"
- "android-23"
- "android-22"
- "android-21"
- "extra"
args:
executable: "/bin/bash"

我还建议使用以下 shell 命令来接受所有许可证。

  shell: "echo \"y\" | /opt/android-sdk-linux/tools/android update sdk -u -a -t {{ item }}"

关于android - ansible android更新sdk给找不到sdkmanager.jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32836846/

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