skip to Main Content

I recently switched to Apple M1 and am having a problem creating a docker image that eventually runs on a Buildkite linux CI. The same code runs just fine on my MacBook with an Intel chip and successfully creates a docker image.

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:

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. Also note that I have run sdkmanager --list, and emulator is not present as an available package there (just on M1).

Here is my Dockerfile (I don’t work with docker too often so please excuse if the code is not the cleanest):

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.

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. 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?

2

Answers


  1. I just had the same problem on M1 Pro and this solved the issue for me.

    In short: emulator is not available on Arm (M1) yet so you need to install it manually. You can follow the official guide but in short, this worked for me

    1. Download emulator for Apple Silicon (example or you find more links in the [official guide](https://developer.android.com/studio/emulator_archive
    2. Unzip the folder in Android SDK folder (it will create a SKD/emulator folder with files inside)
    3. Create 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 downloaded
    4. You should not see the same error again on M1 🎉

    Spoiler Alert: I’m still not able to fully build on M1 because, during the actual build, I get the error

    qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
    
    Login or Signup to reply.
  2. I have same issue. I think there is no android ’emulator’ package for linux/armv8 . So you won’t be able to use docker with native images.

    I tried to configure docker-compose file in order to use linux/x86_64 instead of linux/armv8 but there are others issues.
    I add this line in docker-compose.yaml :

    platform: linux/x86_64
    

    like this :

    version: '3.7'
    services:
      android:
        platform: linux/x86_64
        build:
          dockerfile: Dockerfile
          context: ./Docker
        working_dir: /app/Android/Scripts
        volumes:
          - ../:/app:rw,cached
        command: ./build_distribution.sh
    #    command: sh -c "while true; do sleep 10; done"
    

    But I get a lot of issue with network. It seems that network layer on this architecture is buggy and sometimes it is stuck downloading an image or a component randomly…

    Is there a way to make it work with one or other architecture ?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search