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
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:
Hope this helps you as well.
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:
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!
Try using below commands on terminal-
adb kill-server
adb start-server
It works well.
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'
}
}