android-emulator-runner: could not connect to TCP port 5554: Connection refused

Hello

I have an error when I try to start an emulator. My workflow is

name: Generate screenshots

on: [pull_request]

jobs:
  screenshots:
    name: Generate screenshots
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v2

     - name: Set up JDK 11
        uses: actions/setup-java@v2
        with:
          distribution: 'adopt'
          java-version: '11'
      - name: Cache Gradle packages
        uses: actions/cache@v2.1.6
        with:
          path: |
            ~/.gradle/caches
            .gradle
          key: ${{ runner.os }}-gradle-quality-${{ hashFiles('**/*.gradle.kts') }}
          restore-keys: |
            ${{ runner.os }}-gradle-quality-
      - name: Cache Gradle wrapper
        uses: actions/cache@v2.1.6
        with:
          path: ~/.gradle/wrapper
          key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradlew') }}
          restore-keys: |
            ${{ runner.os }}-gradle-wrapper-
      - uses: actions/setup-ruby@v1
        with:
          ruby-version: '2.6'
          bundler-cache: true
      - name: create AVD
        uses: reactivecircus/android-emulator-runner@v2
        with:
          api-level: 28
          target: default
          arch: x86
          profile: Nexus 6
          emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
          disable-animations: true
          script: echo "Generated AVD."

and the error

/Users/runner/android-sdk/platform-tools/adb -s emulator-5554 emu kill
error: could not connect to TCP port 5554: Connection refused
The process '/Users/runner/android-sdk/platform-tools/adb' failed with exit code 1
Error: The process '/bin/sh' failed with exit code 1

Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 6
  • Comments: 34 (8 by maintainers)

Commits related to this issue

Most upvoted comments

I have just met this issue and noticed that it was happening due to the hanging ADB server. Mine has been solved by running the following commands:

adb kill-server

adb start-server

It doesn’t work with API 30 though, we have the same error with API 30

I separately ran into this error using expo & Android:

could not connect to TCP port 5554: Connection refused

I fixed it by finding and stopping the process using port 5555 (I had a docker compose container using it). Unhelpful error message from the Android team.

I have just met this issue and noticed that it was happening due to the hanging ADB server. Mine has been solved by running the following commands:

adb kill-server

adb start-server

it’s work perfectly

@ychescale9 emulator-build: 7425822 works for me! Thanks for the quick fix.

It works with emulator-build: 7425822 , I don’t have any error 🎉 Thank you so much. I tried with a simple echo for now though, I’ll try tomorrow with a script that actually need a device

@ychescale9 I’m also seeing this in Coil if you want to use that repo to debug.

emulator-build: 6110076

I have the same error than before

API level: 28
target: default
CPU architecture: x86
Hardware profile: 
Cores: 2
SD card path or size: 
AVD name: test
force avd creation: true
emulator options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim
disable animations: true
disable spellchecker: false
disable Linux hardware acceleration: true
using emulator build: 6110076
Script:
echo "Generated AVD."
Installing latest build tools, platform tools, and platform.
/bin/sh -c \sdkmanager --install 'build-tools;30.0.3' platform-tools 'platforms;android-28' > /dev/null
Warning: Observed package id 'ndk;21.4.7075529' in inconsistent location '/Users/runner/Library/Android/sdk/ndk-bundle' (Expected '/Users/runner/Library/Android/sdk/ndk/21.4.7075529')
Warning: Observed package id 'ndk;21.4.7075529' in inconsistent location '/Users/runner/Library/Android/sdk/ndk-bundle' (Expected '/Users/runner/Library/Android/sdk/ndk/21.4.7075529')
Installing emulator build 6110076.
/usr/local/opt/curl/bin/curl -fo emulator.zip https://dl.google.com/android/repository/emulator-darwin-6110076.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:02 --:--:--     0
  3  316M    3 10.0M    0     0  4018k      0  0:01:20  0:00:02  0:01:18 5087k
 12  316M   12 40.0M    0     0  11.0M      0  0:00:28  0:00:03  0:00:25 12.9M
 32  316M   32  103M    0     0  22.9M      0  0:00:13  0:00:04  0:00:09 26.0M
 67  316M   67  212M    0     0  38.3M      0  0:00:08  0:00:05  0:00:03 42.4M
100  316M  100  316M    0     0  49.1M      0  0:00:06  0:00:06 --:--:-- 75.6M
/usr/bin/unzip -q emulator.zip -d /Users/runner/Library/Android/sdk
Installing system images.
/bin/sh -c \sdkmanager --install 'system-images;android-28;default;x86' > /dev/null
Warning: Observed package id 'ndk;21.4.7075529' in inconsistent location '/Users/runner/Library/Android/sdk/ndk-bundle' (Expected '/Users/runner/Library/Android/sdk/ndk/21.4.7075529')
Warning: Observed package id 'ndk;21.4.7075529' in inconsistent location '/Users/runner/Library/Android/sdk/ndk-bundle' (Expected '/Users/runner/Library/Android/sdk/ndk/21.4.7075529')
Creating AVD.
/bin/sh -c \echo no | avdmanager create avd --force -n test --abi 'default/x86' --package 'system-images;android-28;default;x86'
Loading local repository...                                                     
Warning: Observed package id 'ndk;21.4.7075529' in inconsistent location '/Users/runner/Library/Android/sdk/ndk-bundle' (Expected '/Users/runner/Library/Android/sdk/ndk/21.4.7075529')
[=========                              ] 25% Loading local repository...       
[=========                              ] 25% Fetch remote repository...        
[=======================================] 100% Fetch remote repository...       
Do you wish to create a custom hardware profile? [no] Error: "emulator" package must be installed!
null
/Users/runner/Library/Android/sdk/platform-tools/adb -s emulator-5554 emu kill
error: could not connect to TCP port 5554: Connection refused
The process '/Users/runner/Library/Android/sdk/platform-tools/adb' failed with exit code 1
Error: The process '/bin/sh' failed with exit code 1

with

 - name: create AVD
  uses: reactivecircus/android-emulator-runner@v2
  with:
    api-level: 28
    emulator-build: 6110076
    script: echo "Generated AVD."