无法打开调试器端口:java.net.SocketException“Socket closed” [英] Unable to open debugger port : java.net.SocketException “Socket closed”

查看:2362
本文介绍了无法打开调试器端口: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 p项目和设置。

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.

谢谢,
Devin

Thanks, Devin

修改我终于知道为什么@ 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.

推荐答案

只需点击按钮(左侧的RUN按钮)。

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

选择Android。然后运行。

Select Android. Then Run.

它将连接到您的设备。

不要忘记更改构建变体

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

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆