I/O Error Connection refused android studio - android

WhenI run a project in android studio, I get this error - I/O Error: Connection refused
The emulator starts fine but doesn't pull in/reflect my project
Device connected: emulator-5554
Device is online: emulator-5554
Target device: Nexus4 [emulator-5554]
Uploading file
local path: /Users/martinsjolte/AndroidStudioProjects/FirstAPP1/Firstapp1/build/apk/Firstapp1-debug-unaligned.apk
remote path: /data/local/tmp/dk.first.Firstapp1
Installing dk.first.Firstapp1
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/dk.first.Firstapp1"
Device disconnected: emulator-5554
Launching application: dk.first.Firstapp1/dk.first.Firstapp1.MainActivity.
DEVICE SHELL COMMAND: am start -n "dk.first.Firstapp1/dk.first.Firstapp1.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
I/O Error: Connection refused
My platform is a mac osx ver.12.9.1

Ok, I don't know if i got "the" answer. but here is how I've solved the same issue on my environnement ( Windows 8/Android Studio, but same error with ADT or eclipse) :
Context of my issues :
I've got an Asus PC, and with all the application suite installed by default.
So I've found that one of this Asus app ( currently "Asus sync") was using adb and in fact, it was taking control of the emulator over my adb in the AndroidSDK directory.
How to fix as a PC user :
Go to Task manager ( right click on task bar) , and look for "adb.exe" . Then right click on it and select "Open the directory". This will bring you to the responding adb. In my case it was Asus Sync, so I just had to unistall this software and everything works fine !
How to fix as a Mac user :
Go to Activity Monitor (/Applications/Utilities/), and look for "adb". Then try to kill the process. Then look if it solve your "Connection refused" in Android studio/ADT or eclipse
If still not working you can try :
Start a emulator ( with your AVD manager)
when finished loading, Open DDMS panel (in android studio : Menu Tools > Android > Monitors DDMS)
Look if you see your current running android emulator ( listed on the Device panel)
See if this line is kind of "flashing" ( connect/disconnect).
If so, you have probably a other adb instance running in conflict
If not, you can restart adb or reinstall your SDK
Hope this could help someone !

This issue occurs when Android Debug Bridge aka ADB is not responding to the request from Android Studio. I killed the process adb.exe and started it again. This solved my problem.

If you are using a real device :
Just reconnect your device, make sure your cable are workable and you installed the proper drivers.

I had the same problem, and my problem fixed by restarting the android-studio. Hope, that will help you too.

For me the following worked(after I tried the above points mentioned by others):
I tried debugging/running anther application. It was okay. So this pointed me to the direction that the current application has some problem
if (point 1 == true) {I uninstalled the application from my phone manually }
Then re-make/rebuild the application and debug/run worked

Related

ADB is not working after android studio update

I have updated android studio to Android Studio v2.3.3 (June 2017) and adb stopped showing logs when I launch app on android studio emulator
The log shows:
07/11 13:08:17: Launching app
$ adb push C:\Users\1\AndroidStudioProjects\Don'tWakeMeApp4\app\build\outputs\apk\app-debug.apk /data/local/tmp/oleksandr.ivanets.dontwakemeapp
$ adb shell pm install -r "/data/local/tmp/oleksandr.ivanets.dontwakemeapp"
Success
$ adb shell am start -n "oleksandr.ivanets.dontwakemeapp/oleksandr.ivanets.dontwakemeapp.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Client not ready yet..Waiting for process to come online
Connected to process 4429 on device Nexus_5X_API_26 [emulator-5554]
Click on below link
http://adbshell.com/downloads
and download the first link with name ADB Kits ( contains adb.exe and necessary .dll files).
After downloading replace these files with the ones in the path
Android/Sdk/platform-tools/
Now click on adb.exe and it will open cmd and will start the adb server.
Now it will detect the device and no problem. OOOOOllllaaaaa.....
If the Problem persists again then do the same... save the folder
somewhere.... just replace files... it will detect the device
automatically then
Preface: Although my answer focuses on Android Studio's perspective of ADB errors, I'm sure it is helpful for Windows ADB debugging in general!
#sHaRkBoY 's answer helped me look in the right direction. I used to get "Unable to detect adb version, adb output:" on Android Studio while trying to "run" the app onto the phone... and no devices showed up when phone was connected to PC.
I had tried all these (from different SO answers) but none of them worked!!!:
"Invalidate cache and restart" from File toolbar.
Turn off and turn on USB debugging on phone multiple times
Experimented with "MTP", "PTP", "Midi" and "Charging" modes to see if ADB detects something...
Checked my anti-virus software to see if adding exceptions to the adb directory works...
Installed various unnecessary C++ re-distributables
Tried a different USB cable (and USB port)
Restarted Android Studio and PC
and even uninstalled and re-installed Android studio!
The problem finally was that the platform_tools\adb.exe file downloaded by the official SDK tool manager was corrupted! So I used to get windows error code 0xc0000142 on launching adb.exe from command prompt! :(
SOLUTION:
For future readers (and victims xD) of the above ADB problem, please do the following:
Firstly, add the platform_tools\ directory into the system path environment variable.
Go ahead and replace the following 3 files in your platform_tools (C:\Users\{YourAccount}\AppData\Local\Android\Sdk\platform-tools) directory. (Please backup the same folder before, just in case.)
ADB kit (internal version number: 32)
Note: Please prefer this ADB kit (exe and dll files), compared to #sHaRkBoY 's ADB kit (2.0.0.0), since it has an updated version of AdbWinUsbApi.dll (2.0.0.1), where a race condition issue has been fixed!
I hope my answer saves your from the traumatic experience I went through while troubleshooting magical ADB for an entire day! :)

adb socket not working and daemon

I am getting this type of error
error: could not install smartsocket listener: cannot bind to
127.0.0.1:5037: Only one usage of each socket address (protocol/network address/port) is normally permitted. (10048) 1:34:26
PM could not read ok from ADB Server 1:34:26 PM * failed to start
daemon * 1:34:26 PM error: cannot connect to daemon 1:34:26 PM
'C:\Users\MITESH
SUTHAR\AppData\Local\Android\Sdk\platform-tools\adb.exe,start-server'
failed -- run manually if necessary 1:38:14 PM Unable to obtain result
of 'adb version'
my genymotion device is running but it shows me that no device
I came across the same error. I provided the below command and the issue got solved.
COMMAND :- taskkill /f /im adb.exe
Close Eclipse or Android Studio if either is running (Optional).
Open Command Prompt.
Go to the Android SDK platform-tools directory.
Type adb kill-server.
Type adb start-server.
If no error message is thrown while starting ADB server, then adb is started successfully.
OR
Go to Task Manager, open the Processes tab, and end the adb.exe process.
Then restart Android Studio.
This may work if there is any problem with adb.
In my case, none of the above solution worked. I solved it strangely maybe it can be a bug.
Do not run Genymotion emulator before Android Studio. Firstly, I opened android studio then I clicked run project and select deployment target windows appeared. Then I run genymotion emulator and now the emulator is shown in the select deployment target windows in Android Studio. Then deployed to the emulator without errors. Done!
As another way, you can try to set Genymotion sdk to the same as Android studio sdk. To do this, first find your sdk location. You can find it by right clicking the Android Studio project -> Open Module Settings-> Select SDK location -> under Android SDK location, it is shown. Then open Genymotion -> Settings -> ADB tab -> Click Use custom Android SDK tools radio button -> navigate to SDK folder used by Android studio -> Restart Genymotion virtual device
If none of the above worked for you, just make sure that you have closed Genymotion emulator as it caused this issue with me.
Easiest Way! I just ran into this issue trying to connect a React-Native App to an Android Studio emulator. If you read the error message it tells you that "Only one usage of each socket address (protocol/network address/port) is normally permitted." So you can assume that something other than React-Native is also attempting to connect to the emulator.
Terminate The Connections:
Leave the emulator running.
Close out of and uninstall any Android Studio/Eclipse Apps you have on the emulator. This terminates apps trying to connect.
Close Eclipse or Android Studio if either are running. Android Studio doesn't have to be open in order for the emulator to work (This is important). This terminates software trying to connect.
After doing so I went back into my React-Native App and connected to Expo no problem.
All you have to do is terminate all connections. However you so choose.
I came across the same error, it worked simply after restarting the AS on windows, of course, it asked for SDK update.
Android Studio 4.1.3 with API 30 installation has this error
01-04-2021
09:56 'C:\Users\ranja\Android\Sdk\platform-tools\adb.exe start-server' failed -- run manually if necessary
Tried C:\Users\ranja>adb start-server
daemon not running; starting now at tcp:5037
**could not read ok from ADB Server
failed to start daemon
error: cannot connect to daemon**
Note: I have added 'C:\Users\ranja\Android\Sdk\platform-tools' in %PATH% environment variable on Windows 10
i've encountered same error in my ionic 2. i just uninstall and reinstall ionic. and it works fine again..
npm uninstall -g ionic
npm install -g ionic

Android Studio Unknown Emulator running and can't be terminated

I have one emulator actively running at the moment but I see two emulators running when I run the app. One of them is an Unknown Emulator.
When I choose the Unknown emulator, the console shows this error:
Error: Could not access the Package Manager. Is the system running?
How do I terminate this Unknown Simulator? I think it's using my system's resources and degrading the performance.
Well, it was the BlueStacks emulator running in the background. Android Studio automatically detects it. The unknown simulator was there because BlueStacks was running in the background at the Notification Tray in my windows 8.1
When I closed BlueStacks from the Notification Tray, the Unknown emulator vanished for good.
First reason if your emulator in offline.
To resolve this you need to run command kill-server from adb.
Open Command prompt->navigate to android sdk-> go to platform-tools-> adb kill-server -> adb start-server
You need to run above command to remove unknown
Second reason if your project configuration not match with emulator configuration
Change your emulator configuration with your project requirement. May be your application version not match with emulator configuration
It was very simple to fix for my case :) Just need to type the following 2 commands using CMD:
adb kill-server
adb start-server
Make sure that the windows PATH variable contains "adb.exe" file's directory location. Normally, it should be:
YOUR_PATH_TO_SDK\platform-tools
//For example: D:\sdk\platform-tools

ddms: 'adb.exe,start-server' failed -- run manually if necessary, Android Studio

My adb is down, no matter I am using ADT or Android Studio.
And according to the second answer of this SO question, I did:
I type:
adb nodaemon server
Output:
cannot bind 'tcp:5037'
Then netstat -ano | findstr 5037
I did find a pid of 7416 who listen in 127.0.0.1:5037
I use taskkill /pid 7416 -f to kill it.
I type netstat -ano | findstr 5037 again, I found another pid listens at 127.0.0.1:5037 again!
I guess they are the same, but I have no idea who it is.
Can I simply have a easy way to release this port or change the adb port to another one?
In my case I was trying to use genymotion emulator device.
With genymotion opened and running, I've tried to run my app in this emulator but I it doesn't worth
In this part I had this error:
'C:\Users\Jose\AppData\Local\Android\sdk\platform-tools\adb.exe,start-server' failed -- run manually if necessary
Then I've tried Jaskey's solution but it doesn't works.
So I stopped genymotion emulator.
Then I restart ADB (Tools > Android > Unchecked Unable ADB Integration then I've checked again)
Next I've start genymotion emulator again
And now the app works on the emulator.
For Windows,
Close Android Studio and any of your Emulators you are using,
then goto->TaskManager and Kill the process(adb.exe)
After finishing all these First open Android studio followed by emulators.
Sometimes there are conflicts between ADB Genymotion and ADB SDK because both of them use the same port. So I recommend always set up ADB Genymotion to use the ADB SDK, in that way to avoid incompatible issues.
Genymotion-> Settings -> ADB -> Use custom Android SDK tools (here your set up your sdk android location).
I solve this problem at last! I finally found the program name of the pid and I kill it in the task manager.
The way to detect is described in the question:
adb nodaemon server
Output:
cannot bind 'tcp:5037'
2.and then netstat -ano | findstr 5037 to find who takes this port.
Get the pid and find it in the task manager. Please note that the process tab may not show the column of pid, we should include it by setting.
In my case, it is tfadb.exe who takes this port! This is a Chinese Video program client! Try to kill it in task manager.
Now I stop it starting from booting. The problem is solved.
The best and working solution is:
Close Android Studio
Open task manager
Kill the process adb.exe
Open android studio again
Problem solved
Close Android studio then go to Task Manager
End Task adb.exe
goto Details menu
End Task java.exe and jusched.exe
now open Android Studio it will work properly
I solved by End task "adb.exe" background process from task manager.
and Start adb thats it :)
Open the Genymotion emulator after opening The Android studio.
in my case one application on window use adb.exe.
that application name is mobogenie.
Fixed ::
Goto Window TaskManager select adb.exe and press End process
Just goto the task manager on your PC, and kill adb.exe, then back to your android studio. it should initialize and reconnect.
disconnect any usb connected android devices. I was tethering to my laptop via my cellphone for internet connection. I got the adb start server failed error with loopback error "port is only used for one socket connection".
I disconnected my cellphone usb connection from my laptop and now android studio recognizes my genymotion emulator and another android device I have connected via usb in the deployment target box.
if genymotion or emulator not working try to install pdanet+ in your system and mobile device choose your mobile type(motorola,sony,other)it will automatically install driver and run your application in mobile device.
Check the firewall of the system. May be the "allow app to communicate through windows firewall" may have blocked android studio.
I have tried all of the solutions proposed above, but no one of them solve my problem. I had some hour of hadaches trying to solve this problem on my laptop (Ubuntu 20.04). This is how I came to solve it finally.
The problem was that the adb default port 5037 was already taken by another, so the solution became simple :
kill the process running on that port (5037) then launch the adb manually
launch the adb on another port :
user~$ adb start-server -P xxxx
Where xxxx represent another port
There may be a problem with Windows 11. to solve that issue follow the steps
Go to the android studio app
Right-click the app
Go to Properties
Go to compatibility
Check the Run this program in compatibility mode
Select windows version 10 or 8 or 7 Then apply and ok
After these changes start the Android Studio App, This is works for me.

error "The connection to adb is down" when run an android app

I'm new with android development, and I have problems installing all the recent platform. I'm a java developer that I would like learning android.
I've installed all programs succesfully in windows xp sp3 (JDK 1.6 with environment vars created, eclipse 3.5, 3.6 & 3.7 well configured, Android SDK with all the features, devices, platform-tools, APi's, etc, and ADT Plugin 12 for eclipse with an emulator to API 8 -Target 2.2-), but, when I'm running an android project into eclipse (Run -> Android Application), the eclipse console show me: "The connection to adb is down, and a severe error has ocurred... You must restart adb and eclipse... Ensure that adb is in this path 'D:\Android\android-sdk-windows\platform-tools\adb.exe'" (or something similiar).
I'm very sure that the path is right, adb is correctly running on command-line, and the commands 'adb kill-server' and 'adb start-server' works fine, but doesn't solve my problem (like I've read in other answers).
The emulator, via Eclipse, not working, but if I start the emulator via Eclipse ADV Manager, emulator starts fine, but when I runs the android app, I take the same error.
I suppose that Eclipse can't start adb,but I don't know why.
Other issue, when I executed 'adb devices', console show me an empty list, no 'no devices' message, but when I plugged my HTC, adb is running fine in console, but Eclipse doesn't.
In addition, I also try restarting adb with Eclipse - Devices tab, but the list of devices are empty too.
Anyone can help me, please? I've read so much that my eyes are pixelated. xD
Best regards!!
PD: sorry, but my english is a bit poor ;)
in the DDMS perspective (if it doesn't show, add it by click window>open perspective>other...>DDMS)
then click the triangle of the devices tab > reset adb.
this works for me.
I finally resolved the problem, please see my blog
you can do this steps to solve the problem:
task manager-> process
right click on adb.exe and left click on "properties"
check the path of the process:
-if the path is like "Programs\android-sdk\platform-tools", which means it is the android sdk that is running this process.
-if not, that means there is another process this is running adb.exe, you have to kill the process or service which runs adb.exe.(you can identify the process by the path)
I've had this problem too. The solution I've found is to kill eclipse, open up task manager and kill the adb.exe process. Then when you start eclipse again, that should also kick start adb and it should work from there.
Try the following steps :
- Close Eclipse IDE
- Go to the Android SDK platform-tools directory in Command Prompt
- run adb kill-server
- run adb start-server
- Now start Eclipse again.
Hope this may help you :)
In my case, in Windows7
Close all opened emulators
Go to task manager > processes and then click on adb.exe and press the button 'end process'.
Then go to command prompt go to plate-form tools and type
adb start-server
Then run your application through eclipse.
It worked fine for me.
you try
Open Task Manager > Processes > eclipse.exe > End Process > restart eclipse
In my case the problem was the FIREWALL!.Turn off your windows firewall , Then restart adb and eclipse from task-manager

Categories

Resources