codemagic-docs icon indicating copy to clipboard operation
codemagic-docs copied to clipboard

add an example of creating a custom android emulator

Open dtrdic opened this issue 4 months ago • 0 comments

Some users are not aware that they can create a and launch a custom Android emulator for running e2e tests

https://github.com/orgs/codemagic-ci-cd/discussions/2773

- name: Setup and Launch Android 14 Emulator
  script: |
    # Set Android SDK paths
    export ANDROID_SDK_ROOT=/usr/local/share/android-sdk
    export PATH="$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/emulator:$ANDROID_SDK_ROOT/platform-tools:$PATH"

    # Install necessary SDK components and Android 14 system image 
    echo y | sdkmanager --install "cmdline-tools;latest" "emulator" "platform-tools" "system-images;android-34;google_apis;x86_64" 

   # Create the AVD (emulator) if not already created 
   echo no | avdmanager create avd -n Android14 -k "system-images;android-34;google_apis;x86_64" --force 

   # Launch the emulator 
   emulator -avd Android14 -no-window -no-snapshot -no-audio -gpu swiftshader_indirect & 

  adb wait-for-device 

dtrdic avatar Oct 17 '24 13:10 dtrdic