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 Moto E phone on various Android versions). It times out when I try to run it with either of the following errors:
I/System.out: Sending WAIT chunk
W/ActivityThread: Application is waiting for the debugger on port 8100...
Or
failed to open debugger port localhost:8600 java.net.ConnectException "connection refused"
and the App says:
Waiting For Debugger
Application (process ) is waiting for the debugger to attach.
Force Close
Android Studio version:
Android Studio 2.2.2
Build #AI-145.3360264, built on October 18, 2016
JRE: 1.8.0_112-release-b05 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac version:
10.11.6 (15G1004)
I can successfully connect and run the application, I just can’t get the debugger to attach when I do Run > Debug App > select the connected phone > OK.
I have been able to run the app in debug on other computers (both Windows and Mac) with the same phones.
Various approaches I have tried from hours of debugging and online searching:
Invalidate Caches/Restart Android studio
Check for anything else running on ports 8100, 8600, 8601, etc., nothing comes back when I run the following from bash:
$ # while Android studio is trying to attach the debugger
$ lsof -i :8100
$ lsof -i :8600
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
studio 6282 peter 125u IPv4 0x973c7e31bda641ab 0t0 TCP 192.168.1.16:64022->ip-166-62-27-181.ip.secureserver.net:asterix (SYN_SENT)
$ lsof -i :8601
$
$ # after Android studio fails to attach the debugger
$ lsof -i :8100
$ lsof -i :8600
$ lsof -i :8601
$
Run Tools > Android > Android Device Monitor - it shows my device, but I can’t run Android Device Monitor while I’m trying to debug the app, it says, “Monitor will be closed to enable ADB integration. Continue?” I haven’t found anything useful here.
Searching for and killing adb processes
ps aux | egrep '(adb|java)'
... then doing `kill <pid>` or `kill -9 <pid>` if necessary for the found ones
Restart Android studio
Restart my computer
Update Java JDK from the Oracle website—however, I’m not sure why Android Studio still says, “JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o”
Completely uninstall and reinstall android studio - e.g., https://stackoverflow.com/a/18458893/376489 - weirdly, I think this worked for one run of the debugger and then not again…
Tried Run > Attach debugger to Android Process - this didn’t help
Tried running:
~/Library/Android/sdk/platform-tools/adb kill-server &&
~/Library/Android/sdk/platform-tools/adb start-server
Tried unchecking Run > Edit Configurations > Run/Debug Configurations > Skip installation if APK has not changed
Check System Preferences > Security & Privacy > Firewall - this is turned off
Update 1: tried revoking permissions on the phone as well as restarting it
Update 1: muted all breakpoints Android Studio
Are there any other ideas for what might be going wrong or anything meaningful in the details I added above?
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!
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.
I am using a real device. Simply deleting the app on the device, and then running from Android Studio solved this issue.
It seems Android Studio had trouble with overwriting the file that was already on the phone.
1.try cleaning project Build->clean project
2.do file->Invalidate/cache restart
if above not helps you..
3.try to change the data cable you are using to connect your phone.
if nothing above helps, install Android wifi ADB plugin and try to do debug over wifi.
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'
}
}
I also got same error and this thing worked for me
1. Open Android Studio -> Terminal
2. Change directory to $Android SDK Path$\platform-tools
3. Write command adb get-state and hit enter.
Then you will get this output
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
I have the opposite problem with Android Studio 3.3, trying to debug a wi-fi-connected phone.
After selecting the device in Android Studio, I receive the following message:
Error running 'app': Unable to open debugger port (localhost:8600):
java.net.ConnectException "Connection refused: connect"
I also have IPV-6 enabled on my network.
The issue is that "localhost" resolves to ::1 on my machine by default, but ADB studiously binds explicitly to 127.0.0.1. I happen to know this because I spent the day trying to make ADB connect to emulators running on a remote machine (not since Android 4.4 unfortunately.
To solve the problem, add the following line to \windows\system32\drivers\etc\hosts:
127.0.0.1 localhost
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:
Try using below commands on terminal-
adb kill-server
adb start-server
It works well.
Simply not using my google pixel 1st gen and using my new Nokia 7 plus fixed this issue :).
There is a known issue with Android Studio 4.2.1 on Ubuntu 20.04 when debugging native code.
There is an easy way to check if you are concerned, just run the following command line that should not finish with an error:
${android-studio-dir}/bin/lldb/bin/LLDBFrontend
At first i tried all the above ways, did not help.
I have two computers with same settings.
But at one worked at other error.
It's given me an idea that it can be "hardware" problem.
I switched USB to other slot with USB3.0 and used short cable and
WOW it began work.
I suggest there some delay in USB2.0 (polling), therefore process begin out of synch.
Related
I am stuck in a problem here.
I cannot attach debug using Android Studio 3.5.1.
Its keeping showing me the message "Error running 'Android Debugger (8600)': Unable to open debugger port (localhost:8600): java.io.IOException"
I tried a lot of things like:
adb reset
invalidate
restart windows
reinstall android studio
and none of them works.
And I cannot find Enable ADB Integration on this version.
Anyone knows how to fix it?
EDIT
Debugging with emulator is working with all versions.
Debugging with devices is working only with devices with Android 9.0+
Kill and start adb didn't work.
I dont think its a local problem because its happen with a lot of people here. Its seems to be a project problem
You might check this 3 things:
1.
Youre not running a not debuggable version.
android:debuggable="false" in Android Manifest
2.
In Android studio you re not building a release version
Check in Build variants in bottom left corner.
3.
If nothing works use Troubleshoot device connections
Tools -> Connection Assistant
or older version
Tools -> Troubleshoot device connections
And try out the helper page from google (seems for older versions)
https://developer.android.com/studio/run/device#assistant
Try this:
adb kill-server
adb start-server
adb usb
For linux, e.g., ubuntu: start all commands with sudo like this:
sudo adb kill-server.
its your connection issue, cant find your device DNS.
what is your OS ?
In windows:
you must go to network and find duplicate dns and clear it (Search for
it)
In mac:
you must kill adb or delete that and run a new version
last hit is Update emulator in sdk
.First you need to check your build.gradle(app) file , and ensure that your build is debuggable.
.If debuggable then you need to check adb is working or not in your system, you can
check by just press 'adb' .
if its working then check devices by 'adb devices', it will show all connected devices.
add kill-server then enter and adb start-server
Try this. I have had luck with this approach when I run into problems with adb.
You can check if the device is recognised or not using
adb devices
If it is indeed recognised you may try to kill adb and start it again
add kill-server
adb start-server
I know this question was asked before but I tried all the suggested solutions and nothing solved my problem yet.
I can't debug Any Android studio (1.5 preview 2) application using Mac Yosemite.
the error I get is:
Unable to open debugger port (localhost:8600): java.net.ConnectException "Connection refused":
on the debug console I can see error
"Debug port is busy"
I've tried the following with no success:
reinstall jdk 6+7
make sure ports 8600+ are open with with kill .
reinstall Android studio and make sure SDK location configured.
add debuggable true on debug build types.
restart the phone with usb debugging enable.
restart Android studio and my mac.
tried with Build variant debug and release.
on emulator I have the same problem.
with eclipse I dont have any issues with debugging my app.
did I miss something?
This happens to me after updating to AS 1.4 all the time.
I always kill the server and restart it with following commands.
# /path/to/android-sdk/platform-tools/adb.exe
adb.exe kill-server
adb.exe devices
>>> * daemon not running. starting it now on port 5037*
>>> * daemon started successfully*
>>> * 2100000020000001 device
Afterwards I can reconnect with the debugger.
If you add adb.exe to the PATH-variable you can run the commands from the built in terminal in Android-Studio.
For me nothing helped except - Reinstall Android studio and don't choose the option to import your properties from latest Android studio installation. solved the problem.
when I installed and pick the option to import my last installation properties i had the same error again.
Error running Android Debugger (8600):
Unable to open debugger port (localhost:8600):
java.net.SocketException "Connection reset"
I was able to fix this with these commands:
adb kill-server
adb start-server
Try Restarting ANDROID STUDIO (Worked for me)
In my case, there was another service running on my laptop(Windows) that was using the port 8600. I opened Task Manager and stopped the service. Now, I could debug my application normally without the above error.
I solve the problem by checking my localhost.
Making sure 127.0.0.1 localhost.
For me this problem started when i upgraded my Android Studio to new version.
Please go to options menu Build and choose Clean Project.
That is it project started to run again and error was gone.
I tried other answers (e.g. restarting Android Studio) but they didn't solve this for me.
I had accidentally selected MTP (Media Transfer Protocol) in my Developer Options/USB Configuration. It started working once I set it to PTP (Picture Transfer Protocol).
EDIT: On reflection it's probably just that I changed the protocol because I've had the same issue since while on PTP. Hence I'm suggesting that the real answer is to change the protocol on the phone and, if you might need it, don't forget to change it back.
It could be that you need to wait for your code to stop compiling before you attached the debugger. I had a similar error and all I needed was patience.
If you using WiFi debug:
Exit ANDROID STUDIO
adb kill-server && adb start-server
adb tcpip 5555
adb connect [your wi-fi IP]:5555
Start ANDROID STUDIO
I did spent quite an amount of time by trying below things:
Re-installing old(3.6.3) and new(4.0.1) Android studio and Android SDK's
checking all the security things in newly installed Mac OS Catalina
Checking all the developer options in my physical android device and AVD
And all the things mentioned in this post as well: https://medium.com/returntrue/android-studio-cant-bind-to-local-8600-for-debugger-%E3%81%A7%E3%83%87%E3%83%90%E3%83%83%E3%82%AC%E3%83%BC%E3%81%8C%E6%B0%B8%E4%B9%85%E3%81%AB%E8%B5%B7%E5%8B%95%E3%81%97%E3%81%AA%E3%81%84%E3%81%A8%E3%81%8D%E3%81%AB%E3%82%84%E3%81%A3%E3%81%9F%E3%81%93%E3%81%A8-8f5dd9c8ca70
Finally a small change in my /etc/host file resolved this issue. I commented from 0.0.0.0 and ::1 for localhost local DNS entries and enabled only 127.0.0.1
I use Qt Creator to develop an Android dynamic library, i.e. a .so file. This .so file is then used by an Android application, but that is developed in Eclipse.
I need to debug my native code, but since it's a library, I can't start the application from Qt Creator, I must attach to the already running process.
Now, if it were a desktop application, I'd use Debug->Start Debugging->Attach to Running Application, but how do I attach to an Android process, which would be running on the emulator or on a connected phone, which is more like remote-debugging?
I think that I should use Debug->Start Debugging->Attach to Running Debug Server:
However, I'm not sure what the exact steps are - how do I start a debug server for ADB, and which port do I connect to?
So it looks like there may be another way to set up a debugger that can connect properly.
http://lists.qt-project.org/pipermail/qt-creator/2012-June/001017.html
Set a toolchain with this version of gdb, and set your project to use it.
In Tools -> Options -> Debugger -> GDB insert your commands in "Additional
Startup Commands"
...
I use Debug -> Start Debugging -> Attach to Remote. All the fields are
there (solib-absolute-prefix is an alias for sysroot, and "location of
debugging information" is solib-search-path), and the last few
"configurations" are stored, so you can call them back easily. I have
to start gdbserver on the target manually, set a shortcut to open the
'attach to remote' dialog, and it is been working great for me so for.
It's old (June 2012), but it goes into better detail about how the gdbserver is started and the setup for a debugger and attaching to a process in Qt. It also mentions some of the relevant environment variables:
set solib-absolute-prefix $ANDROID_SRC/out/target/product/MYPRODUCT/symbols/
set solib-search-path $ANDROID_SRC/out/target/product/MYPRODUCT/symbols/system/lib/
Hope that helps.
Attaching to a adb logcat is independent of Qt and what Android source you are using. Make sure adb.exe can be found on your path such as: C:\Android\SDK\platform-tools, and you have the adb drivers for the device you are debugging with. Try this one if you are struggling: http://www.koushikdutta.com/post/universal-adb-driver
Command Line ADB commands
This should print out any connected devices that can be found:
adb devices
This clears the current logcat logs:
adb logcat -c
This starts a connection to logcat:
adb logcat
Usually you don't have to worry about which port to connect to, because it is automatically found by adb.
Attaching to logcat over wifi is also do-able.
adb tcpip
adb connect 192.168.XX.XX:5555
Hope that helps.
For some reason eclipse DDMS always gives the error 'Can't bind to local 86XX for debugger' every time I try and debug my app. This just started today for some reason.
I have looked at many posts and tried what they have suggested such as:
1. Adding 127.0.0.1 localhost to the hosts file and moving ::1
2. stopping and restarting adb
3. Under Window -> Preferences -> Android -> DDMS:
Set Base local debugger port to "8601"
Checked the box that says "Use ADBHOST" and set the value to "127.0.0.1"
I have also restarted the computer, updated Android platform tools and the eclipse plugin, Downloaded the latest adt-bundle and started the eclipse that is bundled with that.
I have ran netstat -anob and only javaw and adb use ports 8600+.
Does anyone have any ideas what I can try now?
If you are using Linux, I recommend you as well to run this command:
fuser -k 8600/tcp
With this command you will kill any process running at the 8600 TCP port (The one Android is using to debug).
I had same problem and none of given solutions worked. Then I have uninstalled all JRE 7 and installed latest JRE 6 (http://www.oracle.com/technetwork/java/javase/downloads/jre6downloads-1902815.html). It have immediately fixed the problem.
I have the same problem. I tried really everything, all hints from the web.
I tried:
different versions of JRE and JDE
different ports
different mobiles
modified hosts file
changed preferences ddms
disabled the firewall completely
disabled all IPV6 functionality
I restarted the adb every time
I use Windows 8
Under many many tried it worked for two times. After exiting the debug session and starting another without any changed, the same shit started again....
BUT: I copied the whole environment path with eclipse and android sdk to antoher windows 8 machine, where it works without any problem!
One of the reasons for getting this error could be that there is an existing DDMS session open which is using the port. This is what happened with me. I had Device Manager open when I got this error. After closing the Device manager, I did a clean build and then it worked ! Guess DDMS and debugger are trying to use the same port which results in the problem.
If you are using Windows, then kill any process running at the port 8600 using the two following commands:
netstat -a -n -o | findstr :8600
It should give something like
TCP 127.0.0.1:8600 0.0.0.0:0 LISTENING 7508
Then run
taskkill /F /PID 7508 :: replace 7508 with the displayed PID
I solved this problem like this:
open powershell (Available in all windows after XP). Its a command Prompt. Give the command
> netstat -nao
It will list all the TCP and UDP port that are active on the computer. Find the entry whose local address contain some IP address : 8600. This is the TCP port that you wish to close.
Note the PID of this entry. In the powershell, give another command
> Stop-Process -Id PID
Here the PID is the one we have noted. Now start the debug from eclipse, it should bind the 8600 port with no further problems.