Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run "adb", check your Android SDK installation and ANDROID_SDK_ROOT environment variable #72101

Open
davidefiozzi opened this issue Dec 10, 2020 · 39 comments
Labels
c: crash Stack traces logged to the console P2 Important issues not at the top of the work list platform-windows Building on or for Windows specifically t: flutter doctor Problem related to the "flutter doctor" tool team-tool Owned by Flutter Tool team tool Affects the "flutter" command-line tool. See also t: labels. triaged-tool Triaged by Flutter Tool team

Comments

@davidefiozzi
Copy link

davidefiozzi commented Dec 10, 2020

Hi, I'm not able to use properly Flutter with Android Studio on my new laptop after switching from the old one.

Here is the output of flutter doctor verbose:

flutter doctor -v
C:\src\flutter\bin\flutter.bat doctor --verbose
[√] Flutter (Channel stable, 1.22.4, on Microsoft Windows [Versione 10.0.18363.1256], locale it-IT)
    • Flutter version 1.22.4 at C:\src\flutter
    • Framework revision 1aafb3a8b9 (4 weeks ago), 2020-11-13 09:59:28 -0800
    • Engine revision 2c956a31c0
    • Dart version 2.10.4

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at C:\Users\Claudio\AppData\Local\Android\Sdk\
    • Platform android-30, build-tools 30.0.3
    • ANDROID_SDK_ROOT = C:\Users\Claudio\AppData\Local\Android\Sdk\
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[!] Android Studio (version 4.1.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[!] IntelliJ IDEA Community Edition (version 2018.3)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.3.5
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
    • For information about installing plugins, see
      https://flutter.dev/intellij-setup/#installing-the-plugins

[☠] Connected device (the doctor check crashed)
    X Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at https://github.com/flutter/flutter/issues.
    X Exception: Unable to run "adb", check your Android SDK installation and ANDROID_SDK_ROOT environment variable: C:\Users\Claudio\AppData\Local\Android\Sdk\platform-tools\adb.exe
    • #0      throwToolExit (package:flutter_tools/src/base/common.dart:14:3)
      #1      AndroidDevices.pollingGetDevices (package:flutter_tools/src/android/android_device_discovery.dart:71:7)
      <asynchronous suspension>
      #2      PollingDeviceDiscovery._populateDevices (package:flutter_tools/src/device.dart:467:60)
      #3      PollingDeviceDiscovery.devices (package:flutter_tools/src/device.dart:457:12)
      #4      DeviceManager.getAllConnectedDevices (package:flutter_tools/src/device.dart:171:20)
      #5      DeviceValidator.validate (package:flutter_tools/src/doctor.dart:975:55)
      #6      asyncGuard.<anonymous closure> (package:flutter_tools/src/base/async_guard.dart:111:32)
      #7      _rootRun (dart:async/zone.dart:1190:13)
      #8      _CustomZone.run (dart:async/zone.dart:1093:19)
      #9      _runZoned (dart:async/zone.dart:1630:10)
      #10     runZonedGuarded (dart:async/zone.dart:1618:12)
      #11     runZoned (dart:async/zone.dart:1547:12)
      #12     asyncGuard (package:flutter_tools/src/base/async_guard.dart:109:3)
      #13     Doctor.startValidatorTasks (package:flutter_tools/src/doctor.dart:191:9)
      #14     Doctor.diagnose (package:flutter_tools/src/doctor.dart:290:47)
      #15     DoctorCommand.runCommand (package:flutter_tools/src/commands/doctor.dart:59:47)
      #16     FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:977:18)
      #17     _rootRunUnary (dart:async/zone.dart:1198:47)
      #18     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
      #19     _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
      #20     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
      #21     Future._propagateToListeners (dart:async/future_impl.dart:725:32)
      #22     Future._completeWithValue (dart:async/future_impl.dart:529:5)
      #23     Future._asyncCompleteWithValue.<anonymous closure> (dart:async/future_impl.dart:567:7)
      #24     _rootRun (dart:async/zone.dart:1190:13)
      #25     _CustomZone.run (dart:async/zone.dart:1093:19)
      #26     _CustomZone.runGuarded (dart:async/zone.dart:997:7)
      #27     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
      #28     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
      #29     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
      #30     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
      #31     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:169:5)


! Doctor found issues in 3 categories.

As suggested in the output, i checked env variables, but seems all ok. I don't have any other adb.exe running on my machine. These are my env variables:
ANDROID_SDK_ROOT: C:\Users\Claudio\AppData\Local\Android\Sdk
PATH: [...] C:\Users\Claudio\AppData\Local\Android\Sdk\platform-tools;C:\Users\Claudio\AppData\Local\Android\Sdk\tools;[...]

This is what i tryed to fix the issue, but it didn't work:

  • reboot :P
  • uninstall and reinstall platform-tools from Android SDK settings menu in Android Studio
  • searched with "where adb" if there was another adb.exe causing issues, but i didn't find anything

In my old laptop everything is EXACTLY the same, same platform-tools version, same Android Studio version, same env variables ecc...
I really can't get what's wrong, and this issue is causing important delay to my work, thanks a lot to anyone that will help me!

@pedromassangocode
Copy link

Hi @davidefiozzi
Can you please run from your terminal (making sure that flutter is added to your path)

adb devices 
flutter doctor -v

and provide the full logs.
Thank you

@pedromassangocode pedromassangocode added in triage Presently being triaged by the triage team waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds labels Dec 11, 2020
@davidefiozzi
Copy link
Author

davidefiozzi commented Dec 11, 2020

adb devices recognizes my device

image

I noticed that if i run adb in cmd.exe it doesn't work

image

but if i run it on Windows PowerShell it does work.

I also tried in flutter directory

image

I don't repost the verbose flutter doctor output because is exactly the same as the one provided in the issue opening
Thanks a lot Pedro for the help

EDIT: I can also notice that when I open Android Studio, i see the message "Flutter daemon terminated".
Moreover, I searched if other processes were using port 5037, but only adb in my laptop uses this port

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Dec 11, 2020
@pedromassangocode
Copy link

Is flutter doctor -v able to detect your device?

@pedromassangocode pedromassangocode added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Dec 11, 2020
@davidefiozzi
Copy link
Author

No, it crashes

[☠] Connected device (the doctor check crashed)
X Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at https://github.com/flutter/flutter/issues.
X Exception: Unable to run "adb", check your Android SDK installation and ANDROID_SDK_ROOT environment variable: C:\Users\Claudio\AppData\Local\Android\Sdk\platform-tools\adb.exe

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Dec 11, 2020
@pedromassangocode pedromassangocode added passed first triage platform-windows Building on or for Windows specifically c: crash Stack traces logged to the console t: flutter doctor Problem related to the "flutter doctor" tool tool Affects the "flutter" command-line tool. See also t: labels. and removed in triage Presently being triaged by the triage team labels Dec 11, 2020
@jmagman
Copy link
Member

jmagman commented Dec 16, 2020

@davidefiozzi Can you find where adb.exe is in your SDK? It is in C:\Users\Claudio\AppData\Local\Android\Sdk\platform-tools?

@davidefiozzi
Copy link
Author

Yes, is the only adb.exe present in my system.
(as written in the first post)

@christopherfujino christopherfujino moved this from Awaiting triage to Engineer reviewed in Tools - Android review Dec 16, 2020
@AfrahAsif
Copy link

Yes, is the only adb.exe present in my system.
(as written in the first post)

I encounter with the same error on ANDROID_SDK_ROOT variable. How did you fix this?

@boriskamtou
Copy link

No, it crashes

[☠] Connected device (the doctor check crashed)
X Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at https://github.com/flutter/flutter/issues.
X Exception: Unable to run "adb", check your Android SDK installation and ANDROID_SDK_ROOT environment variable: C:\Users\Claudio\AppData\Local\Android\Sdk\platform-tools\adb.exe

I've the same error

@chunweii
Copy link

$ flutter doctor -v
[✓] Flutter (Channel stable, 2.2.1, on Microsoft Windows [Version 10.0.19043.985], locale en-SG)
    • Flutter version 2.2.1 at C:\src\flutter
    • Framework revision 02c026b03c (22 hours ago), 2021-05-27 12:24:44 -0700
    • Engine revision 0fdb562ac8
    • Dart version 2.13.1

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at C:\Users\chunw\AppData\Local\Android\Sdk\
    • Platform android-30, build-tools 30.0.3
    • ANDROID_SDK_ROOT = C:\Users\chunw\AppData\Local\Android\Sdk\
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[✓] Android Studio
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • android-studio-dir = C:\Program Files\Android\Android Studio
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)

[✓] IntelliJ IDEA Community Edition (version 2021.1)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.2.4
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.56.2)
    • VS Code at C:\Users\chunw\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[☠] Connected device (the doctor check crashed)
    ✗ Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know
      about this issue at https://github.com/flutter/flutter/issues.
    ✗ Exception: Unable to run "adb", check your Android SDK installation and ANDROID_SDK_ROOT environment variable:
      C:\Users\chunw\AppData\Local\Android\Sdk\platform-tools\adb.exe
    • #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
      #1      AndroidDevices.pollingGetDevices (package:flutter_tools/src/android/android_device_discovery.dart:78:7)
      <asynchronous suspension>
      #2      PollingDeviceDiscovery._populateDevices (package:flutter_tools/src/device.dart:397:54)
      <asynchronous suspension>
      #3      Future.wait.<anonymous closure> (dart:async/future.dart)
      <asynchronous suspension>
      #4      DeviceManager.getAllConnectedDevices (package:flutter_tools/src/device.dart:163:40)
      <asynchronous suspension>
      #5      DeviceValidator.validate (package:flutter_tools/src/doctor.dart:510:34)
      <asynchronous suspension>
      #6      asyncGuard.<anonymous closure> (package:flutter_tools/src/base/async_guard.dart:111:24)
      <asynchronous suspension>

I also have a similar issue and I cannot run adb on cmd, but it works on git bash or powershell.

Interestingly, when I created a new user account on the same pc, and followed the same steps in https://flutter.dev/docs/get-started/install/windows, I can run flutter apps just fine. It just does not work on my main account, even after many rounds of reinstallations.

@edutilos6666
Copy link

`I have solved this issue in ubuntu:

  1. in ~/.bashrc add the following lines:
    export PATH="/home/edutilos/Applications/android-sdk/platform-tools:$PATH"
    export PATH="/home/edutilos/Applications/android-sdk/tools:$PATH"

  2. source ~/.bashrc file:
    source ~/.bashrc

In Windows , probably you have to make sure /tools and /platform-tools are in the %PATH%.
`

@ansidev
Copy link

ansidev commented Jul 24, 2021

Same problem:

[✓] Flutter (Channel stable, 2.2.3, on macOS 11.4 20F71 darwin-x64, locale en)
    • Flutter version 2.2.3 at /Users/mac/tools/flutter
    • Framework revision f4abaa0735 (3 weeks ago), 2021-07-01 12:46:11 -0700
    • Engine revision 241c87ad80
    • Dart version 2.13.4

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/mac/Library/Android/sdk
    • Platform android-31, build-tools 30.0.3
    • ANDROID_HOME = /Users/mac/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/mac/Library/Android/sdk
    • Java binary at: /Users/mac/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/202.7351085/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.5.1, Build version 12E507
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.2)
    • Android Studio at /Users/mac/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/202.7351085/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)

[✓] IntelliJ IDEA Ultimate Edition (version 2021.1.2)
    • IntelliJ at /Users/mac/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 58.0.3
    • Dart plugin version 211.7665

[✓] VS Code (version 1.58.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.24.0

[☠] Connected device (the doctor check crashed)
    ✗ Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at https://github.com/flutter/flutter/issues.
    ✗ Exception: Unable to run "adb", check your Android SDK installation and ANDROID_SDK_ROOT environment variable: /Users/mac/Library/Android/sdk/platform-tools/adb
    • #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
      #1      AndroidDevices.pollingGetDevices (package:flutter_tools/src/android/android_device_discovery.dart:78:7)
      <asynchronous suspension>
      #2      PollingDeviceDiscovery._populateDevices (package:flutter_tools/src/device.dart:397:54)
      <asynchronous suspension>
      #3      Future.wait.<anonymous closure> (dart:async/future.dart)
      <asynchronous suspension>
      #4      DeviceManager.getAllConnectedDevices (package:flutter_tools/src/device.dart:163:40)
      <asynchronous suspension>
      #5      DeviceValidator.validate (package:flutter_tools/src/doctor.dart:510:34)
      <asynchronous suspension>
      #6      asyncGuard.<anonymous closure> (package:flutter_tools/src/base/async_guard.dart:111:24)
      <asynchronous suspension>

@Noojuno
Copy link

Noojuno commented Feb 3, 2022

Having the same issue. Creating a separate user account and running it there worked, but it still won't work on my primary user.

[✓] Flutter (Channel stable, 2.8.1, on Microsoft Windows [Version 10.0.19044.1503], locale en-NZ)
    • Flutter version 2.8.1 at F:\Android\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 77d935af4d (7 weeks ago), 2021-12-16 08:37:33 -0800
    • Engine revision 890a5fca2e
    • Dart version 2.15.1

[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at F:\Android\Sdk\
    • Platform android-32, build-tools 32.1.0-rc1
    • ANDROID_SDK_ROOT = F:\Android\Sdk\
    • Java binary at: E:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[✓] Android Studio (version 2021.1)
    • Android Studio at E:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822)

[✓] IntelliJ IDEA Ultimate Edition (version 2021.1)
    • IntelliJ at E:\Program Files\JetBrains\IntelliJ IDEA 2020.1
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[☠] Connected device (the doctor check crashed)
    ✗ Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know
      about this issue at https://github.com/flutter/flutter/issues.
    ✗ Exception: Unable to run "adb", check your Android SDK installation and ANDROID_SDK_ROOT environment variable:
      F:\Android\Sdk\platform-tools\adb.exe
    • #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
      #1      AndroidDevices.pollingGetDevices (package:flutter_tools/src/android/android_device_discovery.dart:75:7)
      <asynchronous suspension>
      #2      PollingDeviceDiscovery._populateDevices (package:flutter_tools/src/device.dart:413:54)
      <asynchronous suspension>
      #3      Future.wait.<anonymous closure> (dart:async/future.dart)
      <asynchronous suspension>
      #4      DeviceManager.getAllConnectedDevices (package:flutter_tools/src/device.dart:170:40)
      <asynchronous suspension>
      #5      DeviceValidator.validate (package:flutter_tools/src/doctor.dart:515:34)
      <asynchronous suspension>
      #6      asyncGuard.<anonymous closure> (package:flutter_tools/src/base/async_guard.dart:111:24)
      <asynchronous suspension>


! Doctor found issues in 1 category.

@timaskraft
Copy link

Having the same issue. Creating a separate user account and running it there worked, but it still won't work on my primary user.

[✓] Flutter (Channel stable, 2.8.1, on Microsoft Windows [Version 10.0.19044.1503], locale en-NZ)
    • Flutter version 2.8.1 at F:\Android\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 77d935af4d (7 weeks ago), 2021-12-16 08:37:33 -0800
    • Engine revision 890a5fca2e
    • Dart version 2.15.1

[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at F:\Android\Sdk\
    • Platform android-32, build-tools 32.1.0-rc1
    • ANDROID_SDK_ROOT = F:\Android\Sdk\
    • Java binary at: E:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[✓] Android Studio (version 2021.1)
    • Android Studio at E:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822)

[✓] IntelliJ IDEA Ultimate Edition (version 2021.1)
    • IntelliJ at E:\Program Files\JetBrains\IntelliJ IDEA 2020.1
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[☠] Connected device (the doctor check crashed)
    ✗ Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know
      about this issue at https://github.com/flutter/flutter/issues.
    ✗ Exception: Unable to run "adb", check your Android SDK installation and ANDROID_SDK_ROOT environment variable:
      F:\Android\Sdk\platform-tools\adb.exe
    • #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
      #1      AndroidDevices.pollingGetDevices (package:flutter_tools/src/android/android_device_discovery.dart:75:7)
      <asynchronous suspension>
      #2      PollingDeviceDiscovery._populateDevices (package:flutter_tools/src/device.dart:413:54)
      <asynchronous suspension>
      #3      Future.wait.<anonymous closure> (dart:async/future.dart)
      <asynchronous suspension>
      #4      DeviceManager.getAllConnectedDevices (package:flutter_tools/src/device.dart:170:40)
      <asynchronous suspension>
      #5      DeviceValidator.validate (package:flutter_tools/src/doctor.dart:515:34)
      <asynchronous suspension>
      #6      asyncGuard.<anonymous closure> (package:flutter_tools/src/base/async_guard.dart:111:24)
      <asynchronous suspension>


! Doctor found issues in 1 category.

Check if mobile hotspot is enabled, if it is enabled turn it off and restart android studio. I had a problem with this.

@ElhassanGhannmi
Copy link

For Me.
The problem is the antivirus program. It denied access to starting the flutter daemon on port 5037. I disabled/exited the antivirus program. Then it works.

@yuguansu
Copy link

set up environment variable in .bashrc or .zshrc

# replace the user name of  apple
export PATH="/Users/apple/flutter/bin:$PATH"
export ANDROID_HOME="/Users/apple/Library/Android/sdk"
export ANDROID_SDK_ROOT="/Users/apple/Library/Android/sdk"
export ANDROID_AVD_HOME="/Users/apple/.android/avd"
export PATH="$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/platform-tools:$PATH"

! important then reboot your system

It works!
Important to reboot!

@christopherfujino
Copy link
Member

I think the action item for this bug is to differentiate between failing to find adb binary and we ran adb, but it failed. In the latter case, we should surface to the user adb's STDERR.

@christopherfujino christopherfujino added the P2 Important issues not at the top of the work list label Jun 6, 2022
@YongXinMON
Copy link

PS D:\FLUTTER PROJEK\New folder\Pertemuan 13> flutter devices
Unable to run "adb", check your Android SDK installation and ANDROID_SDK_ROOT environment variable: C:\platform-tools\adb.exe

PS D:\FLUTTER PROJEK\New folder\Pertemuan 13> flutter doctor -v
[√] Flutter (Channel stable, 3.0.2, on Microsoft Windows [Version 10.0.19043.1706], locale en-ID)
• Flutter version 3.0.2 at C:\flutter\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision cd41fdd (2 weeks ago), 2022-06-08 09:52:13 -0700
• Engine revision f15f824b57
• Dart version 2.17.3
• DevTools version 2.12.2

Checking Android licenses is taking an unexpectedly long time...[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at C:
• Platform android-32, build-tools 30.0.3
• Java binary at: C:\Program Files\Java\jdk-11.0.14\bin\java
• Java version Java(TM) SE Runtime Environment 18.9 (build 11.0.14+8-LTS-263)
• All Android licenses accepted.

[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[X] Visual Studio - develop for Windows
X Visual Studio not installed; this is necessary for Windows development.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components

[!] Android Studio (not installed)
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).

[√] VS Code (version 1.68.1)
• VS Code at C:\Users\XiM0N\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.42.0

[☠] Connected device (the doctor check crashed)
X Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at
https://github.com/flutter/flutter/issues.
X Exception: Unable to run "adb", check your Android SDK installation and ANDROID_SDK_ROOT environment variable: C:\platform-tools\adb.exe
• #0 throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
#1 AndroidDevices.pollingGetDevices (package:flutter_tools/src/android/android_device_discovery.dart:75:7)

#2 PollingDeviceDiscovery._populateDevices (package:flutter_tools/src/device.dart:435:54)

#3 Future.wait. (dart:async/future.dart:521:21)

#4 DeviceManager.getAllConnectedDevices (package:flutter_tools/src/device.dart:191:40)

#5 DeviceValidator.validate (package:flutter_tools/src/doctor.dart:561:34)

#6 Future.any.onValue (dart:async/future.dart:611:5)

[√] HTTP Host Availability
• All required HTTP hosts are available

! Doctor found issues in 3 categories.

@HeyItsJono
Copy link

For me (on Windows), the adb daemon was unable to start (when trying adb devices). Doing the following via an Admin CMD worked: net stop winnat, then net start winnat. Then try again.

@flowerlake

This comment was marked as duplicate.

@abidurrn
Copy link

I have windows 7 and when open android studio, showing this message at the left corner "unable to detect adb version error code 0xc0000005"

how to fix this, kindly give me suggestions.

@luoqiang110
Copy link

had the them issue, the solution is as follows:

https://www.geeksforgeeks.org/fix-unable-to-locate-adb-within-sdk-in-android-studio/

@LeoAndo
Copy link

LeoAndo commented Feb 17, 2023

I suddenly had the same problem.

I deleted /Users/$USER/Library/Android/sdk and re installed it.

  1. Rename /Users/$USER/Library/Android to /Users/$USER/Library/Android_not_work
  2. Uninstall Android Studio from JetBrains ToolBox
  3. Install Android Studio from JetBrains ToolBox
  4. You will be prompted to install /Users/$USER/Library/Android/sdk when you start Android Studio for the first time, so proceed with the installation.
  5. Delete Android_not_work directory.

@honzahajek
Copy link

I've tried and unfortunately that doesn't help either. I ran it on a second computer where I have windows 10.

@himanshuMaheshwari2311
Copy link

All the solutions mentioned above doesn't work on windows 11
I can't use my old laptop anymore and don't want to downgrade windows version just for flutter.

Anyone else able to get around this on windows 11?

@tomesparon
Copy link

For me (on Windows), the adb daemon was unable to start (when trying adb devices). Doing the following via an Admin CMD worked: net stop winnat, then net start winnat. Then try again.

this worked for me after flutter upgrade changed things

@ghost
Copy link

ghost commented Apr 1, 2024

For Me. The problem is the antivirus program. It denied access to starting the flutter daemon on port 5037. I disabled/exited the antivirus program. Then it works.

this one work for me, thanks a lot

@adetorodev
Copy link

I have gone through all suggestion and I still have the same problem:

[✓] Flutter (Channel stable, 3.22.1, on Ubuntu 22.04.4 LTS 6.5.0-41-generic,
    locale en_NG)
    • Flutter version 3.22.1 on channel stable at
      /home/adetorodev/snap/flutter/common/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision a14f74ff3a (6 weeks ago), 2024-05-22 11:08:21 -0500
    • Engine revision 55eae6864b
    • Dart version 3.4.1
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /home/adetorodev/Android/Sdk
    • Platform android-34-ext8, build-tools 34.0.0
    • ANDROID_HOME = /home/adetorodev/Android/Sdk
    • ANDROID_SDK_ROOT = /home/adetorodev/Android/Sdk
    • Java binary at: /snap/android-studio/157/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.10+0-17.0.10b1087.21-11572160)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 10.0.0-4ubuntu1
    • cmake version 3.16.3
    • ninja version 1.10.0
    • pkg-config version 0.29.1

[✓] Android Studio (version 2023.3)
    • Android Studio at /snap/android-studio/157
    • Flutter plugin version 80.0.1
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      17.0.10+0-17.0.10b1087.21-11572160)

[✓] IntelliJ IDEA Ultimate Edition (version 2024.1)
    • IntelliJ at /snap/intellij-idea-ultimate/510
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.90.1)
    • VS Code at /usr/share/code
    • Flutter extension version 3.90.0

[☠] Connected device (the doctor check crashed)
    ✗ Due to an error, the doctor check did not complete. If the error message
      below is not helpful, please let us know about this issue at
      https://github.com/flutter/flutter/issues.
    ✗ Error: Unable to run "adb", check your Android SDK installation and
      ANDROID_HOME environment variable:
      /home/adetorodev/Android/Sdk/platform-tools/adb
    • #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
      #1      AndroidDevices.pollingGetDevices
      (package:flutter_tools/src/android/android_device_discovery.dart:75:7)
      <asynchronous suspension>
      #2      PollingDeviceDiscovery._populateDevices
      (package:flutter_tools/src/device.dart:547:36)
      <asynchronous suspension>
      #3      Future.wait.<anonymous closure> (dart:async/future.dart:524:21)
      <asynchronous suspension>
      #4      DeviceManager.refreshAllDevices
      (package:flutter_tools/src/device.dart:217:40)
      <asynchronous suspension>
      #5      DeviceValidator.validate
      (package:flutter_tools/src/doctor.dart:741:34)
      <asynchronous suspension>
      #6      Future.any.onValue (dart:async/future.dart:618:5)
      <asynchronous suspension>


[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

@bunny-pu
Copy link

bunny-pu commented Jul 8, 2024

same issue

@MomsSpughetti
Copy link

I encountered the same problem in Ubuntu 22.04.4, using vs code, after connecting my smartphone using a type-c cable.
It immediately shows a message saying:
Flutter daemon has terminated.

For me the solution was as follows:

step 1:

go to the location of adb executable file
mine was in: ~/Android/sdk/platform-tools

step 2:

then - in terminal after navigating to the previous location - run sudo ./adb devices

step 3:
The previous command will trigger a message on your phone asking you to authorize debugging
Check the 'Always allow' box
then proceed.

step 4:
Congrats, now the problem is gone.

@slefter
Copy link

slefter commented Jul 10, 2024

I had the same problem after upgrading Android Studio. I'm using Windows 10.
What helped me was to uninstall and re-install Android-SDK Platform-Tools.

(1)
In Android Studio, open SDK Manager.
Open SDK Tools.
Uncheck ⬜ Android-SDK Platform-Tools.
Apply changes.
Check that C:\Users\Username\AppData\Local\Android\Sdk folder was deleted (normally it should).
Go back to Android Studio and check ✅ Android-SDK Platform-Tools.
Apply changes

(2)
Reboot the system (required)

After this, flutter doctor should report OK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: crash Stack traces logged to the console P2 Important issues not at the top of the work list platform-windows Building on or for Windows specifically t: flutter doctor Problem related to the "flutter doctor" tool team-tool Owned by Flutter Tool team tool Affects the "flutter" command-line tool. See also t: labels. triaged-tool Triaged by Flutter Tool team
Projects
Tools - Android review
  
Engineer reviewed
Development

No branches or pull requests