[英]Unable to get gradle build-tools in docker - Apple M1
I recently switched to Apple M1 and am having a problem creating a docker image that eventually runs on a Buildkite linux CI.我最近切换到 Apple M1,但在创建最终在 Buildkite linux CI 上运行的 docker 映像时遇到问题。 The same code runs just fine on my MacBook with an Intel chip and successfully creates a docker image.
相同的代码在我的配备 Intel 芯片的 MacBook 上运行良好,并成功创建了 docker 映像。
The problem happens when sdkmanager
tries to pull in build-tools;${ANDROID_BUILD_TOOLS_VERSION}
with the latest commandlinetools
, it fails with the following errors:当
sdkmanager
尝试使用最新的commandlinetools
拉入build-tools;${ANDROID_BUILD_TOOLS_VERSION}
时会出现问题,它会失败并出现以下错误:
Warning: Dependant package with key emulator not found!
Warning: Unable to compute a complete list of dependencies.ates...
The closest issues I can find are Install build-tools: emulator not found and Error with android sdk , both without any resolutions.我能找到的最接近的问题是Install build-tools: emulator not found和Error with android sdk ,两者都没有任何解决方案。 Also note that I have run
sdkmanager --list
, and emulator
is not present as an available package there (just on M1).另请注意,我已经运行
sdkmanager --list
,并且emulator
没有作为可用的 package 存在(仅在 M1 上)。
Here is my Dockerfile
(I don't work with docker too often so please excuse if the code is not the cleanest):这是我的
Dockerfile
(我不经常使用 docker,所以如果代码不是最干净的,请原谅):
FROM gradle:7.4-jdk11
ENV SDK_URL="https://dl.google.com/android/repository/commandlinetools-linux-8092744_latest.zip" \
ANDROID_HOME="/usr/local/android-sdk" \
ANDROID_VERSION=32 \
ANDROID_BUILD_TOOLS_VERSION=32.0.0
RUN mkdir "$ANDROID_HOME" .android \
&& cd "$ANDROID_HOME" \
&& curl -o sdk.zip $SDK_URL \
&& unzip sdk.zip \
&& rm sdk.zip \
&& yes | $ANDROID_HOME/cmdline-tools/bin/sdkmanager --sdk_root=$ANDROID_HOME --licenses \
&& $ANDROID_HOME/cmdline-tools/bin/sdkmanager --sdk_root=$ANDROID_HOME --update \
&& $ANDROID_HOME/cmdline-tools/bin/sdkmanager --sdk_root=$ANDROID_HOME "platform-tools" "build-tools;${ANDROID_BUILD_TOOLS_VERSION}" \
&& $ANDROID_HOME/cmdline-tools/bin/sdkmanager --sdk_root=$ANDROID_HOME "platforms;android-${ANDROID_VERSION}" \
&& apt-get update \
&& apt-get install -y build-essential file apt-utils curl gnupg \
&& curl -sL https://deb.nodesource.com/setup_14.x | bash - \
&& apt-get -y install nodejs \
&& npm install -g firebase-tools -y \
&& rm -rf /var/lib/apt/lists/*
Side note;边注; I had to upgrade usage of jdk8 to jdk11 for the Android build agent, the previous implementation was pulling in
sdk-tools-linux-3859397.zip
instead of commandlinetools-linux-8092744_latest.zip
, and that was able to pull in build-tools
via the sdkmanager
just fine on the M1 as well and created a docker image. I had to upgrade usage of jdk8 to jdk11 for the Android build agent, the previous implementation was pulling in
sdk-tools-linux-3859397.zip
instead of commandlinetools-linux-8092744_latest.zip
, and that was able to pull in build-tools
通过sdkmanager
在 M1 上也很好,并创建了 docker 图像。
Given that it builds on Intel, my task is technically complete, but it's going to be much easier in the long run that it runs on M1.鉴于它建立在英特尔之上,我的任务在技术上是完整的,但从长远来看,它在 M1 上运行会容易得多。 Any ideas?
有任何想法吗? Or can anyone suggest what the right place would be to raise this?
或者任何人都可以建议提出这个问题的正确地方是什么? Do you reckon it is a google command line tool issue or docker issue?
您认为这是 google 命令行工具问题还是 docker 问题?
I just had the same problem on M1 Pro and this solved the issue for me.我刚刚在 M1 Pro 上遇到了同样的问题,这为我解决了这个问题。
In short: emulator
is not available on Arm (M1) yet so you need to install it manually.简而言之:
emulator
在 Arm (M1) 上不可用,因此您需要手动安装它。 You can follow the official guide but in short, this worked for me您可以按照官方指南进行操作,但简而言之,这对我有用
emulator
for Apple Silicon ( example or you find more links in the [official guide]( https://developer.android.com/studio/emulator_archiveemulator
( 示例或您在 [官方指南]( https://developer.android.com/studio/emulator_archive )中找到更多链接SKD/emulator
folder with files inside)SKD/emulator
文件夹)SDK/emulator/package.xml
file with content from here and update the last part of the xml <revision><major>31</major><minor>1</minor><micro>4</micro></revision>
with the version you downloadedSDK/emulator/package.xml
文件并更新 xml 的最后一部分<revision><major>31</major><minor>1</minor><micro>4</micro></revision>
与您下载的版本Spoiler Alert: I'm still not able to fully build on M1 because, during the actual build, I get the error剧透警告:我仍然无法在 M1 上完全构建,因为在实际构建期间,我收到了错误
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.