Unable to attach debugger in Android Studio - localhost:8600 java.net.ConnectException

前端 未结 11 2095
不思量自难忘°
不思量自难忘° 2021-02-07 00:35

I cannot attach the debugger in Android Studio while running debug on a phone.

I’m currently using a Samsung S4, running Android 4.4.4 (but have tried an S5, S6, S7, and

相关标签:
11条回答
  • 2021-02-07 01:29

    I just experienced the same issue. It seems, as if Android Studio Version 2.2 has some issues with a non-attaching debugger as you can see for example here and here.

    In my case the following helped:

    • Remove the launch profile for your app by going to Run -> Edit Configurations... and removing the profile there. Don't forget to hit the OK button after you have removed the profile. :)
    • Create a new launch profile from scratch by again going to Run -> Edit Configurations..., hitting the + button, selecting an Android App launch profile and selecting your start module. The other default values of the profile were just fine.

    Hope this helps you as well.

    0 讨论(0)
  • 2021-02-07 01:32

    This problem was driving me crazy for about 2 weeks. What finally fixed it for me was changing "auto" to "java" in the debugger process selection window like this:

    0 讨论(0)
  • 2021-02-07 01:34

    Quite embarrassing, but it looks like some time ago I had entered an ip address into my /etc/hosts file to test something as localhost and never removed it. I found a comment on another post saying to check that the following is in your /etc/hosts:

    127.0.0.1       localhost
    255.255.255.255 broadcasthost
    ::1             localhost
    

    Upon commenting out that spurious line, the debugger is now working. Given I have a dozen or so other IPs in that file (so I can more easily test remote hosts with a friendly name), I must have not noticed this one at the bottom. I think a more foolproof approach to verifying if this is the problem or not is to ping localhost and verify that it resolves to the ip address of 127.0.0.1, e.g.,

    $ ping localhost
    PING localhost (127.0.0.1): 56 data bytes
    

    Great comments and suggestions from other folks here too, thanks!

    0 讨论(0)
  • 2021-02-07 01:34

    Try using below commands on terminal-

    1. adb kill-server

    2. adb start-server

    It works well.

    0 讨论(0)
  • 2021-02-07 01:35

    Support for a true debug build. Developers no longer need to add the android:debuggable attribute to the tag in the manifest — the build tools add the attribute automatically. In Eclipse/ADT, all incremental builds are assumed to be debug builds, so the tools insert android:debuggable="true". When exporting a signed release build, the tools do not add the attribute. In Ant, a ant debug command automatically inserts the android:debuggable="true" attribute, while ant release does not. If android:debuggable="true" is manually set, then ant release will actually do a debug build, rather than a release build.

    In my case i struggling this issue with 5 hour and found that the

    minifyEnabled true is the main culprit so change minifyEnabled false work for me

    My app build.gradle file look like

     buildTypes {
            debug {
                signingConfig signingConfigs.debug
                minifyEnabled false
                shrinkResources true
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
    
        }
    
    0 讨论(0)
提交回复
热议问题