[英]unzip returns non-zero code 2 on Android NDK zip (tested multiple versions)
I'm running the simple docker commands ( ubuntu:bionic
) to download Android NDK and unzip it:我正在运行简单的 docker 命令 ( ubuntu:bionic
) 来下载 Android NDK 并解压它:
ENV ANDROID_NDK_VERSION r21d
ENV ANDROID_NDK_URL http://dl.google.com/android/repository/android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip
RUN curl -L "${ANDROID_NDK_URL}" -o android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip
RUN unzip android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip -d ${SDK_HOME}
But I always get (even if I prune everything and start again):但我总是得到(即使我修剪一切并重新开始):
creating: /opt/android-ndk-r21d/wrap.sh/
inflating: /opt/android-ndk-r21d/wrap.sh/asan.sh
The command '/bin/sh -c unzip android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip -d ${SDK_HOME}' returned a non-zero code: 2
/opt/android-ndk-r21d/wrap.sh/asan.sh
is the last thing to be unzipped. /opt/android-ndk-r21d/wrap.sh/asan.sh
是最后要解压的东西。 On r20
, it's inflating: /opt/android-ndk-r20/ndk-stack
, then I get the same error.在r20
上,它正在inflating: /opt/android-ndk-r20/ndk-stack
,然后我得到同样的错误。
Running unzip with -v
as suggested below gives an weird output:按照下面的建议使用-v
运行解压缩会得到一个奇怪的 output:
16704 Defl:X 3281 80% 2019-05-22 12:47 80a0acc7 android-ndk-r20/sources/android/native_app_glue/android_native_app_glue.c
577 Defl:X 371 36% 2019-05-22 12:47 e63c146e android-ndk-r20/sources/android/native_app_glue/NOTICE
439 Defl:X 282 36% 2019-05-22 12:47 8fc9fc18 android-ndk-r20/sources/android/native_app_glue/Android.mk
0 Stored 0 0% 2019-05-22 12:47 00000000 android-ndk-r20/sources/android/renderscript/
577 Defl:X 371 36% 2019-05-22 12:47 e63c146e android-ndk-r20/sources/android/renderscript/NOTICE
813 Defl:X 234 71% 2019-05-22 12:47 bfbf4628 android-ndk-r20/sources/android/renderscript/Android.mk
2172 Defl:X 1117 49% 2019-05-22 12:47 43b8cf66 android-ndk-r20/CHANGELOG.md
92 Defl:X 86 7% 2019-05-22 12:50 250f0ae3 android-ndk-r20/ndk-stack
-------- ------- --- -------
3049400190 854740668 72% 18484 files
which executes instantly (no delay for unzipping) and then the image continues to build, but when it finishes there's nothing on the unzipped destination.它立即执行(解压缩没有延迟),然后图像继续构建,但是当它完成时,解压缩的目标上什么也没有。
I tried downloading sdk r21c
, r21b
thinking that maybe it was a problem with the zip archive, but it wasn't.我尝试下载 sdk r21c
和r21b
,认为这可能是 zip 存档的问题,但事实并非如此。 Container is ubuntu:bionic.容器是 ubuntu:bionic。
curl
was downloading corrupt files the majority of the time. curl
大部分时间都在下载损坏的文件。 Compred using sha1
from android website and from the downloaded file.使用来自 android 网站和下载文件的sha1
进行压缩。
By moving to wget
it worked...通过移动到wget
它起作用了......
According to the man page exit code 2 is a generic error.根据手册页,退出代码 2 是一般错误。
2 a generic error in the zipfile format was detected. 2 检测到 zip 文件格式中的一般错误。 Processing may have completed successfully anyway;处理可能已经成功完成; some broken zipfiles created by other archivers have simple work-arounds.其他存档器创建的一些损坏的 zip 文件有简单的解决方法。
Run unzip
with option -v
to see the diagnostic output, which should help debug this issue.使用选项-v
运行unzip
以查看诊断信息 output,这应该有助于调试此问题。
Edit: I'm not exactly sure what's going on with unzip, but the following works for me:编辑:我不确定解压缩发生了什么,但以下对我有用:
FROM ubuntu:bionic
ENV SDK_HOME /var/ndk
ENV ANDROID_NDK_VERSION r21d
ENV ANDROID_NDK_URL http://dl.google.com/android/repository/android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip
RUN apt-get update && apt-get -y install curl unzip && apt-get clean && \
curl -L "${ANDROID_NDK_URL}" -o android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip && \
unzip -qq android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip -d ${SDK_HOME} && \
rm -f android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip && \
apt-get -y remove curl unzip && apt-get -y autoremove && rm -rf /var/lib/apt/lists/*
Let me know if it helps让我知道是否有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.