我正在尝试制作一个可以用于构建Android项目的Docker镜像,使用Shippable.
问题是android update sdk命令,它给出以下错误:
Installing Android SDK Tools,revision 24.2
Failed to rename directory /opt/android-sdk-linux/tools to /opt/android-sdk-linux/temp/ToolPackage.old01.
Failed to create directory /opt/android-sdk-linux/tools
我在这里找到了一个解决方案:https://stackoverflow.com/a/8839359/867099,但它适用于Windows,似乎没有解决linux上的问题.看来,在update命令中,当前目录正在使用中,因此无法重命名.
RUN cp -r /opt/android-sdk-linux/tools /opt/android-sdk-linux/tools_copy
RUN cd /opt/android-sdk-linux/tools && echo 'y' | /opt/android-sdk-linux/tools_copy/android update sdk --no-ui -a --filter tools,platform-tools,build-tools-22.0.1,android-21,extra-android-support,extra-google-google_play_services --force
但是我觉得android命令也应该运行在正确的目录下,这就是为什么我先进入它.
但是,它仍然失败.我非常抱歉如何解决这个问题,所以任何帮助是赞赏.
——更新——–
我运行的android sdk update命令没有工具过滤器,最后,我的毕业生的建立是成功的.所以我不知道这是不是一个问题,不能更新他们…
有关Android开源项目问题跟踪的a post的详细解释:
The problem is caused when you run the SDK update in a Docker
container. Docker uses a special filesystem which works like a version
control system (e.g. git) and records all changes made to the
filesystem. The problem is that the SDK update uses a hardlink move
operation to move the ‘tools’ directory,which is not supported by the
underlying Docker filesystem.The solution for this is to simply run all Android SDK commands in a
single ‘RUN’ command in Docker. That way,the hardlink move works as
normal,as long as you don’t use the ‘hardlink move’ operation between
multiple RUN command (snapshots). The advantage of this is also that
your Docker layers will be smaller (compared to running multiple
seperate RUN commands).Here is the line from the Dockerfile:
RUN wget https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz && \
tar xzf android-sdk_r24.4.1-linux.tgz && \
rm android-sdk_r24.4.1-linux.tgz && \
(echo y | android-sdk-linux/tools/android -s update sdk --no-ui --filter platform-tools,tools -a ) && \
(echo y | android-sdk-linux/tools/android -s update sdk --no-ui --filter extra-android-m2repository,extra-google-google_play_services,extra-google-m2repository -a) && \
(echo y | android-sdk-linux/tools/android -s update sdk --no-ui --filter build-tools-23.0.2,android-24 -a)