模拟器:模拟器:错误:AdbHostServer.cpp:102:无法连接到端口为5037的adb守护程序。

13
我花了整个下午的时间来尝试在Android Studio中重新运行我的小型Android/Kotlin应用程序,但却无法成功。这篇问题主题中贴出的信息突然击垮了我。
我尝试了以下几个方法:
1 - 冷启动 (在虚拟设备屏幕上 > 操作 > 立即冷启动)
2 - 我删除了以前的虚拟设备,并下载了一个新设备(Nexus One)
3 - 我遵循了其他stackoverflow答案中的所有步骤
3.1
cd C:\Users\Jimis\AppData\Local\Android\Sdk\platform-tool

adb kill-server
adb.exe start-server
adb devices -l 

3.2

SDK Platform 下载并重新安装平台工具。

3.3

重新启动电脑。

我完全卡住了。

有些事情引起了我的注意:为什么端口5037会有这么多个PID。请看下面,当我开始使用Android Studio时,只有3个,但在尝试调试应用程序之后,出现了更多的PID。

Microsoft Windows [versão 10.0.18363.836]
(c) 2019 Microsoft Corporation. Todos os direitos reservados.

C:\Users\Jimis>netstat -ano -p tcp |find "5037"
  TCP    127.0.0.1:5037         0.0.0.0:0              LISTENING       11492
  TCP    127.0.0.1:5037         127.0.0.1:50582        ESTABLISHED     11492
  TCP    127.0.0.1:50582        127.0.0.1:5037         ESTABLISHED     10052

C:\Users\Jimis>netstat -ano -p tcp |find "5037"
  TCP    127.0.0.1:5037         0.0.0.0:0              LISTENING       11492
  TCP    127.0.0.1:5037         127.0.0.1:50582        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50714        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50731        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50734        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50736        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50737        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:50738        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50739        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50740        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50741        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50742        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50743        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50744        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50745        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50746        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50747        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50748        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50749        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50750        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50751        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50752        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50753        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50754        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50755        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50756        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50757        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50758        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50759        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:50760        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50761        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50762        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50763        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50764        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50765        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50766        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50767        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50768        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50769        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:50770        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50771        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50772        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50773        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50779        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:50780        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:50781        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:50782        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:50783        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:50784        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:50785        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:50786        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:50787        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:50788        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:50789        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:50790        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:50791        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50792        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:50793        ESTABLISHED     11492
  TCP    127.0.0.1:5037         127.0.0.1:50794        ESTABLISHED     11492
  TCP    127.0.0.1:50582        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50714        127.0.0.1:5037         ESTABLISHED     792
  TCP    127.0.0.1:50717        127.0.0.1:5037         TIME_WAIT       0
  TCP    127.0.0.1:50719        127.0.0.1:5037         TIME_WAIT       0
  TCP    127.0.0.1:50722        127.0.0.1:5037         TIME_WAIT       0
  TCP    127.0.0.1:50729        127.0.0.1:5037         TIME_WAIT       0
  TCP    127.0.0.1:50731        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50734        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50736        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50738        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50739        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50740        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50741        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50742        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50743        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50744        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50745        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50746        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50747        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50748        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50749        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50750        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50751        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50752        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50753        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50754        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50755        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50756        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50757        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50758        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50760        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50761        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50762        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50763        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50764        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50765        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50766        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50767        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50768        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50770        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50771        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50772        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50773        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50791        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50793        127.0.0.1:5037         ESTABLISHED     10052
  TCP    127.0.0.1:50794        127.0.0.1:5037         ESTABLISHED     10052

C:\Users\Jimis>

试图通过"netstat -a -b"命令找出为什么有这么多连接到5037端口的已建立连接,我找到了这个列表,但我不确定在使用Android Studio和模拟器时是否正常

...
     TCP    127.0.0.1:5037         SPANOT149:0            LISTENING
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50582        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50714        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50731        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50734        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50736        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50738        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50739        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50740        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50741        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50742        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50744        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50745        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50746        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50747        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50748        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50750        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50751        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50753        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50756        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50757        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50760        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50761        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50762        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50763        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50764        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50765        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50766        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50767        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50768        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50770        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50772        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50773        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50793        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50797        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:50955        ESTABLISHED
     [adb.exe]
      TCP    127.0.0.1:5037         orionhost:51276        ESTABLISHED
     [adb.exe]

我的应用程序build.gradle

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"

    android {
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
    }

    defaultConfig {
        applicationId "com.mycomp.appfirestore"
        minSdkVersion 16
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.72"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

    // Firebase Libraries
    implementation 'com.google.firebase:firebase-core:17.4.2'
    implementation 'com.google.firebase:firebase-auth:19.3.1'
    implementation 'com.google.firebase:firebase-database:19.3.0'
    implementation 'com.google.firebase:firebase-storage:19.1.1'

    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:4.7.2'
}
项目 build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.3.71'
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

如果相关的话,我刚刚更新到了Android Studio 4.0,并且出现了相同的问题。

Android Studio 4.0
Build #AI-193.6911.18.40.6514223, built on May 20, 2020
Runtime version: 1.8.0_242-release-1644-b01 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 1237M
Cores: 8
Registry: ide.new.welcome.screen.force=true
Non-Bundled Plugins: 

在 StackOverflow 上阅读了很多文章后,我遇到了其他问题

我尝试在 C:\Users\....android 中添加 advancedFeatures.ini 文件,但是没有成功。

Vulkan = off
GLDirectMem = on

我不知道我具体做了什么,但我还是尝试了一下,问题仍然存在。在同一个stackoverflow讨论中,我注意到有人谈到了hyper-V。

如果相关的话,我之前在我的Windows 10上关闭了Hyper-V,因为我必须使用VirtualBox进行其他原因(OpenShift/minishift)。我不认为它与我的问题有关,因为直到两天前我没有遇到过5037端口问题。顺便说一下,我很好奇:Android模拟器是否与Hyper-V有任何关系?

***在Jacob的评论后编辑

Microsoft Windows [version 10.0.18363.836] (c) 2019 Microsoft Corporation. All rights reserved.

1)在启动Android Studio之前,我如预期一样无法连接到5037端口

C:\Users>netstat -ano | findstr "5037"

2)然后我启动Android Studio,我看到至少有三个连接到5037端口。

C:\Users\Cast>netstat -ano | findstr "5037"
  TCP    127.0.0.1:5037         0.0.0.0:0              LISTENING       11880
  TCP    127.0.0.1:5037         127.0.0.1:54602        ESTABLISHED     11880
  TCP    127.0.0.1:54602        127.0.0.1:5037         ESTABLISHED     348

3) 当我点击Debug应用程序(shift + F9)时,Android Studio左下角会显示两个错误信息。

Emulator: emulator: ERROR: AdbHostServer.cpp:102: Unable to connect to adb daemon on port: 5037

Emulator: socketTcpLoopbackClientFor: error: fd 56668 above FD_SETSIZE (32768)

同时有许多与大量TIME WAIT相关的连接。这对我来说看起来很奇怪。

C:\Users>netstat -ano | findstr "5037"
  TCP    127.0.0.1:5037         0.0.0.0:0              LISTENING       11880
  TCP    127.0.0.1:5037         127.0.0.1:54602        ESTABLISHED     11880
  TCP    127.0.0.1:5037         127.0.0.1:54631        ESTABLISHED     11880
  TCP    127.0.0.1:5037         127.0.0.1:54643        ESTABLISHED     11880
  TCP    127.0.0.1:5037         127.0.0.1:54647        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:54648        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:54649        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:54650        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:54662        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:54663        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:54665        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:54666        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:54667        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:54668        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:54669        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:54670        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:54671        ESTABLISHED     11880
  TCP    127.0.0.1:5037         127.0.0.1:54672        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:54673        ESTABLISHED     11880
  TCP    127.0.0.1:5037         127.0.0.1:54674        TIME_WAIT       0
  TCP    127.0.0.1:54602        127.0.0.1:5037         ESTABLISHED     348
  TCP    127.0.0.1:54631        127.0.0.1:5037         ESTABLISHED     5224
  TCP    127.0.0.1:54634        127.0.0.1:5037         TIME_WAIT       0
  TCP    127.0.0.1:54636        127.0.0.1:5037         TIME_WAIT       0
  TCP    127.0.0.1:54639        127.0.0.1:5037         TIME_WAIT       0
  TCP    127.0.0.1:54641        127.0.0.1:5037         TIME_WAIT       0
  TCP    127.0.0.1:54643        127.0.0.1:5037         ESTABLISHED     348
  TCP    127.0.0.1:54671        127.0.0.1:5037         ESTABLISHED     348
  TCP    127.0.0.1:54673        127.0.0.1:5037         ESTABLISHED     348

C:\Users>

完整事件日志

01/06/2020
00:08   Gradle sync started
00:08   * daemon not running; starting now at tcp:5037
00:08   * daemon started successfully
00:08   Gradle sync finished in 2 s 418 ms (from cached state)
00:08   Executing tasks: [:app:assembleDebug] in project C:\WSs\FireStoreDemos\AppFirestore
00:08   Emulator: socketTcpLoopbackClientFor: error: fd 56296 above FD_SETSIZE (32768)
00:08   Emulator: socketTcpLoopbackClientFor: error: fd 56296 above FD_SETSIZE (32768)
00:08   Emulator: emulator: ERROR: AdbHostServer.cpp:102: Unable to connect to adb daemon on port: 5037
00:08   Emulator: socketTcpLoopbackClientFor: error: fd 56668 above FD_SETSIZE (32768)
00:08   Emulator: socketTcpLoopbackClientFor: error: fd 56668 above FD_SETSIZE (32768)
00:08   Emulator: socketTcpLoopbackClientFor: error: fd 56928 above FD_SETSIZE (32768)
00:08   Emulator: socketTcpLoopbackClientFor: error: fd 56928 above FD_SETSIZE (32768)
00:08   Gradle build finished in 19 s 659 ms
00:08   Install successfully finished in 584 ms.: App restart successful without requiring a re-install.

更改了ADB端口后进行编辑

我在Windows环境下将ANDROID_ADB_SERVER_PORT更改为5038,并重新启动Android Studio,但我仍然看到一些5037等待连接。

在Windows中更改环境变量ANDROID_ADB_SERVER_PORT之后

C:\Users\>netstat -ano | findstr "5037"
  TCP    127.0.0.1:5037         127.0.0.1:54643        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:54671        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:54673        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:55204        TIME_WAIT       0
  TCP    127.0.0.1:54602        127.0.0.1:5037         TIME_WAIT       0
  TCP    127.0.0.1:54631        127.0.0.1:5037         TIME_WAIT       0

C:\Users\>netstat -ano | findstr "5038"
  TCP    127.0.0.1:5038         0.0.0.0:0              LISTENING       7912
  TCP    127.0.0.1:5038         127.0.0.1:55238        ESTABLISHED     7912
  TCP    127.0.0.1:55238        127.0.0.1:5038         ESTABLISHED     11368

1
这个回答解决了你的问题吗?adb.exe出现问题 - Bilal Abdeen
1
我必须首先运行adb服务器。如此建议:https://superuser.com/a/1530617/56505。 - Ujjwal Singh
6个回答

15

这可能是由于权限不足引起的。请以管理员身份运行Android Studio或您喜欢的命令提示符,这样应该就可以解决您的问题。


谢谢你的回答,但在我来这里之前,我已经尝试以管理员身份运行Android Studio,但仍然没有改变。你知道为什么会有那么多连接与5037端口建立吗?我猜这与管理员权限无关。 - Jim C
1
我不确切地知道为什么会有这么多连接到 adb 端口,但这只是守护进程的运行方式。当我的模拟器正常运行时,我也会得到很多连接。至于如何更改 adb 端口,如果没有设置 ANDROID_ADB_SERVER_PORT 环境变量,5037 是默认端口。将该环境变量设置为您选择的端口,它就会尝试使用那个端口。 - Jacob
降级Android到9和API到28,我终于可以看到屏幕再次工作了。我认为我没有解决我的原始问题,因为我仍然收到相同的错误消息(请参见我问题中添加的新详细信息),而且我更喜欢使用Android 10。我认为这很矛盾,每当我启动Android Studio时,我会看到“daemon not running; starting now at tcp:5037”,然后我再次启动调试时会再次看到“Emulator: emulator: ERROR: AdbHostServer.cpp:102: Unable to connect to adb daemon on port: 5037”。 - Jim C
你知道是否有可能禁用Android Studio连接到模拟器端口,只有在我按下“运行”或“调试”时才连接吗?你同意我的看法,如果我还没有运行模拟器,那么Android Studio启动守护进程是没有意义的吗?或者从另一个角度来看,如果已经启动了,为什么不使用相同的连接,而是在达到“调试”时再次尝试连接adb守护进程?我并不是在抱怨。我只是猜测有一些错误的设置导致尝试连接到模拟器端口比实际需要更多。也许我需要在启动Studio时禁用连接。 - Jim C
1
很遗憾,我对adb的了解不够深入,只能提供上次评论中提到的知识。除此之外,我无法提供更多帮助并解释您所看到的结果。 - Jacob
显示剩余2条评论

9
1. emulator -list-avds
2. adb start-server 
3. emulator -avd <avd_name>

如果你看到以下错误信息:

PANIC: 缺少 'x86' CPU 的模拟器引擎程序。

那么你可以尝试以下方法:

1. emulator -list-avds
2. adb start-server
3. $ANDROID_HOME/emulator/emulator @name_device

针对冷启动,使用标志-no-snapshot-no-snapshot-load


4

尝试通过进入您的platform-tools目录并运行adb start-server来启动adb守护程序,然后再次模拟您的虚拟设备,您可能会成功。


3

我遇到了和你一样的错误。我通过更新Android Studio中的所有内容,包括SDK来解决了这个问题。之后,我清除了模拟器上的数据并运行程序。它正常工作。希望你也能修复你的问题。


0
请确保环境变量中定义的 PATH 是正确的。 打开命令提示符 键入 ECHO %PATH% 并按 Enter 键 检查屏幕上显示的路径
如果 PATH 不正确,请在“开始 - env - 环境变量 - 路径”中进行更正。

你是指 platform-tools 的路径吗? - user3698694

-1

问题有时会发生,因为您在Windows中有虚拟机,并且Windows 10禁用Windows功能的方式不同。

因此,如果您使用Windows 10 Pro,则必须确保关闭hyper V和虚拟机平台。

然后重新启动计算机即可解决错误。

还请不要忘记运行

  1. adb start-server
  2. emulator -adb "andname"

并确保设置以下环境:

  1. ANDROID_AVB_HOME = C:\Users\fernando.android\avd

然后在路径中添加模拟器目录

  1. C:\Users"username"\AppData\Local\Android\Sdk\emulator
  2. C:\Users"username"\AppData\Local\Android\Sdk\emulator\bin64
  3. C:\Users"username"\AppData\Local\Android\Sdk\platform-tools
  4. C:\Users\fernando\AppData\Local\Android\Sdk\tools
  5. C:\Users\fernando\AppData\Local\Android\Sdk\tools\bin

确保一切都是正确的。

加油!希望这能帮到你们。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接