无法打开调试器端口:java.net.SocketException “Socket closed"

Unable to open debugger port : java.net.SocketException “Socket closed”(无法打开调试器端口:java.net.SocketException “Socket closed)
本文介绍了无法打开调试器端口:java.net.SocketException “Socket closed"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在使用 Android Studio,有多种使用 Gradle 的风格,每种风格都有一个 Debug 和 Release 类型,组织方式如 这里,在下半部分.当我尝试启动调试器时,我收到此错误:

I'm using Android Studio, with multiple flavors using Gradle, each with a Debug and Release type, organized as described here, on the bottom half.When I try to start the debugger, I get this error:

Error running androidRecover [installAppDebug]: Unable to open debugger port :     java.net.SocketException "Socket closed

一旦调试器运行,我也无法将它附加到我的设备上(它只显示我的手机名称,而不是应用程序).

I'm also unable to attach the debugger to my device once it's running (it only displays the name of my phone, not the app).

所有 3 种口味都可以安装在我的手机上.我只是无法让我调试它们.我还测试了将调试器附加到 Nexus 平板电脑上,得到了相同的结果.

All 3 flavors install on my phone just fine. I just can't get it to let me debug them. I also tested attaching the debugger on a Nexus tablet, and I got the same result.

它并不是一个整体的 Gradle,因为我可以运行其他基于 Gradle 的应用程序并很好地附加调试器,所以我想知道这是否与我如何设置我的 Gradle 项目和设置有关.

It's not Gradle specifically as a whole because I can run other Gradle-based apps and attach the debugger just fine so I wonder if it's something with how I've setup my Gradle project and settings.

这是我的 build.gradle:

Here's my build.gradle:

apply plugin: 'android'
apply from: 'signing.gradle'

android {
    compileSdkVersion 19
    buildToolsVersion '19.0.3'

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 19
    }

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

    productFlavors {
        flav1 {
            packageName "com.ex.flav1"
            versionCode 32
            versionName "1.0.5"
            signingConfig signingConfigs.flav1
        }

        flav2 {
            packageName "com.ex.flav2"
            versionCode 33
            versionName "1.0.6"
            signingConfig signingConfigs.flav2
        }

        flav3 {
            packageName "com.ex.flav3"
            versionCode 27
            versionName "1.0.0"
            signingConfig signingConfigs.flav3
        }
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:19.+'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile files('libs/httpmime-4.2.5.jar')
}

我真的不知道还能尝试什么.Android Studio 是完全最新的.我已经重启了 Android Studio、我的手机和我的电脑.

I really have no idea what else to try. Android Studio is completely up-to-date. I've restarted Android Studio, my phone, and my computer.

另外,上周我遇到了这个问题,但它是一个特定的套接字被阻止,无法同时运行模拟器和我的手机.我还注意到我有多个 Gradle 进程正在运行,因为它不会自行杀死它们,我经常不得不杀死 Android Studio 来杀死它们.一旦解决了这个问题,它就会断断续续地工作.

Also, last week I was having this problem, but it was a specific socket that was blocked, from trying to run the emulator and my phone at the same time. I also noticed I had multiple Gradle processes running, because it wasn't killing them on its own, which I often had to kill Android Studio to kill them. Once that was fixed, it was working off and on.

如果您需要任何其他信息,请告诉我.

Let me know if you need any other info.

谢谢,德文

编辑我终于知道为什么@hasanaydogar 的答案有效,以及为什么如果我们当时知道它可能会解决我的问题.请参阅我的第二条评论以了解原因,但简而言之,您必须在该下拉列表中选择与您的应用程序根目录匹配的名称.

Edit I finally know why @hasanaydogar's answer works and why it probably would have solved my problem if we had known it then. See my 2nd comment on it to know why, but in short, you have to select in that dropdown the name that matches your app's root directory.

推荐答案

只需点击按钮(运行按钮左侧).

Just Click the button (left side the RUN button).

选择安卓.然后运行.

它将连接到您的设备.

别忘了更改构建变体

这篇关于无法打开调试器端口:java.net.SocketException “Socket closed"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Android release APK crash with java.lang.AssertionError: impossible in java.lang.Enum(Android 发布 APK 因 java.lang.AssertionError 崩溃:在 java.lang.Enum 中不可能)
Finished with Non Zero Exit Value 3(以非零退出值 3 结束)
On gradle:3.0.0 More than one file was found with OS independent path #39;META-INF/ASL2.0#39;(在 gradle:3.0.0 上找到多个文件,其独立于操作系统的路径为“META-INF/ASL2.0)
Android : app loading library at runtime on Lollipop but not IceCreamSandwich(Android:运行时在 Lollipop 上而不是 IceCreamSandwich 上的应用程序加载库)
buildConfigField depending on flavor + buildType(buildConfigField 取决于风味 + buildType)
How do I suppress warnings when compiling an android library with gradle?(使用 gradle 编译 android 库时如何抑制警告?)