Open lsaadeh opened 4 years ago
You can use Android Debug Bridge CLI to push your apk inside your device, and install it from your local machine
adb -P 5037 [ -s %UDID_IF_MULTIPLE_DEVICE% ] push /path/to/local.apk /data/local/tmp/downloaded.apk
adb -P 5037 [ -s %UDID_IF_MULTIPLE_DEVICE% ] shell pm install -r /data/local/tmp/downloaded.apk
@arthuRHD - imagine I have CICD pipeline:
Can I pack emulater with this apk, install and start it on docker-andorid redeploy on kubernetes cluster?
I am new to android emulators, so thx for patience. 👍
refer to https://github.com/budtmo/docker-android/issues/180
install in this way? adb connect 34.68.174.199:5555 adb -e install /SuperSU_v2.79.apk
refer to #180
install in this way? adb connect 34.68.174.199:5555 adb -e install /SuperSU_v2.79.apk
I installed an apk using this command inside the container.
androidusr@15be855c644c:~$ adb -e install /tmp/test.apk
Performing Streamed Install
Success
But I cannot find it on the emulator UI.
@gainskills tell me please, how you are connecting adb to android container?! 🥺 🙏
For people coming here looking for answer on how to install an apk. @Banzaika
I used a docker-compose example made by: bernatvadell (credit where credit is due) https://github.com/budtmo/docker-android/issues/395
I added an extra container that does the apk installation. A script will run and poll the device if it's started, if it's started it will try to install the apk into the android-container. This way the container directly has the apk you want.
docker-compose
services:
android-container:
build:
context: .
container_name: android-container
privileged: true
environment:
- EMULATOR_DEVICE=Samsung Galaxy S10
- WEB_VNC=true
- WEB_LOG=true
- WEB_LOG_PORT=9000
- ENV_LOG_PATH=/var/log/
volumes:
- data:/home/androidusr
- root:/root
ports:
- "6080:6080"
- "9005:9000"
devices:
- "/dev/kvm:/dev/kvm"
restart: always
apk-installer:
build:
context: .
dockerfile: Dockerfile_apk
container_name: apk-installer
depends_on:
- android-container
environment:
- ANDROID_CONTAINER_NAME=android-container
- APK_PATH=/apk/test_apk.apk
entrypoint: ["/bin/bash", "-c", "/install-apk.sh"]
restart: "no"
volumes:
data:
root:
Dockerfile
FROM budtmo/docker-android:emulator_11.0
USER root
RUN echo 'root:x:0:0:root:/root:/bin/bash' >> /etc/passwd
USER androidusr
COPY run.sh /run.sh
ENTRYPOINT ["/bin/bash", "-c"]
CMD ["/run.sh"]
Dockerfile_apk
RUN apt-get update && apt-get install -y adb netcat
COPY install-apk.sh /install-apk.sh
COPY test_apk.apk /apk/test_apk.apk
RUN chmod +x /install-apk.sh
install-apk.sh
#!/bin/bash
# Wait for the Android container to be ready
while ! nc -z ${ANDROID_CONTAINER_NAME} 5555; do
echo "Waiting for Android container to be ready..."
sleep 5 # 5 seconds
done
echo "Android container is ready."
# Connect to the Android emulator
adb connect ${ANDROID_CONTAINER_NAME}:5555
# Wait for the device to be online
DEVICE_ONLINE="offline"
while [ "$DEVICE_ONLINE" == "offline" ]; do
DEVICE_ONLINE=$(adb -s ${ANDROID_CONTAINER_NAME}:5555 get-state 2>/dev/null)
if [ "$DEVICE_ONLINE" == "offline" ]; then
echo "Waiting for device to be online..."
sleep 5
fi
done
echo "Device is online."
# Wait for the device to be fully booted
BOOT_COMPLETED="0"
while [ "$BOOT_COMPLETED" != "1" ]; do
BOOT_COMPLETED=$(adb -s ${ANDROID_CONTAINER_NAME}:5555 shell getprop sys.boot_completed 2>/dev/null)
if [ "$BOOT_COMPLETED" != "1" ]; then
echo "Waiting for device to boot..."
sleep 30 # 30 seconds
fi
done
echo "Device booted successfully."
# Install the APK
adb -s ${ANDROID_CONTAINER_NAME}:5555 install ${APK_PATH}
echo "APK installation complete"
run.sh
#!/bin/bash
rm -rf /home/androidusr/emulator/*.lock
/home/androidusr/docker-android/mixins/scripts/run.sh
Result
I ran the emulator and uploaded an APK on it and then i am trying to open the APK but it keeps stopping anyone has a solution?
💬 Questions and Help
Please make sure that it is an issue / a feature request. If it is a question / help wanted, please visit our group chat. Thank you!
How to install app via .apk file