問題描述
我正在使用 Android Studio,有多種使用 Gradle 的風(fēng)格,每種風(fēng)格都有一個 Debug 和 Release 類型,組織方式如 這里,在下半部分.當我嘗試啟動調(diào)試器時,我收到此錯誤:
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
一旦調(diào)試器運行,我也無法將它附加到我的設(shè)備上(它只顯示我的手機名稱,而不是應(yīng)用程序).
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 種口味都可以安裝在我的手機上.我只是無法讓我調(diào)試它們.我還測試了將調(diào)試器附加到 Nexus 平板電腦上,得到了相同的結(jié)果.
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 的應(yīng)用程序并很好地附加調(diào)試器,所以我想知道這是否與我如何設(shè)置我的 Gradle 項目和設(shè)置有關(guān).
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 是完全最新的.我已經(jīng)重啟了 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 進程正在運行,因為它不會自行殺死它們,我經(jīng)常不得不殺死 Android Studio 來殺死它們.一旦解決了這個問題,它就會斷斷續(xù)續(xù)地工作.
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 的答案有效,以及為什么如果我們當時知道它可能會解決我的問題.請參閱我的第二條評論以了解原因,但簡而言之,您必須在該下拉列表中選擇與您的應(yīng)用程序根目錄匹配的名稱.
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.
推薦答案
只需點擊按鈕(運行按鈕左側(cè)).
Just Click the button (left side the RUN button).
選擇安卓.然后運行.
它將連接到您的設(shè)備.
別忘了更改構(gòu)建變體
這篇關(guān)于無法打開調(diào)試器端口:java.net.SocketException “Socket closed"的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!