Unable to open debugger port : java.net.SocketException “Socket closed”

后端 未结 5 1636
野的像风
野的像风 2020-12-11 14:43

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 de

相关标签:
5条回答
  • 2020-12-11 15:10

    I managed to get this working by attaching the debugger after a build see Unable to open debugger port : java.net.SocketException "Socket closed"

    0 讨论(0)
  • 2020-12-11 15:14

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

    enter image description here

    Select Android. Then Run.

    It will connect to your device.

    And dont forget to change build variant

    enter image description here

    0 讨论(0)
  • 2020-12-11 15:15

    I finally understand why I was getting that error so I'm going to explain how I Debug now. Note that I use Gradle (build multiple apk's using the same code), which might influence some how you use the third part of this answer.

    For these to work, in the dropdown next to the debug (icon in #1) and run buttons in the top toolbar, you have to have the one selected with the following icon next to it because that's the name of the root directory of your app where all your code lives:

    enter image description here

    1. To start debugging from the beginning, I run the app in Debug mode from the start, using this button in your toolbar:

    enter image description here!

    1. To attach the debugger to the app when it's already running as @scottyab mentioned, I click the Attach Debugger button in your toolbar:

    enter image description here

    1. To run the release version of my app in debug mode, I've started changing my strings in the Debug version of strings.xml in the file path myApp/src/appNameDebug(verses appNameRelease)/res/values/strings.xml, more easily seen here, on the bottom half. When I say change, I really mean that I have two versions of all the strings (3 in my case) necessary to change from using the debug server to using the release server. It might not be completely kosher, but it takes about 5 seconds to go the file, and hold down Cmd+/ and uncomment and comment all of the appropriate lines.

    My Release version is just there for when I'm ready to build an apk for release.

    Doing things in this way has eliminated that error popping up anymore. I think the Release version is just not made for debugging, and I haven't found an easy way to turn the debug flags on when in Release mode.

    0 讨论(0)
  • 2020-12-11 15:15

    I managed to get rid of this problem by killing & restart the adb process,hope this would help :]

    0 讨论(0)
  • 2020-12-11 15:16

    I have solved this question with reference to the following SO Answer

    The "Select Run/Debug Configuration" button in android studio 2.3.2

    Change the Debug type to Native

    0 讨论(0)
提交回复
热议问题