amrsa1 / Android-Emulator-image

The use of this Docker image simplifies the process of running an Android emulator within a Docker container
MIT License
112 stars 52 forks source link

Emulator start error #21

Open webberbond opened 8 months ago

webberbond commented 8 months ago

So, I was building a docker image on architecture linux/amd64. I got an image and wanted to setup my GitLab CI Pipeline:

stages: 
  - testing 
  - history_copy 
  - reports 
  - deploy 

docker_job:
  stage: testing
  image: webberbond/appium-python3.11-ewf
  tags:
    - docker
  before_script:
    - chmod +x ./scripts/start_emu_headless.sh
  script:
    - ./scripts/start_emu_headless.sh
  allow_failure: true
  artifacts:
    when: always
    paths:
      - ./allure-results
    expire_in: 1 day

history_job:
  stage: history_copy
  tags:
    - docker
  image: storytel/alpine-bash-curl
  script:
    - 'curl --location --output artifacts.zip "https://gitlab.com/api/v4/projects/20887326/jobs/artifacts/master/download?job=pages&job_token=$CI_JOB_TOKEN"'
    - apk add unzip
    - unzip artifacts.zip
    - chmod -R 777 public
    - cp -r ./public/history ./allure-results
  allow_failure: true
  artifacts: 
    paths:
      - ./allure-results
    expire_in: 1 day
  rules:
    - when: always

allure_job:
  stage: reports
  tags:
    - docker
  image: frankescobar/allure-docker-service
  script:
     - allure generate -c ./allure-results -o ./allure-report
  artifacts:
    paths:
      - ./allure-results
      - ./allure-report
    expire_in: 1 day
  rules:
    - when: always

When i started the pipeline the logs I obtained are:

Running with gitlab-runner 16.9.1 (782c6ecb)
  on green-4.saas-linux-small-amd64.runners-manager.gitlab.com/default ntHFEtyX, system ID: s_8990de[2](https://gitlab.com/webbersd/test-ci/-/jobs/6443251953#L2)1c550
  feature flags: FF_USE_IMPROVED_URL_MASKING:true
Preparing the "docker+machine" executor
01:50
Using Docker executor with image webberbond/appium-python[3](https://gitlab.com/webbersd/test-ci/-/jobs/6443251953#L3).11-ewf ...
Pulling docker image webberbond/appium-python3.11-ewf ...
Using docker image sha256:6e1616d109fa5dc3262a7b338b[4](https://gitlab.com/webbersd/test-ci/-/jobs/6443251953#L4)df[5](https://gitlab.com/webbersd/test-ci/-/jobs/6443251953#L5)19dc3d[6](https://gitlab.com/webbersd/test-ci/-/jobs/6443251953#L6)2e203b428ae0232[7](https://gitlab.com/webbersd/test-ci/-/jobs/6443251953#L7)e5ee4584b28 for webberbond/appium-python3.11-ewf with digest webberbond/appium-python3.11-ewf@sha256:aade93efc4ae0f1798d5250ec870e1511d5026a37095d6ae0015fccf136ed72f ...
Preparing environment
00:03
Running on runner-nthfetyx-project-56003221-concurrent-0 via runner-nthfetyx-s-l-s-amd64-1710994542-12594ae0...
Getting source from Git repository
00:08
Fetching changes with git depth set to 20...
Initialized empty Git repository in /builds/webbersd/test-ci/.git/
Created fresh repository.
Checking out 5ee22eeb as detached HEAD (ref is main)...
Skipping Git submodules setup
$ git remote set-url origin "${CI_REPOSITORY_URL}"
Executing "step_script" stage of the job script
00:07
Using docker image sha256:6e1616d109fa5dc3262a7b338b4df519dc3d62e203b428ae02327e5ee4584b28 for webberbond/appium-python3.11-ewf with digest webberbond/appium-python3.11-ewf@sha256:aade93efc4ae0f1798d5250ec870e1511d5026a37095d6ae0015fccf136ed72f ...
$ chmod +x ./scripts/start_emu_headless.sh
$ ./scripts/start_emu_headless.sh
* daemon not running; starting now at tcp:5037
* daemon started successfully
linux-gnu: emulator @nexus -no-window -no-snapshot -noaudio -no-boot-anim -memory 204[8](https://gitlab.com/webbersd/test-ci/-/jobs/6443251953#L8) -accel off -camera-back none -gpu off
INFO    | Storing crashdata in: /tmp/android-unknown/emu-crash-34.1.1[9](https://gitlab.com/webbersd/test-ci/-/jobs/6443251953#L9).db, detection is enabled for process: 29
INFO    | Android emulator version 34.1.19.0 (build_id 11525734) (CL:N/A)
INFO    | Found systemPath /opt/android/system-images/android-34/google_apis_playstore/x86_64/
WARNING | File System is not ext4, disable QuickbootFileBacked feature
WARNING | x86_64 emulation may not work without hardware acceleration!
WARNING | Your AVD has been configured with an in-guest renderer, but the system image does not support guest rendering.Falling back to 'swiftshader_indirect' mode.
INFO    | Storing crashdata in: /tmp/android-unknown/emu-crash-34.1.19.db, detection is enabled for process: 29
INFO    | Duplicate loglines will be removed, if you wish to see each individual line launch with the -log-nofilter flag.
INFO    | Increasing RAM size to 3072MB
library_mode swiftshader_indirect gpu mode swiftshader_indirect
Initializing hardware OpenGLES emulation supportandroid_startOpenglesRenderer: gpu infoI0321 04:20:28.073729      29 HealthMonitor.cpp:279] HealthMonitor disabled.
cannot add library /opt/android/emulator/qemu/linux-x86_64/lib64/vulkan/libvulkan.so: failed
cannot add library /opt/android/emulator/qemu/linux-x86_64/lib64/vulkan/libvulkan.so.1: failed
added library /opt/android/emulator/lib64/vulkan/libvulkan.so
createGlobalVkEmulation:964 Selecting Vulkan device: SwiftShader Device (Subzero)
initialize: Supports id properties, got a vulkan device UUID
WARNING: could not open libX11.so, try libX11.so.6
I0321 04:20:28.343840      29 VkCommonOperations.cpp:1226] Initializing VkEmulation features:
I0321 04:20:28.343865      29 VkCommonOperations.cpp:1227]     glInteropSupported: false
I0321 04:20:28.343870      29 VkCommonOperations.cpp:1228]     useDeferredCommands: true
I0321 04:20:28.343873      29 VkCommonOperations.cpp:1230]     createResourceWithRequirements: true
I0321 04:20:28.343875      29 VkCommonOperations.cpp:1231]     useVulkanComposition: false
I0321 04:20:28.343878      29 VkCommonOperations.cpp:1232]     useVulkanNativeSwapchain: false
I0321 04:20:28.343883      29 VkCommonOperations.cpp:1233]     enable guestRenderDoc: false
I0321 04:20:28.343887      29 VkCommonOperations.cpp:1234]     ASTC LDR emulation mode: 2
I0321 04:20:28.343889      29 VkCommonOperations.cpp:1235]     enable ETC2 emulation: true
I0321 04:20:28.343891      29 VkCommonOperations.cpp:1236]     enable Ycbcr emulation: false
I0321 04:20:28.343893      29 VkCommonOperations.cpp:1237]     guestUsesAngle: false
I0321 04:20:28.343896      29 VkCommonOperations.cpp:1238]     useDedicatedAllocations: false
I0321 04:20:28.344636      29 FrameBuffer.cpp:486] Graphics Adapter Vendor Google (Google Inc.)
I0321 04:20:28.344653      29 FrameBuffer.cpp:487] Graphics Adapter Android Emulator OpenGL ES Translator (Google SwiftShader)
I0321 04:20:28.344657      29 FrameBuffer.cpp:488] Graphics API Version OpenGL ES 3.0 (OpenGL ES 3.0 SwiftShader 4.0.0.1)
I0321 04:20:28.344659      29 FrameBuffer.cpp:489] Graphics API Extensions GL_OES_EGL_sync GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_depth24 GL_OES_depth32 GL_OES_element_index_uint GL_OES_texture_float GL_OES_texture_float_linear GL_OES_compressed_paletted_texture GL_OES_compressed_ETC1_RGB8_texture GL_OES_depth_texture GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_packed_depth_stencil GL_OES_vertex_half_float GL_OES_standard_derivatives GL_OES_texture_npot GL_OES_rgb8_rgba8 GL_EXT_color_buffer_float GL_EXT_color_buffer_half_float GL_EXT_texture_format_BGRA8888 GL_APPLE_texture_format_BGRA8888 
I0321 04:20:28.344662      29 FrameBuffer.cpp:490] Graphics Device Extensions N/A
OpenGL Vendor=[Google (Google Inc.)]OpenGL Renderer=[Android Emulator OpenGL ES Translator (Google SwiftShader)]OpenGL Version=[OpenGL ES 3.0 (OpenGL ES 3.0 SwiftShader 4.0.0.1)]INFO    | Sending adb public key [QAAAAL+KmdvBGplTr3YBVkxOdU8udCSnPyt01pJ3Zz7FE+5YdSjL4tt1nvx6BTBPpAc+/K3Xuz74bNCy8d1zsfkuSwj80pHcHnkWvws0zmocAVEDU8U7RJpwTkrTh3mJxSUf80j7zM2DZ0sKVw9s5/bQK3rCGWWl/1Hs8GmgkSOSAsJ62QlkjCLU9Try9/dTAWlrdJkeeBGjNqXJsurH2dy1zlGLWKW9BTvgIE0Y3Ea0ygy36x7F1/ccEb+gWD2mly8Z6TX7kXbPP7p6HLPWAHgH7AdSDe8RSNA+xlZtEo7ZpXH2ujmYNo82r5lVnas5HVToU0ebxYsp6YGHMQe7XL0qmzU7sSufL40/j5y5ddKzQjx1gjpsddSKglXZi3bbJoZMfjVaM0+R6Y5Pmk08/V9/pHFB28LkjpkZO60L+S+lmfUuFlzZMc1Q1jRRtYD/C8TMOrZSW+laZ5hORWqSUnC/JAo2RLWpQLQe58N359dBe0YGSz8jQI8WpDSi7Xw1Lz1KsPlgCG0A0Z1MSk6bHA1WXtVPrXXtyN7rZaeGn3zgtbnXAeYKpZwuYSR4p59doK+w0n9ByW2LlHpFVpDeyfWEtftHVE8Ng1RNtDHTQpi/dVaFrOg9KGNRJdmAs/LuZTCyjZ6KALsD77cRtOeMQi67QfYWkBWExQ3VOujPqvIqRcK5W52FBQEAAQA= @unknown]
TCG doesn't support requested feature: CPUID.01H:ECX.tsc-deadline [bit 24]
TCG doesn't support requested feature: CPUID.01H:ECX.avx [bit 28]
TCG doesn't support requested feature: CPUID.01H:ECX.f16c [bit 29]
TCG doesn't support requested feature: CPUID.01H:ECX.tsc-deadline [bit 24]
TCG doesn't support requested feature: CPUID.01H:ECX.avx [bit 28]
TCG doesn't support requested feature: CPUID.01H:ECX.f16c [bit 29]
WARNING: cannnot unmap ptr 0x7f5fe685c000 as it is in the protected range from 0x7f5fe685c000 to 0x7f60a6a5c000
WARNING: cannnot unmap ptr 0x7f60a6a0[10](https://gitlab.com/webbersd/test-ci/-/jobs/6443251953#L10)00 as it is in the protected range from 0x7f5fe685c000 to 0x7f60a6a5c000
WARNING | Using fallback path for the emulator registration directory.
WARNING | The emulator now requires a signed jwt token for gRPC access! Use the -grpc flag if you really want an open unprotected grpc port
INFO    | Using security allow list from: /opt/android/emulator/lib/emulator_access.json
WARNING | *** Basic token auth should only be used by android-studio ***
INFO    | The active JSON Web Key Sets can be found here: /root/.android/avd/running/29/jwks/b66c8346-fdd2-4bc1-b46a-7139cce5df4e/active.jwk
INFO    | Scanning /root/.android/avd/running/29/jwks/b66c8346-fdd2-4bc1-b46a-7139cce5df4e for jwk keys.
INFO    | Started GRPC server at [12](https://gitlab.com/webbersd/test-ci/-/jobs/6443251953#L12)7.0.0.1:8554, security: Local, auth: +token
WARNING | Using fallback path for the emulator registration directory.
INFO    | Advertising in: /root/.android/avd/running/pid_29.ini
I0321 04:20:28.455288      91 FrameBuffer.cpp:3707] setDisplayConfigs w [14](https://gitlab.com/webbersd/test-ci/-/jobs/6443251953#L14)40 h 2560 dpiX 560 dpiY 560
I0321 04:[20](https://gitlab.com/webbersd/test-ci/-/jobs/6443251953#L20):[28](https://gitlab.com/webbersd/test-ci/-/jobs/6443251953#L28).455647      91 FrameBuffer.cpp:[37](https://gitlab.com/webbersd/test-ci/-/jobs/6443251953#L37)20] setDisplayActiveConfig 0
INFO    | Cold boot: requested by the user
WARNING | Cold boot:  requested by the user
INFO    | Activated packet streamer for bluetooth emulation
==> Checking emulator booting up status 🧐
Uploading artifacts for failed job
00:00
Uploading artifacts...
WARNING: ./allure-results: no matching files. Ensure that the artifact path is relative to the working directory (/builds/webbersd/test-ci) 
ERROR: No files to upload                          
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1

Don't know how to fix, would like to get help

amrsa1 commented 8 months ago

==> Checking emulator booting up status

Does it fail right away after this line, or it take few minutes ?

webberbond commented 8 months ago

@amrsa1 it takes a few minutes

abaldwin-op commented 6 months ago

I resolved this (via Windows/Docker Desktop using the non-Windows specific yaml) by changing to install emulator as well. Assuming that's the right call, but still in early testing phase on my end.


However, I can't build the image on an M3, so that's another problem I need to learn more about... (Assuming something obvious I'm missing due to architecture.) Will research and potentially post a sep. issue if I need further help... And edit solution here either way.

Build error ``` docker build -t android-emulator . Android-Emulator-image [+] Building 2.1s (9/13) docker:desktop-linux => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 3.74kB 0.0s => [internal] load metadata for docker.io/library/openjdk:18-jdk-slim 0.9s => [internal] load .dockerignore 0.0s => => transferring context: 215B 0.0s => [ 1/10] FROM docker.io/library/openjdk:18-jdk-slim@sha256:8e17383576d7e71988ee5927473a32e8461381c7a29eefa9a0c24b3a28 0.0s => [internal] load build context 0.0s => => transferring context: 6.33kB 0.0s => CACHED [ 2/10] RUN apt update && apt install -y curl sudo wget unzip bzip2 libdrm-dev libxkbcommon-dev libgbm-dev li 0.0s => CACHED [ 3/10] RUN wget https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip -P /tmp 0.0s => CACHED [ 4/10] RUN yes Y | sdkmanager --licenses 0.0s => ERROR [ 5/10] RUN yes Y | sdkmanager --verbose --no_https system-images;android-34;google_apis_playstore;x86_64 plat 1.2s ------ > [ 5/10] RUN yes Y | sdkmanager --verbose --no_https system-images;android-34;google_apis_playstore;x86_64 platforms;android-34 build-tools;34.0.0 platform-tools emulator: Info: Parsing legacy package: /opt/android/cmdline-tools/tools Warning: Errors during XML parse: Warning: Additionally, the fallback loader failed to parse the XML. Warning: Failed to find package 'emulator' 1.126 [=== ] 10% Computing updates... ------ Dockerfile:50 -------------------- 48 | #============================================ 49 | RUN yes Y | sdkmanager --licenses 50 | >>> RUN yes Y | sdkmanager --verbose --no_https ${ANDROID_SDK_PACKAGES} 51 | 52 | #============================================ -------------------- ERROR: failed to solve: process "/bin/bash -c yes Y | sdkmanager --verbose --no_https ${ANDROID_SDK_PACKAGES}" did not complete successfully: exit code: 1 View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/s68eub1jc6wde7vscrszlwppx ```

My local setup before I found this image seemed fine, but I now notice these XML errors just the same:

🔮  sdkmanager emulator
Warning: Errors during XML parse:
Warning: Additionally, the fallback loader failed to parse the XML.
[=======================================] 100% Unzipping... emulator/._NOTICE.tx

Local for reference:

"Without Android Studio" 1. Install Android Studio Command Line Tools: https://developer.android.com/studio#command-tools - **MacOS** * [homebrew](https://formulae.brew.sh/cask/android-commandlinetools): `brew install --cask android-commandlinetools` - To see where things are installed: `brew info --cask android-commandlinetools` - **Windows** (_Fully untested_) * [scoop](https://scoop.sh/#/apps?q=android+command+line+tools): `scoop bucket add main` * ~~winget: [microsoft/winget-pkgs/issues/4082](https://github.com/microsoft/winget-pkgs/issues/4082)~~ 2. Install emulator and platform-tools: `sdkmanager platform-tools emulator` 3. Find _your_ target system image, platform, and build tools: `sdkmanager --list` - Example: * System Images: `system-images;android-33;google_apis;arm64-v8a` * Platform: `platforms;android-33` * Build Tools: `build-tools;33.0.3` 4. Install target platform, system image, and build tools: `sdkmanager "" "" ""` - Example: `sdkmanager "platforms;android-33" "system-images;android-33;google_apis;arm64-v8a" "build-tools;33.0.3"` * Alternatively, you can install components individually: ``` sdkmanager "platforms;android-33" sdkmanager "system-images;android-33;google_apis;arm64-v8a" sdkmanager "build-tools;33.0.3" ``` * If you don't specify a version for platforms or build tools, latest will be used: - Example: `sdkmanager "platforms;" "build-tools;"` 5. Create Android Virtual Device (AVD): `avdmanager create avd --name --package “”` - Example: `avdmanager create avd --name android-33 --package "system-images;android-33;google_apis;arm64-v8a"` * _Note: I did not elect to create a custom hardware profile when asked._ 6. Set [`ANDROID_HOME` environment variables](#environment-variables) 7. Run emulator to verify installation: `emulator -avd ` - Example: `emulator -avd android-33` 8. CTRL+C on running terminal to end the process, or: - Or: `adb -e emu kill` or `adb -s emu kill` - Or: `emulator -avd -no-window && emulator -avd -wipe-data`

Unfortunately, won't have time for a bit longer to dive into, but posting in case it helps someone else before I have a chance to revisit.

amrsa1 commented 6 months ago

@abaldwin-op

Yea, the actual issue that we are currently missing the support for apple silicon arm chip, looking forward to find a solution for that.