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 logcat
launched from the command line show anything? – pskink