无法打开调试器端口:java.net.SocketException“套接字已关闭" [英] Unable to open debugger port : java.net.SocketException “Socket closed”

查看:57
本文介绍了无法打开调试器端口:java.net.SocketException“套接字已关闭"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Android Studio,使用 Gradle 有多种风格,每种风格都有调试和发布类型,按照描述进行组织 此处,下半部分.当我尝试启动调试器时,出现此错误:

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.

推荐答案

只需单击按钮(RUN 按钮左侧).

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

选择安卓.然后运行.

它将连接到您的设备.

并且不要忘记更改构建变体

And dont forget to change build variant

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

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