[android] flutter run: No connected devices

I am trying to create a sample application with flutter (fresh installation) android studio is also installed (fresh installation)

Here is the output of flutter run

flutter run  
No connected devices.

the output of flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[?] Flutter (Channel beta, v0.1.5, on Linux, locale en_US.UTF-8)
[?] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[?] Android Studio (version 3.0)
[!] VS Code (version 1.20.1)
[!] Connected devices
! No devices available

! Doctor found issues in 2 categories.

Is there a solution to this problem?

The answer is


In case you want to test you app on your physical device via WiFi:

1.) Connect your device via USB (make sure developer options and USB debugging is enabled) 2.) Type in your Android Studio terminal: adb tcpip 5555 3.) Remove USB connection 4.) Type in your Android Studio terminal: adb connect <ip address of your device>

Alternatively, you can use WiFi ADB extension for Android Studio. I don't know any similar extension for VS Code.


If you have already installed and set-up your emulator, but facing the issue during running your app, You can try these steps to fix this issue.

Steps:

  1. Open Android Studio
  2. Tools -> AVD Manager
  3. Virtual Device -> Actions (Refer Image)
  4. Click On Stop
  5. Now Start Emulator

Note - If it's still not working, Try again the 4th step By Wiping your data.

Hope this works 4 you ;)


STEP 1: To check the connected devices, run: flutter devices

STEP 2: If there are no connected devices to see the list of available emulators, run: flutter emulators

STEP 3: To run an emulator, run: flutter emulators --launch <emulator id>

STEP 4: If there is no available emulator, run: flutter emulators --create [--name xyz]

==> FOR ANDROID:

STEP 1: To check the list of emulators, run: emulator -list-avds

STEP 2: Now to launch the emulator, run: emulator -avd avd_name

==> FOR IOS:

STEP 1: open -a simulator

STEP 2: flutter run (In your app directory)

I hope this will solve your problem.


If there is a problem with ADB Interface driver:

enter image description here

Try to find an appropriate driver on manufacturer's web-site. For Intel read this Installing the Android Debug Bridge (ADB) USB Driver on a Windows Computer.


If your device was already connected successfully, and just suddenly stopped being recognized by flutter devices (and Android Studio for that matter), this worked for me:

  • Turn USB debugging OFF
  • Turn USB debugging back ON

Yup. This worked. For me.


I had an emulator running but the VSC ide could not connect to it. So I enabled developer mode in the emulator and the debugging options as well. Voila, It worked!


In my case, flutter devices showed my device correctly and flutter run worked as expected. but the device is not shown in Android Studio.

Here is my sulotion:

in my .bash_profile ,the Android SDK configed like this:

export ANDROID_SDK_ROOT="~/Library/Android/sdk"

seems flutter plugin can not recgize the ~, so I changed it to this way:

export ANDROID_SDK_ROOT="/Users/charliema/Library/Android/sdk"

reopen the Android Studio, it worked.


Try running android studio as administrator if your flutter sdk location is in the C Drive


I am using Linux so here are the step can help. First open studio with root permission, (window : Right-click the program icon > Choose Run As Administrator, linux : sudo ./studio.sh in terminal)

Create emulator with Hardware - GLES 2.0 in hardware acceleration as mentioned here. Open terminal in android studio (Alt+F12)

Run command flutter devices and see the list devices

root@abc-OptiPlex-3050:~/flutter_workspace/my_app/my_app# flutter devices
   Woah! You appear to be trying to run flutter as root.
   We strongly recommend running the flutter tool without superuser privileges.

1 connected device:

Android SDK built for x86 • emulator-5554 • android-x86 • 
Android 8.1.0 (API 27)(emulator)

Finally run from terminal flutter run

root@abc-OptiPlex-3050:~/flutter_workspace/my_app/my_app# flutter run
   Woah! You appear to be trying to run flutter as root.
   We strongly recommend running the flutter tool without superuser privileges.


Using hardware rendering with device Android SDK built for x86. 
If you get graphics artifacts, consider enabling software rendering 
with "--enable-software-rendering".
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...                                       0.7s
Resolving dependencies...                                    1.2s
Running 'gradlew assembleDebug'...                           1.5s
Built build/app/outputs/apk/debug/app-debug.apk.
I/FlutterActivityDelegate(25096): onResume setting current activity to this
Syncing files to device Android SDK built for x86...             
D/        (25096): HostConnection::get() New Host Connection established 
0xe8487780, tid 25116
D/EGL_emulation(25096): eglMakeCurrent: 0xe5b3d8a0: ver 2 0 (tinfo 0xe84832f0)

  To hot reload changes while running, press "r". To hot restart (and 
rebuild state),press "R".An Observatory debugger and profiler on 
Android SDK built for x86 is available at: http://127.0.0.1:8100/
For a more detailed help message, press "h". To quit, press "q".

And do check flutter-sdk path in your project.Configure from this answer


This is my Solution. First Connect the Device to the Laptop and in mobile Open Settings of the smartphone and search for Developer Options and click on it and Enable USB Debugging on your device. Then Open the project and open the terminal and type "flutter run" By doing so your device is recognized. Then Setup your Android Emulator. In Android Studio, at the top, there will be no devices option and click on that and proceed to select your device and wait for a few minutes and you can see your app on your smartphone or on the emulator as per your selected Android Emulator.


One option that I haven't see mentioned so far is that (for my setup) the Developer Option 'Select USB Configuration' must be set to MTP (Media Transfer Protocol).


There should be at least one device/Simulator connected to run Flutter applications.

Also make sure the USB debugging is enabled in developer settings.


  1. Please check if you have two Android versions installed, if yes uninstall it as two versions can’t run at the same time.
  2. Also, you may try to set android-sdk in the flutter config where you can deploy directly to devices from Android Studio

Check adb is running or not if not run using the below command

adb start server than adb devices

if adb is not installed in your machine, install it and run commands again.


I am facing the same issue with Flutter. But I found another way to work i.e.

  1. First run Android Emulator
  2. Then go to your Flutter Console
  3. Run the command flutter doctor & check whether your emulator is showing under connected devices tag e.g. enter image description here

  4. Now move to your Flutter project path via Flutter console e.g. for me it is D:\FlutterWorkspace\flutter_demo

  5. Then run flutter run command. e.g.

enter image description here

Wait for few moments you will see your app running into Android Emulator. enter image description here


This was my solution. Hope my confusion can help someone else too:

My "Developer Options" was ON,

but the "USB Debbugging" was OFF.

So I turned ON the USB Debbugging and the problem was solved.


in iOS with mac, when i got this error, this works for me :

open -a simulators flutter run


I solved the problem after changing "ANDROID_HOME" to the Environment variables and setting it to the location of your android SDK..in my case C:\Android\Sdk


Flutter needs a device to run the app. There are two choices for this.

  1. Run the app on your real phone.
  2. Run the app on a virtual device in your computer.

I would recommend Option 1 because it doesn't use your device resources and is faster.

Option 1:

Unlock developer options on your phone, go to developer setting and turn on USB debugging and connect your phone to your computer. Now run flutter run and it will work.

Option 2:

Open android studio, go to AVD manager, Add a virtual device if you haven't done that yet & run the virtual device. Now run flutter run again and it should work.

Note that this way works with any virtual device and not just virtual device from android studio.


Just my case. I haven't found this solution among the answers.

System

Android 10 device.

Mac with MacOS Mojave 10.14.6 (18G4032).

Developer options and USB debugging were enabled on my Android device.

Flutter SDK was installed on my Mac.

Problem

When the Android device had been connected to my Mac with the USB cable the flutter devices command still stated: No devices available.

Solution

Fortunately, my Android device showed me the popup with the suggestion to install Android File Transfer to my Mac.

After installing the Android File Transfer to my Mac the flutter devices command showed my Android device as connected.

Hope this helps someone.


What I needed to do:

flutter emulators

It will list all available emulators. For iOS you will need to open simulator first.

flutter emulators --launch EMULATOR NAME

This will launch the emulator

And to build it

flutter run -d "EMULATOR ID"

NOTE: I am using Mi(Xiaomi) mobile (Redmi K20 Pro) which is running on Android 10

You need to do 2 things to show your device listing.

1) Go to your Android Studio --> File --> Project Structure and choose Project SDK from the options. I chose the latest one from the menu.

2) When you connect your real device to your PC/Laptop, make sure you choose Transfer photos (PTP) mode.

NOTE: DON'T CHOOSE File transfer mode. It will not work.

After doing the above 2 things, you can check the status of your device availability by writing flutter devices on command prompt.

I hope it shows your mobile device.


You could try

flutter emulators to show a list of already created emulators.

Today this shows me the two emulators in the list below.

Nexus_6_API_27 • Nexus 6 API 27 • Google • android

Pixel_2_API_27 • Pixel 2 API 27 • Google • android

You can then use something like

flutter emulators --launch Nexus_6_API_2 to start the emulator of choice

You can then use flutter run to test your app.

I use VSCode and tend to do use this approach which saves me having to load Android Studio to launch an emulator.

I hope this helps.


If the emulator is running and is not being detected by the flutter and adb devices then try connecting it manually by using the following command

abd connect 127.0.0.1:62001

If it fails to connect, try again. The following message should appear

connected to 127.0.0.1:62001

Then try flutter doctor or adb devices to make sure it has been connected successfully.


I have same problems while I was debugging with local flutter engine. In such case, if you have set environment variable FLUTTER_ENGINE, you should unset it and restart you IDE.


For me it was

  1. adding "ANDROID_HOME" to the Environment variables and setting it to D:\dev\android\ (for me)

  2. adding "D:\dev\android\platform-tools" (for me) to Path I put flutter there before

  3. Ok, Ok, Ok Restart Android studio


I found that my antivirus(Avast) had quarantined the adb.exe file. I went to Avast -> protection -> virus chest. Removed the adb.exe file from the list.

Then added the Android_home variable + added it to the path variable. Restarted my machine and Android Studio picked up the device/emulator.


While using in windows 7, I had received an error: unable to install device drivers. And the device wasn't recognised.

You need to also install Android OEM device driver for the particular device, just like mentioned here.

I downloaded driver for device from the manufacturer's website and installed driver from device manager.


If you have

  • Downloaded the flutter SDK
  • Connected your mobile device and enabled the developer option on the mobile and allowed USB debugging.

And still you are getting "No device connected" then i think you should install ADB driver. It worked for me!! Click here to download


For window user,

Set environment variable of Flutter SDK(...\flutter_windows_v0.2.8-beta.zip\flutter\bin)

No device connect

For more information, you can check here http://www.developerlibs.com/2018/05/flutter-introduction-and-setup.html

Here is the info from the mentioned page: Add Flutter to Windows Environment variable Path

  1. Navigate in to Flutter SDK folder.
  2. Go inside to bin folder and copy the directory path (in your case C:\Flutter\bin)
  3. Go to “Control Panel > User Accounts > User Accounts > Change my environment variables”
  4. Under “User variables” select path variable and click edit.
  5. Put C:\Flutter\bin and apply.

Same as Flutter Environment, we have to set the Android SDK path if it is on custom location.

  1. Navigate into the Android SDK folder.
  2. Copy the directory path (in your case ..AndroidStudioSDK\sdk)
  3. Go to “Control Panel > User Accounts > User Accounts > Change my environment variables”
  4. Under “User variables” select path variable and click edit.
  5. Put ..AndroidStudioSDK\sdk with ANDROID_HOME and apply.

Tips:

If you facing the following issue,

1.[?] Android toolchain - develop for Android devices ? Unable to locate Android SDK. Install Android Studio from https://developer.android.com/studio/index.html On the first launch, it will assist you in installing the Android SDK components. (or visit https://flutter.io/setup/#android-setup for detailed instructions).

If Android SDK has been installed to a custom location, set $ANDROID_HOME to that location.

You can resolve it with the following command.

flutter config --android-sdk <android-sdk-location> OR flutter config --android-sdk "android-sdk-location"

  1. Error: Unknown argument --licenses

You can resolve it with Following Command.

flutter -v doctor --android-licenses

Now, Pick the emulator you want to use and click the green arrow to run the project. So, here default screen that is already designed.


I recently face the same problem, I am using mac os and ios simulator. flutter devices command shows No devices detected.

flutter devices command

Then i run the flutter doctor command and it says my xcode installation is incomplete,

But its not true(i verify it by building native ios app and it runs well)!

flutter doctor command

I didn't reinstall/download xcode again, just run that two commands according to their suggestions

sudo xcode-select --switch /Applications/Xcode.app/Contacts/Developer
sudo xcodebuild -runFirstLaunch

And it solves my problem. Here is the final flutter doctor command output. Hope this will be helpful for someone.

flutter doctor command


For window user,

The solution for me was running Android Studio as administrator


This was my solution. Hope my confusion can help someone else too:

My "Developer Options" was ON,

but the "USB Debbugging" was OFF.

So I turned ON the USB Debbugging and the problem was solved.


Setting the Environment System variable:

Variable Value ANDROID_HOME D:\Android_Sdk\Sdk (your path)


It basically needs a device "connected" to your development machine. If you're using a simulator/emulator running on the machine it should automatically be recognised as a connected device. Another way is to connect a physical device and the setup process varies slightly for Android and iOS devices.


open the termina in vs-code, write the below commands:

flutter devices

flutter daemon -v

after that connect using cmd

cd (adb folder)

adb tcpip 4455
adb connect 192.168.1.11:4455 (user your device IP)

None of the suggestions worked until I ran:

flutter config --android-sdk ANDROID_SDK_PATH

Use "PATH" = your path. For example:

flutter config --android-sdk C:\Users\%youruser%\AppData\Local\Android\Sdk

In Android Studio, you sometimes need to start the android emulator manually.

  1. In Android Studio, click on the android (AVD Manager) icon: enter image description here

  2. Start your android device. enter image description here

  3. Wait a few seconds and select your android device: enter image description here


flutter config --android-sdk ANDROID_SDK_PATH

OR

  • Device Not Found (When setup Flutter in android studio)
  • Project structure -> select latest ANDROID API in Project SDK

enter image description here


Follow these step:
File -> Project Structure -> Project SDK(Select the SDK Path in the Android SDK) -> OK

Make sure your device is connected to the PC.

Open GitBash and type: flutter devices. Then run your flutter app.It will work.


If you are using mobile,

  • Turn on your developer options.

  • Turn on USB debugging option


I ran mine with Genymotion, probably the best for Flutter.

Setting up is less painful and

Make sure setting ADB under

enter image description here

--YOUR ANDROID SDK PATH --

Mine is C:\Users\user\AppData\Local\Android\Sdk


This works for me:

Go to Settings > Developer options > Disable USB debugging > Re-enable USB debugging


No one here mentions to make sure the Android device is not connected as "Media device" As soon as I turned this off and set it to "Charging" it worked.

I obviously installed the USB driver through Android studio, and also went through a step of adding "adb" to my system path by adding the location of it to "PATH"


I'm using genymotion for testing apps I have same problem when i press the run button i face this error last two hours.. enter image description here

how to fixed this error just reinstall genymotion this error is gone.


Some times the issue is with the device connection and it's driver

if you already turned on the Developer Option and USB debugging and still unable to connect your Device

you must try this one as it's officially from GOOGLE.

Install OEM USB drivers :

https://developer.android.com/studio/run/oem-usb


The actual answer did not worked for me.

But setting ANDROID_HOME in you ~/.bash_profile and logout then login, make it work!

This may be an Android Studio issue since It is not setting this environment variable for the open projects.


just excute the below command in terminal before running

open -a Simulator

If you are using Windows, press Control+Alt+Delete and select Dart Task inside Android Studio & Click End Task . I tried many times it works.


In my case

File>Project Structure

select latest sdk

enter image description here


I was using Visual Studio Code in Mac and was trying to run the flutter code on my iPhone. The device was not showing up in the status bar. I fixed the issue by doing this in the Terminal:

rm -rf <flutter_repo_directory>/bin/cache
flutter doctor -v

This will basically clear all the cache data from the Flutter repository folder. So when you run flutter doctor it will download some files initially


I encounter the same problem as you did. It turns out that your device is not connected with your computer.

Note:

  • If you are using XCode, if both your computer and the device are using the same WIFI, you don't have to connect the device with the computer.
  • For Android, or iOS running under terminal command, if you are using command line to run this, you have to make sure they are connected via cables. Sharing the same WIFI does not work. Make sure your device is really connected.
  • Make sure you allowed USB Debugging on your android device.

If this still does not work, try to fire below command, where you can get richer info and details:

flutter run --verbose

None of the above solutions worked for me but I was able to solve it by invalidating catch and restarting my android studio:

File > Invalidate Catches / Restart...

I tried a lot of the recommended steps listed here but the only thing it helps me was this:

File -> Settings -> Language & Support -> Dart -->

Activate the checkbox "Enable Dart support for the project ..."

enter image description here


Well, This query has been answered, I just wanted to add that You can see connected devices if you start the simulator manually on MAC and Android emulator from AVD manager as well.


Sometimes you have everything perfect but the device is no longer authorized on ADB. In such cases you have ADB but It will not show you in connected devices.

Steps to Fix this issue

1. Check if authorized: Open terminal/cmd/PowerShell and write adb devices it will show you all connected devices to PC.

<ANDROID_SDK_HOME>\platform-tools>adb devices
List of devices attached
4df798d76f98cf6d        unauthorized

2. Revoke USB Debugging on phone

If the device is shown as unauthorized, go to the developer options on the phone and click "Revoke USB debugging authorization" (tested with JellyBean & Samsung GalaxyIII).

3. Restart ADB Server:

adb kill-server
adb start-server

4. Reconnect Device and run following command again : adb devices

Now it should display authorized.

5. Ready to go.

Now, open you editor Android Studio/Visual Studio Code and check if your device is showing in connected devices or not.

You can simply check that with flutter doctor command.


Basically there are 3 common causes for this problem:

1. You don't have the ADB drivers installed on your computer. Make sure you have the correct ADB drivers for your Android device installed on your PC.

Even if your computer reads your device, You may not have the ADB drivers installed, I recommend that you search and download the correct ADB drivers for your Android device from Google or download an ADB package. If you install an ADB and it doesn't work, try installing another ADB, as it is common that not all ADBs work.

If you're in Windows, when you've installed the correct ADB drivers, maybe the S.O. Run 'Windows Update' to complete the ADB installation.

2. Your device does not have debugger mode enabled. It depends on each version of Android, generally on your Android device you have to go to the configuration menu, then open the developer options and then activate the debugger mode and enable OEM unlocking and USB debugger. ALSO MAKE SURE YOU ALLOW THE DEVELOPER TO SIGN ON YOUR DEVICE

3. Incorrect cable or other physical problems. Sometimes the problems are caused by the data transfer cable, try using other cables.


I solved the AVD problem with the flutter using the Flutter console.

Step 1:

C: \ Users \ valer> flutter emulators
6 available emulators:

3.2_QVGA_ADP2_API_22 _-_ Lollipop • 3.2in QVGA (ADP2) • Generic • 3.2 QVGA (ADP2) API 22 - Lollipop
Android_ARMv7a
Android_Accelerated_x86
Nexus S API Google Nexus S API 23
Nexus_S_API_25_1080x1920_Nougart_7.1.1_ • pixel • Google • Nexus S API 25 1080x1920 (Nougart 7.1.1)
Pixel_API_28 • pixel • Google • Pixel API 28

To run an emulator, run flutter emulators --launch <emulator id>.

Step 2:

C: \ Users \ valer> flutter emulators --launch Pixel_API_28

I had the same issue. Setting up the Android SDK is also a correct answer. But this is very simple -

  1. Import an android project to a new Android studio window.
  2. Close your current Flutter project Android studio window.
  3. Import that Flutter project to new Android Studio window.

Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to android-studio

A failure occurred while executing com.android.build.gradle.internal.tasks "Failed to install the following Android SDK packages as some licences have not been accepted" error Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util This version of Android Studio cannot open this project, please retry with Android Studio 3.4 or newer WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()' Flutter plugin not installed error;. When running flutter doctor ADB.exe is obsolete and has serious performance problems Android design support library for API 28 (P) not working Flutter command not found How to find the path of Flutter SDK

Examples related to android-emulator

flutter run: No connected devices How to remove the Flutter debug banner? Android Studio AVD - Emulator: Process finished with exit code 1 Android Studio Emulator and "Process finished with exit code 0" Run react-native on android emulator ERROR Android emulator gets killed Error while waiting for device: Time out after 300seconds waiting for emulator to come online Unfortunately Launcher3 has stopped working error in android studio? updating Google play services in Emulator Android Studio emulator does not come with Play Store for API 23

Examples related to ios-simulator

The iOS Simulator deployment targets is set to 7.0, but the range of supported deployment target version for this platform is 8.0 to 12.1 flutter run: No connected devices Error Running React Native App From Terminal (iOS) How to uninstall downloaded Xcode simulator? Capture iOS Simulator video for App Preview iPhone 6 Plus resolution confusion: Xcode or Apple's website? for development How to enable native resolution for apps on iPhone 6 and 6 Plus? How to access iOS simulator camera Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost." Document directory path of Xcode Device Simulator

Examples related to flutter

Flutter Countdown Timer How to make an AlertDialog in Flutter? FlutterError: Unable to load asset Set the space between Elements in Row Flutter Flutter: RenderBox was not laid out Space between Column's children in Flutter How to change status bar color in Flutter? How can I add shadow to the widget in flutter? Flutter - The method was called on null Flutter- wrapping text