簡體   English   中英

Docker 容器中的 Android Studio 仿真器出現問題

[英]Problem with Android Studio emulator in Docker container

我有一個帶有 Android studio 3.6 的 Docker 容器,它運行良好。 問題是模擬器無法運行,因為 Ubuntu 機器沒有 CPU 來重現 x86。 有誰知道如何將它包含在 Dockerfile 中? 謝謝你。

這是我的 Dockerfile:

FROM ubuntu:16.04

RUN dpkg --add-architecture i386

RUN apt-get update

# Download specific Android Studio bundle (all packages).
RUN apt-get install -y curl unzip
RUN apt-get install -y git
RUN curl 'https://uit.fun/repo/android-studio-ide-3.6.3-linux.tar.gz' > /studio.tar.gz && \
  tar -zxvf studio.tar.gz && rm /studio.tar.gz


# Install X11
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get install -y xorg


# Install other useful tools
RUN apt-get install -y vim ant

# install Java
RUN apt-get install -y default-jdk

# Install prerequisites
RUN apt-get install -y libz1 libncurses5 libbz2-1.0:i386 libstdc++6 libbz2-1.0 lib32stdc++6 lib32z1
RUN apt-get install wget
RUN wget 'https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip' -P /tmp \
&& unzip -d /opt/android /tmp/sdk-tools-linux-4333796.zip 
RUN apt install xserver-xorg-video-amdgpu
# Clean up
RUN apt-get clean
RUN apt-get purge


ENTRYPOINT [ "android-studio/bin/studio.sh" ]

當您在 docker 中使用 ubuntu 時,運行 android 仿真器的唯一方法是找到帶有“arm”的system-images;android-25;google_apis;armeabi-v7a

但是,即使您能夠在容器中運行模擬器,您也可能會對此感到失望。 由於基於 arm 的模擬器通常啟動速度很慢,更不用說在 docker 中運行可能會更慢。


如果您真的想創建它,可以執行以下操作。

sdkmanager "system-images;android-25;google_apis;armeabi-v7a"
avdmanager create avd -n demoTest -d "pixel" -k "system-images;android-25;google_apis;armeabi-v7a" -g "google_apis" -b "armeabi-v7a"
emulator @demoTest -no-window -no-audio -verbose &

一旦你得到這個提示信息

模擬器:從訪客系統指紋 HAL 收到消息

您的仿真器已准備好 go。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM