Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio: "Unable to obtain result of 'adb version'"

I am presently unable to do app testing on Android Studio, and I don't know what to do next. I've been getting the error "Unable to obtain result of 'adb version'" when I try to run an emulator. I don't think I changed anything on my system to make it happen, though I usually update any packages Android Studio recommends. I've Googled and that has given me a number of things to try, but I'm no further on. I've tried the following:

  • Uninstalling and reinstalling platform-tools - I even downloaded version 23 (I'm currently on 24) and replaced 24 with that, but that didn't work.

  • Uninstalling and reinstalling Android Studio - this worked for a day, but took hours, so I can't just do it every time.

  • Checking adb.exe exists and the path is correct etc. - adb.exe exists in C:\Users\My Name\AppData\Local\Android\sdk\platform-tools and it seems ok.

  • Anti-virus software blocking adb.exe - turned Firewall off; didn't help.

  • Ran adb from the command line - runs ok, but when I type "adb devices", I get an empty list. If I go into Android Studio and start a device manually from the AVD Manager, and then do "adb devices" again, this time the running device shows up

  • The location of "where adb" seems to be correct - I'm wondering whether Android Studio is looking in the wrong place for it. Is there a way to check the path?

  • Went to the platform-tools folder and typed "adb tcpip 5555" - it said it was starting the daemon, and then that it had started successfully, but that still didn't help

  • Disabled "Enable ADB integration" option, and then re-enabled it. Didn't help. Then tried killing the adb server from the command line in between disabling/enabling. Tried restarting AS in between as well, still didn't help.

I'm stuck now, and I don't know what else to try. Would anyone suggest anything else I could try?

Also, I reckon I could temporarily push the app to the device using the command line, but I'm not sure what to push if I'm only testing, as I don't have an apk file (I think). Which file would I push over to the emulator? And how do I do that? The emulator appears to be called emulator-5554.

I am on Windows 10, and have upgraded to the latest Android Studio (2.1.3).

like image 264
Sharon Avatar asked Feb 06 '23 07:02

Sharon


1 Answers

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!

Wow, I understand the frustration from debugging for hours on long, here is my take on this strange error!

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:

  1. Firstly, add the platform_tools\ directory into the system path environment variable.

  2. 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)

like image 165
varun Avatar answered Feb 11 '23 14:02

varun