mirror of
https://github.com/HQarroum/docker-android.git
synced 2026-11-21 11:45:56 +00:00
Merge pull request #5 from twocolors/main
support all variables for docker and fix recreate avd
This commit is contained in:
5 files changed
+58
-28
No files matched your search
+4
-2
@@ -41,7 +41,8 @@ ENV ANDROID_SDK_ROOT=/opt/android \
|
|||||||
ABI=${IMG_TYPE}/${ARCHITECTURE} \
|
ABI=${IMG_TYPE}/${ARCHITECTURE} \
|
||||||
GPU_ACCELERATED=$GPU_ACCELERATED \
|
GPU_ACCELERATED=$GPU_ACCELERATED \
|
||||||
QTWEBENGINE_DISABLE_SANDBOX=1 \
|
QTWEBENGINE_DISABLE_SANDBOX=1 \
|
||||||
ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL=10
|
ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL=10 \
|
||||||
|
ANDROID_AVD_HOME=/data
|
||||||
|
|
||||||
# Exporting environment variables to keep in the path
|
# Exporting environment variables to keep in the path
|
||||||
# Android SDK binaries and shared libraries.
|
# Android SDK binaries and shared libraries.
|
||||||
@@ -59,7 +60,8 @@ EXPOSE 5554 5555
|
|||||||
|
|
||||||
# Initializing the required directories.
|
# Initializing the required directories.
|
||||||
RUN mkdir /root/.android/ && \
|
RUN mkdir /root/.android/ && \
|
||||||
touch /root/.android/repositories.cfg
|
touch /root/.android/repositories.cfg && \
|
||||||
|
mkdir /data
|
||||||
|
|
||||||
# Exporting ADB keys.
|
# Exporting ADB keys.
|
||||||
#COPY keys/* /root/.android/
|
#COPY keys/* /root/.android/
|
||||||
|
|||||||
+4
-2
@@ -44,7 +44,8 @@ ENV ANDROID_SDK_ROOT=/opt/android \
|
|||||||
ABI=${IMG_TYPE}/${ARCHITECTURE} \
|
ABI=${IMG_TYPE}/${ARCHITECTURE} \
|
||||||
GPU_ACCELERATED=$GPU_ACCELERATED \
|
GPU_ACCELERATED=$GPU_ACCELERATED \
|
||||||
QTWEBENGINE_DISABLE_SANDBOX=1 \
|
QTWEBENGINE_DISABLE_SANDBOX=1 \
|
||||||
ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL=10
|
ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL=10 \
|
||||||
|
ANDROID_AVD_HOME=/data
|
||||||
|
|
||||||
# Exporting environment variables for keeping in the path
|
# Exporting environment variables for keeping in the path
|
||||||
# Android SDK binaries and shared libraries.
|
# Android SDK binaries and shared libraries.
|
||||||
@@ -62,7 +63,8 @@ EXPOSE 5554 5555
|
|||||||
|
|
||||||
# Initializing the required directories.
|
# Initializing the required directories.
|
||||||
RUN mkdir /root/.android/ && \
|
RUN mkdir /root/.android/ && \
|
||||||
touch /root/.android/repositories.cfg
|
touch /root/.android/repositories.cfg && \
|
||||||
|
mkdir /data
|
||||||
|
|
||||||
# Exporting ADB keys.
|
# Exporting ADB keys.
|
||||||
#COPY keys/* /root/.android/
|
#COPY keys/* /root/.android/
|
||||||
|
|||||||
@@ -76,7 +76,6 @@ You can generate one by running `adb keygen adbkey`, that generates 2 files - ad
|
|||||||
|
|
||||||
override them inside ./keys directory.
|
override them inside ./keys directory.
|
||||||
|
|
||||||
|
|
||||||
### Running the container
|
### Running the container
|
||||||
|
|
||||||
Once the image is built, you can mount your KVM driver on the container and expose its ADB port.
|
Once the image is built, you can mount your KVM driver on the container and expose its ADB port.
|
||||||
@@ -87,6 +86,14 @@ Once the image is built, you can mount your KVM driver on the container and expo
|
|||||||
docker run -it --rm --device /dev/kvm -p 5555:5555 android-emulator
|
docker run -it --rm --device /dev/kvm -p 5555:5555 android-emulator
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Save data/storage after restart (wipe)
|
||||||
|
|
||||||
|
All avd save in docker dir `/data`, name for avd is `android`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -it --rm --device /dev/kvm -p 5555:5555 -v ~/android_avd:/data android-emulator
|
||||||
|
```
|
||||||
|
|
||||||
### Connect ADB to the container
|
### Connect ADB to the container
|
||||||
|
|
||||||
The ADB server in the container will be spawned automatically and listen on all interfaces in the container. After a few seconds, once the kernel has booted, you will be able to connect ADB to the container.
|
The ADB server in the container will be spawned automatically and listen on all interfaces in the container. After a few seconds, once the kernel has booted, you will be able to connect ADB to the container.
|
||||||
@@ -142,15 +149,22 @@ docker build \
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Variables
|
### Variables
|
||||||
|
## Default variables
|
||||||
|
|
||||||
#### Disable animation
|
#### Disable animation
|
||||||
DISABLE_ANIMATION=false
|
DISABLE_ANIMATION=false
|
||||||
|
|
||||||
#### Disable hidden policy
|
#### Disable hidden policy
|
||||||
DISABLE_HIDDEN_POLICY=true
|
DISABLE_HIDDEN_POLICY=false
|
||||||
|
|
||||||
#### skip adb authentication
|
#### Skip adb authentication
|
||||||
SKIP_AUTH=false
|
SKIP_AUTH=true
|
||||||
|
|
||||||
|
#### Memory for emulator
|
||||||
|
MEMORY=8192
|
||||||
|
|
||||||
|
#### Cores for emulator
|
||||||
|
CORES=4
|
||||||
|
|
||||||
### Mount an external drive in the container
|
### Mount an external drive in the container
|
||||||
|
|
||||||
|
|||||||
+7
-1
@@ -15,12 +15,15 @@ services:
|
|||||||
- DISABLE_HIDDEN_POLICY=true
|
- DISABLE_HIDDEN_POLICY=true
|
||||||
- SKIP_AUTH=false
|
- SKIP_AUTH=false
|
||||||
#- ANDROID_ADB_SERVER_ADDRESS=host.docker.internal
|
#- ANDROID_ADB_SERVER_ADDRESS=host.docker.internal
|
||||||
|
- MEMORY=16384
|
||||||
|
- CORES=16
|
||||||
privileged: true
|
privileged: true
|
||||||
tty: true
|
tty: true
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
volumes:
|
volumes:
|
||||||
- ./keys/adbkey:/root/.android/adbkey:ro
|
- ./keys/adbkey:/root/.android/adbkey:ro
|
||||||
- ./keys/adbkey.pub:/root/.android/adbkey.pub:ro
|
- ./keys/adbkey.pub:/root/.android/adbkey.pub:ro
|
||||||
|
- ./android_avd:/data
|
||||||
extra_hosts:
|
extra_hosts:
|
||||||
- "host.docker.internal:host-gateway"
|
- "host.docker.internal:host-gateway"
|
||||||
|
|
||||||
@@ -40,6 +43,8 @@ services:
|
|||||||
- DISABLE_HIDDEN_POLICY=true
|
- DISABLE_HIDDEN_POLICY=true
|
||||||
- SKIP_AUTH=false
|
- SKIP_AUTH=false
|
||||||
#- ANDROID_ADB_SERVER_ADDRESS=host.docker.internal
|
#- ANDROID_ADB_SERVER_ADDRESS=host.docker.internal
|
||||||
|
- MEMORY=16384
|
||||||
|
- CORES=16
|
||||||
privileged: true
|
privileged: true
|
||||||
tty: true
|
tty: true
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
@@ -72,6 +77,8 @@ services:
|
|||||||
- DISABLE_HIDDEN_POLICY=true
|
- DISABLE_HIDDEN_POLICY=true
|
||||||
- SKIP_AUTH=false
|
- SKIP_AUTH=false
|
||||||
#- ANDROID_ADB_SERVER_ADDRESS=host.docker.internal
|
#- ANDROID_ADB_SERVER_ADDRESS=host.docker.internal
|
||||||
|
- MEMORY=16384
|
||||||
|
- CORES=16
|
||||||
privileged: true
|
privileged: true
|
||||||
tty: true
|
tty: true
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
@@ -89,4 +96,3 @@ services:
|
|||||||
- driver: nvidia
|
- driver: nvidia
|
||||||
count: 1
|
count: 1
|
||||||
capabilities: [gpu]
|
capabilities: [gpu]
|
||||||
|
|
||||||
+25
-19
@@ -8,9 +8,9 @@ source ./emulator-monitoring.sh
|
|||||||
EMULATOR_CONSOLE_PORT=5554
|
EMULATOR_CONSOLE_PORT=5554
|
||||||
# The ADB port used to connect to ADB.
|
# The ADB port used to connect to ADB.
|
||||||
ADB_PORT=5555
|
ADB_PORT=5555
|
||||||
MEMORY=16048
|
OPT_MEMORY=${MEMORY:-8192}
|
||||||
CORES=10
|
OPT_CORES=${CORES:-4}
|
||||||
SKIP_AUTH=true
|
OPT_SKIP_AUTH=${SKIP_AUTH:-true}
|
||||||
AUTH_FLAG=
|
AUTH_FLAG=
|
||||||
# Start ADB server by listening on all interfaces.
|
# Start ADB server by listening on all interfaces.
|
||||||
echo "Starting the ADB server ..."
|
echo "Starting the ADB server ..."
|
||||||
@@ -25,16 +25,21 @@ socat tcp-listen:"$ADB_PORT",bind="$LOCAL_IP",fork tcp:127.0.0.1:"$ADB_PORT" &
|
|||||||
export USER=root
|
export USER=root
|
||||||
|
|
||||||
# Creating the Android Virtual Emulator.
|
# Creating the Android Virtual Emulator.
|
||||||
echo "Creating the Android Virtual Emulator ..."
|
TEST_AVD="$(emulator -list-avds | grep android)"
|
||||||
echo "Using package '$PACKAGE_PATH', ABI '$ABI' and device '$DEVICE_ID' for creating the emulator"
|
if [ -z "$TEST_AVD" ]; then
|
||||||
echo no | avdmanager create avd \
|
echo "Use the exists Android Virtual Emulator ..."
|
||||||
--force \
|
else
|
||||||
--name android \
|
echo "Creating the Android Virtual Emulator ..."
|
||||||
--abi "$ABI" \
|
echo "Using package '$PACKAGE_PATH', ABI '$ABI' and device '$DEVICE_ID' for creating the emulator"
|
||||||
--package "$PACKAGE_PATH" \
|
echo no | avdmanager create avd \
|
||||||
--device "$DEVICE_ID"
|
--force \
|
||||||
|
--name android \
|
||||||
|
--abi "$ABI" \
|
||||||
|
--package "$PACKAGE_PATH" \
|
||||||
|
--device "$DEVICE_ID"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$SKIP_AUTH" == "true" ]; then
|
if [ "$OPT_SKIP_AUTH" == "true" ]; then
|
||||||
AUTH_FLAG="-skip-adb-auth"
|
AUTH_FLAG="-skip-adb-auth"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -55,17 +60,18 @@ fi
|
|||||||
wait_for_boot &
|
wait_for_boot &
|
||||||
|
|
||||||
# Start the emulator with no audio, no GUI, and no snapshots.
|
# Start the emulator with no audio, no GUI, and no snapshots.
|
||||||
echo "Starting the emulator ... "
|
echo "Starting the emulator ..."
|
||||||
echo "OPTIONS: "
|
echo "OPTIONS:"
|
||||||
echo "GPU - $GPU_MODE"
|
echo "ADB AUTH - $OPT_SKIP_AUTH"
|
||||||
echo "MEMORY - $MEMORY"
|
echo "GPU - $GPU_MODE"
|
||||||
echo "CORES - $CORES"
|
echo "MEMORY - $OPT_MEMORY"
|
||||||
|
echo "CORES - $OPT_CORES"
|
||||||
emulator \
|
emulator \
|
||||||
-avd android \
|
-avd android \
|
||||||
-gpu "$GPU_MODE" \
|
-gpu "$GPU_MODE" \
|
||||||
-memory $MEMORY \
|
-memory $OPT_MEMORY \
|
||||||
-no-boot-anim \
|
-no-boot-anim \
|
||||||
-cores $CORES \
|
-cores $OPT_CORES \
|
||||||
-ranchu \
|
-ranchu \
|
||||||
$AUTH_FLAG \
|
$AUTH_FLAG \
|
||||||
-no-window \
|
-no-window \
|
||||||
|
|||||||
Reference in new issue
Block a user