There are 2 services:
services:
...other
emulator:
build:
context: .
dockerfile: './rust-jni/Dockerfile.emulator'
command: emulator -avd test_avd -no-snapshot -no-audio -no-window -read-only -port 5554 -selinux permissive
image: emulator-base
android:
build:
context: .
dockerfile: './rust-jni/Dockerfile.android'
depends_on:
- rust
- emulator
command: >
sh -c "
sleep 35 &&
until adb kill-server && adb start-server && adb connect emulator:5554 && adb devices | grep -m 1 '1'; do sleep 1; done &&
adb wait-for-device &&
until echo 'Wait...' && adb shell getprop sys.boot_completed | grep -m 1 '1'; do sleep 1; done &&
adb install -t app/build/outputs/apk/debug/app-debug.apk &&
adb shell am start -n com.example.myapp/.MainActivity"
When running docker-compose up
adb
does not connect to emulator
:
Cyclic output:
android-1 | * daemon not running; starting now at tcp:5037
android-1 | * daemon started successfully
android-1 | failed to connect to 'emulator:5554': Connection refused
I tried to connect to emulator
via adb
on my windows:
Changed:
services:
...
emulator:
...
ports:
- 5554:5554
Unsuccessful:
D:\sdk\emulator>adb connect 127.0.0.1:5554
already connected to 127.0.0.1:5554
D:\sdk\emulator>adb devices
List of devices attached
127.0.0.1:5554 offline
There may be a problem inside the emulator
service.
Dockerfile.emulator
:
FROM thyrlian/android-sdk:latest
ENV ANDROID_SDK_ROOT=/opt/android-sdk
ENV PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/emulator
# Установите необходимые пакеты для ARMv7 эмулятора
RUN sdkmanager --install "system-images;android-21;google_apis;armeabi-v7a" \
&& sdkmanager --install "platform-tools" \
&& sdkmanager --install "platforms;android-21" \
&& sdkmanager --install "emulator"
# Создание AVD
RUN echo "no" | avdmanager create avd -n test_avd -k "system-images;android-21;google_apis;armeabi-v7a" -f
Output docker-comopose
emulator
:
Attaching to android-1, emulator-1
emulator-1 | INFO | Storing crashdata in: /tmp/android-unknown/emu-crash-35.1.20.db, detection is enabled for process: 1
emulator-1 | INFO | Android emulator version 35.1.20.0 (build_id 12234392) (CL:N/A)
emulator-1 | INFO | Graphics backend: gfxstream
emulator-1 | INFO | Found systemPath /opt/android-sdk/system-images/android-21/google_apis/armeabi-v7a/
emulator-1 | WARNING | File System is not ext4, disable QuickbootFileBacked feature
emulator-1 | WARNING | encryption is off
emulator-1 | WARNING | FeatureControl is requesting a non existing feature.
emulator-1 | ERROR | Unable to connect to adb daemon on port: 5037
emulator-1 | WARNING | FeatureControl is requesting a non existing feature.
emulator-1 | WARNING | FeatureControl is requesting a non existing feature.
emulator-1 | WARNING | Your GPU drivers may have a bug. Switching to software rendering.
emulator-1 | ERROR | emuglConfig_get_vulkan_hardware_gpu: Failed to create vulkan instance error code: -9
emulator-1 | WARNING: could not open libX11.so, try libX11.so.6
emulator-1 | WARNING: cannnot unmap ptr 0x7fa8bde53000 as it is in the protected range from 0x7fa8bde53000 to 0x7fa8fe053000
emulator-1 | WARNING: cannnot unmap ptr 0x7fa8fe001000 as it is in the protected range from 0x7fa8bde53000 to 0x7fa8fe053000
emulator-1 | WARNING | could not find /usr/share/zoneinfo/ directory. unable to determine host timezone
emulator-1 | INFO | Storing crashdata in: /tmp/android-unknown/emu-crash-35.1.20.db, detection is enabled for process: 1
emulator-1 | INFO | Duplicate loglines will be removed, if you wish to see each individual line launch with the -log-nofilter flag.
emulator-1 | INFO | Increasing RAM size to 1024MB
emulator-1 | library_mode swangle_indirect gpu mode swangle_indirect
emulator-1 | INFO | Initializing hardware OpenGLES emulation support
emulator-1 | android_startOpenglesRenderer: gpu infoI0908 14:31:54.343054 1 FrameBuffer.cpp:262] Not raising nofile soft limit from 1048576.
emulator-1 | I0908 14:31:54.343152 1 HealthMonitor.cpp:279] HealthMonitor disabled.
emulator-1 | I0908 14:31:54.417056 1 FrameBuffer.cpp:505] Graphics Adapter Vendor Google (Google Inc.)
emulator-1 | I0908 14:31:54.417071 1 FrameBuffer.cpp:506] Graphics Adapter Android Emulator OpenGL ES Translator (Google SwiftShader)
emulator-1 | I0908 14:31:54.417074 1 FrameBuffer.cpp:507] Graphics API Version OpenGL ES 3.0 (OpenGL ES 3.0 SwiftShader 4.0.0.1)
emulator-1 | I0908 14:31:54.417075 1 FrameBuffer.cpp:508] 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
emulator-1 | I0908 14:31:54.417078 1 FrameBuffer.cpp:509] Graphics Device Extensions N/A
emulator-1 | INFO | Monitoring duration of emulator setup.
emulator-1 | I0908 14:32:01.823521 54 FrameBuffer.cpp:2884] Setting display: 0 configuration to: 320x640, dpi: 160x160
emulator-1 | I0908 14:32:01.823563 54 FrameBuffer.cpp:2897] setDisplayActiveConfig 0
emulator-1 | ##############################################################################
emulator-1 | ## WARNING - ACTION REQUIRED ##
emulator-1 | ## Consider using the '-metrics-collection' flag to help improve the ##
emulator-1 | ## emulator by sending anonymized usage data. Or use the '-no-metrics' ##
emulator-1 | ## flag to bypass this warning and turn off the metrics collection. ##
emulator-1 | ## In a future release this warning will turn into a one-time blocking ##
emulator-1 | ## prompt to ask for explicit user input regarding metrics collection. ##
emulator-1 | ## ##
emulator-1 | ## Please see '-help-metrics-collection' for more details. You can use ##
emulator-1 | ## '-metrics-to-file' or '-metrics-to-console' flags to see what type of ##
emulator-1 | ## data is being collected by emulator as part of usage statistics. ##
emulator-1 | ##############################################################################
emulator-1 | WARNING | Cold boot: requested by the user
emulator-1 | INFO | Cold boot: requested by the user
emulator-1 | WARNING | Failed to process .ini file /root/.android/emu-update-last-check.ini for reading.
emulator-1 | WARNING | Failed to process .ini file /root/.android/emu-update-last-check.ini for reading.
emulator-1 | WARNING | could not find /usr/share/zoneinfo/ directory. unable to determine host timezone