FULL STACK DEV
FULL STACK DEV

Reputation: 15951

Message "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?

Upvotes: 388

Views: 621710

Answers (30)

Jude Okoroafor
Jude Okoroafor

Reputation: 484

None of the above solutions worked for me, but I was able to solve it by invalidating caches and restarting my Android Studio:

Menu FileInvalidate Caches / Restart...

EDIT:::

To clear Android Studio’s cache and bring it out of its state of confusion

select ‘File > Invalidate Caches / Restart’ and then click the ‘Invalidate and Restart’ button.

Clean and rebuild your project.

Upvotes: 4

Karma
Karma

Reputation: 597

Exit and start Android Studio again can solve the issue.

Upvotes: 1

Pablo Chvx
Pablo Chvx

Reputation: 1931

This was my solution:

My "Developer Options" was ON, but the "USB Debugging" was OFF.

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

Upvotes: 89

Victor Odiah
Victor Odiah

Reputation: 1081

Solution most times is to enable Dart support on android studio. Preferences > Languages and framework > Dart

Ensure Dart support is enabled for your flutter project.

Upvotes: 1

Andrei Drynov
Andrei Drynov

Reputation: 8592

None of the suggestions worked until I ran:

flutter config --android-sdk ANDROID_SDK_PATH

Use "ANDROID_SDK_PATH" = your path. For example:

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

Upvotes: 57

ash
ash

Reputation: 1055

I encountered the same problem as you experienced. It turns out that your device is not connected to your computer. What I did was actually just

flutter emulators

then Specially perform a cold boot things will get back to their place most probably. All the Best coder.

Upvotes: 0

Kairat
Kairat

Reputation: 788

MacOS solution: I have scanned through all the answers and did find my solution. As far as I remember there was a problem with .bas_profile, .zshrc and other config files synchronization. So in order to make them synchronize run Android Studio from terminal, for example:

open /Applications/Android\ Studio\ 2.app

Upvotes: 0

IvanPavliuk
IvanPavliuk

Reputation: 1790

Android Studio -> Preferences -> Languages & Frameworks -> Dart

Make sure you enabled Dart support for the module (should be checked in)

enter image description here

Upvotes: 12

Iamat8
Iamat8

Reputation: 3906

I am using Linux and here are the steps that can help. First open Android Studio with root permissions, (Windows: Right-click the program icon → Choose Run As Administrator, Linux: sudo ./studio.sh in the terminal)

  1. Create emulator with Hardware - GLES 2.0 in hardware acceleration as mentioned here. Open a 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 flutter run from the terminal:

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 the flutter-sdk path in your project.Configure file from this answer.

  1. Set Project SDK of project from Project Structure

    File > Project Structure > Project SDK > "available sdk" > Apply

    set project sdk

Upvotes: 15

Krunal
Krunal

Reputation: 79656

Flutter supports both iOS and Android device/simulators.

In the terminal, run the flutter devices command to verify that Flutter recognizes your connected Android device.

Here is a reference document on how you can set up a device/simulator to run your application.

For, Android (on a Mac system)

Set up your Android device

To prepare to run and test your Flutter app on an Android device, you’ll need an Android device running Android 4.1 (API level 16) or higher.

  1. Enable Developer options and USB debugging on your device. Detailed instructions are available in the Android documentation.
  2. Using a USB cable, plug your phone into your computer. If prompted on your device, authorize your computer to access your device.
  3. In the terminal, run the flutter devices command to verify that Flutter recognizes your connected Android device.
  4. Start your app by running flutter run.

By default, Flutter uses the version of the Android SDK where your ADB tool is based. If you want Flutter to use a different installation of the Android SDK, you must set the ANDROID_HOME environment variable to that installation directory.

Set up the Android emulator

To prepare to run and test your Flutter app on the Android emulator, follow these steps:

  1. Enable VM acceleration on your machine.
  2. Launch Android Studio → menu ToolsAVD Manager and select Create Virtual Device.
  3. Choose a device definition and select Next.
  4. Select one or more system images for the Android versions you want to emulate, and select Next. An x86 or x86_64 image is recommended.
  5. Under Emulated Performance, select Hardware - GLES 2.0 to enable hardware acceleration.
  6. Verify the AVD configuration is correct, and select Finish.

For details on the above steps, see Managing AVDs.

  1. In Android Virtual Device Manager, click Run in the toolbar. The emulator starts up and displays the default canvas for your selected OS version and device.
  2. Start your app by running flutter run. The connected device name is Android SDK built for <platform>, where platform is the chip family, such as x86.

Open & Connect Device using Android Studio:

Here is an easier way to open and connect simulators/devices.

Android Studio shows a list of emulators/simulators (installed in your system) or devices (connected to your system). Just select a device you want to open from a list, and run the project.

Enter image description here

Upvotes: 284

crazyProgrammer
crazyProgrammer

Reputation: 386

Basically there are three 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 on Windows, when you've installed the correct ADB drivers, maybe the O.S. 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, activate the debugger mode, 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.

Upvotes: 0

Wesley Barnes
Wesley Barnes

Reputation: 671

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".

Upvotes: 0

O Thạnh Ldt
O Thạnh Ldt

Reputation: 1221

Setting the System environment variable:

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

Upvotes: 1

Utkarsh Singh
Utkarsh Singh

Reputation: 377

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

Steps:

  1. Open Android Studio
  2. Menu ToolsAVD Manager
  3. Virtual DeviceActions (Refer Image)
  4. Click on Stop
  5. Now start the emulator

Note - if it's still not working, try the 4th step again by wiping your data.

Upvotes: 1

Malek Tubaisaht
Malek Tubaisaht

Reputation: 1387

Open the terminal in Visual Studio Code, and 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 (use your device IP address)

Upvotes: 1

Eric Sison
Eric Sison

Reputation: 359

In case you want to test you app on your physical device via Wi-Fi:

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

Alternatively, you can use the Wi-Fi ADB extension for Android Studio. I don't know any similar extension for Visual Studio Code.

Upvotes: 0

MockerTim
MockerTim

Reputation: 2483

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

System

Android 10 device.

Mac with macOS v10.14.6 (Mojave, 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 on my Mac.

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

Upvotes: 0

Lahiru Liyanage
Lahiru Liyanage

Reputation: 75

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 a new Android Studio window.

Upvotes: 3

Vivek Gupta
Vivek Gupta

Reputation: 164

Just execute the below command in a terminal before running:

open -a Simulator

Upvotes: -4

IFTEKHAR I ASIF
IFTEKHAR I ASIF

Reputation: 395

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

Step 2: If there aren't any connected devices to see in 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)

Upvotes: 5

Ananta Prasad
Ananta Prasad

Reputation: 3859

Check ADB is running or not. If not, run using the below command:

adb start server

And then

adb devices

If ADB is not installed in your machine, install it and run commands again.

Upvotes: 0

Sai Tarun Kaniganti
Sai Tarun Kaniganti

Reputation: 115

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 set up your Android Emulator.

In Android Studio, at the top, there will be no devices option. Click on that and proceed to select your device, wait for a few minutes, and you can see your app on your smartphone or on the emulator as per your selected Android emulator.

Upvotes: 0

Robin
Robin

Reputation: 5427

I recently faced the same problem. I am using macOS and the iOS simulator. The 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 it's not true (I verify it by building native iOS app and it runs well)!

'flutter doctor' command

I didn't reinstall/download Xcode again. I just ran those 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.

'flutter doctor' command

Upvotes: 0

Tarun Sharma
Tarun Sharma

Reputation: 1008

If you are using Windows, press Control + Alt + Delete and select Dart Task inside Android Studio and click End Task.

I tried many times, and it works.

Upvotes: 0

Akshay Chopra
Akshay Chopra

Reputation: 1253

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

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

  1. Go to your Android Studio, menuFileProject Structure and choose the 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 two things, you can check the status of your device availability by writing flutter devices on the command prompt.

I hope it shows your mobile device.

Upvotes: 3

Arun
Arun

Reputation: 1411

I was using Visual Studio Code on a 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.

Upvotes: 2

Andrew Stevenson
Andrew Stevenson

Reputation: 658

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 Visual Studio Code and tend to do use this approach which saves me having to load Android Studio to launch an emulator.

Upvotes: 2

alter123
alter123

Reputation: 601

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

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

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

Upvotes: 0

Muhaiminur Rahman
Muhaiminur Rahman

Reputation: 3152

In my case

Menu FileProject Structure

Select the latest SDK:

Enter image description here

Upvotes: 38

Anilkumar Patel
Anilkumar Patel

Reputation: 2409

Use:

flutter config --android-sdk ANDROID_SDK_PATH

Or

  • Device Not Found (when setting up Flutter in Android Studio)
  • Project structure -> select latest Android API in Project SDK

Enter image description here

Upvotes: 229

Related Questions