remarkablemark / react-native-android-detox

📱 React Native Android Detox
3 stars 3 forks source link

Would you know why emulator shows error: Not enough space to create userdata partition #76

Open poponuts opened 2 weeks ago

poponuts commented 2 weeks ago

Question

I was following your CI steps with the following snippet:

      - name: Get Device Name
        id: device
        run: |
          AVD_NAME=$(node -p "require('./.detoxrc').devices.emulator.device.avdName")
          echo "AVD_NAME=$AVD_NAME" >> $GITHUB_OUTPUT

      - name: Detox Test
        timeout-minutes: 20
        uses: reactivecircus/android-emulator-runner@v2
        with:
          api-level: ${{ env.API_LEVEL }}
          arch: ${{ env.ARCH }}
          avd-name: ${{ steps.device.outputs.AVD_NAME }}
          disable-animations: false
          emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
          force-avd-creation: false
          script: >
            yarn detox test
            --configuration ${{ env.DETOX_CONFIGURATION }}
            --headless
            --record-logs failing
            --record-videos failing
            --take-screenshots failing

I get the following error: ERROR | Not enough space to create userdata partition. Available: 4870.562500 MB at /home/runner/.android/avd/../avd/Pixel_8_Pro_API_34.avd, need 7372.800000 MB. which I think in turn does this: adb: device 'emulator-5554' not found

Additional info:

API_LEVEL: 26
ARCH: x86_64
remarkablemark commented 2 weeks ago

@poponuts do you know if your machine on GitHub Actions has enough space?

poponuts commented 2 weeks ago

I did this on my previous step to free disk space:

  sudo rm -rf /opt/hostedtoolcache
  sudo rm -rf /usr/share/dotnet
  sudo rm -rf /opt/ghc
  sudo rm -rf "/usr/local/share/boost"
  sudo rm -rf "$AGENT_TOOLSDIRECTORY"

Also, this works fine so unsure why running with same specs for detox test fails:

      - name: Create AVD and generate snapshot for caching
        if: steps.avd-cache.outputs.cache-hit != 'true'
        uses: reactivecircus/android-emulator-runner@v2
        with:
          api-level: ${{ env.API_LEVEL }}
          arch: ${{ env.ARCH }}
          disable-animations: false
          emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
          force-avd-creation: false
          script: echo 'Generated AVD snapshot for caching.'
remarkablemark commented 2 weeks ago

What machine are you using to run the action? ubuntu-latest?

poponuts commented 2 weeks ago

Yes, ubuntu-latest. See below:

name: Mobile android e2e tests

env:
  CI: true
  DETOX_CONFIGURATION: android.emu.release
  API_LEVEL: 26
  ARCH: x86_64

on:
  pull_request:
    branches:
      - master

jobs:
  e2e-test:
    name: Run Tests
    runs-on: ubuntu-latest
    timeout-minutes: 60
    steps:
      - uses: actions/checkout@v4

      - name: Free Disk Space
        run: |
          sudo rm -rf /opt/hostedtoolcache
          sudo rm -rf /usr/share/dotnet
          sudo rm -rf /opt/ghc
          sudo rm -rf "/usr/local/share/boost"
          sudo rm -rf "$AGENT_TOOLSDIRECTORY"

      - name: Enable KVM
        run: |
          echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
          sudo udevadm control --reload-rules
          sudo udevadm trigger --name-match=kvm

      - uses: actions/setup-node@v4
        # id: cache-node-modules
        with:
          node-version: '20.x'
          cache: 'yarn'

      - name: Install Dependencies
        run: yarn # install --frozen-lockfile

      - name: Setup Java
        uses: actions/setup-java@v4
        with:
          cache: gradle
          distribution: temurin
          java-version: 17

      - name: Gradle cache
        uses: gradle/actions/setup-gradle@v3

      - name: AVD cache
        uses: actions/cache@v4
        id: avd-cache
        with:
          path: |
            ~/.android/avd/*
            ~/.android/adb*
          key: avd-${{ env.API_LEVEL }}

      - name: Create AVD and generate snapshot for caching
        if: steps.avd-cache.outputs.cache-hit != 'true'
        uses: reactivecircus/android-emulator-runner@v2
        with:
          api-level: ${{ env.API_LEVEL }}
          arch: ${{ env.ARCH }}
          disable-animations: false
          emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
          force-avd-creation: false
          script: echo 'Generated AVD snapshot for caching.'

      - name: Cache Detox Build
        id: cache-detox-build
        uses: actions/cache@v4
        with:
          path: android/app/build
          key: ${{ runner.os }}-detox-build
          restore-keys: |
            ${{ runner.os }}-detox-build

      - name: Detox Build
        if: steps.cache-detox-build.outputs.cache-hit != 'true'
        run: yarn e2e:android:build --if-missing

      - name: Get Device Name
        id: device
        run: |
          AVD_NAME=$(node -p "require('./.detoxrc').devices.emulator.device.avdName")
          echo "AVD_NAME=$AVD_NAME" >> $GITHUB_OUTPUT

      - name: Detox Test
        timeout-minutes: 20
        uses: reactivecircus/android-emulator-runner@v2
        with:
          api-level: ${{ env.API_LEVEL }}
          arch: ${{ env.ARCH }}
          avd-name: ${{ steps.device.outputs.AVD_NAME }}
          disable-animations: false
          emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
          force-avd-creation: false
          script: >
            yarn detox test
            --configuration ${{ env.DETOX_CONFIGURATION }}
            --headless
            --record-logs failing
            --record-videos failing
            --take-screenshots failing

      - name: Upload Artifacts
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: detox-artifacts
          path: artifacts
remarkablemark commented 2 weeks ago

Try commenting out the step Create AVD and generate snapshot for caching. See https://github.com/ReactiveCircus/android-emulator-runner/issues/390#issuecomment-2081914911

poponuts commented 2 weeks ago

Same issue after commenting out that step. It says that: I remedied this by deleting my temporary SDK build directory after a new SDK is built, freeing up GBs of space and this emulator action then works fine again.

Would you know how do I do this?

remarkablemark commented 2 weeks ago

Go to Actions > Caches and click the trash icon:

Screenshot 2024-09-01 at 11 51 43 PM

poponuts commented 2 weeks ago

I have 0 caches so it seems even the Detox cache is not working for me in any case 😢 Screenshot 2024-09-02 at 2 51 48 PM

remarkablemark commented 2 weeks ago

Maybe try using a larger runner?