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

Android Studio 3.0 with Flutter & Dart plugin not recognizing USB or virtual devices when clicking Play #1525

Open
mit-mit opened this issue Nov 22, 2017 · 39 comments

Comments

@mit-mit
Copy link
Member

mit-mit commented Nov 22, 2017

From @tomnta on November 14, 2017 19:22

Steps to Reproduce

Run "Flutter Devices" in Windows 10 Command Prompt shows that a device is connected.

flutter devices
1 connected device:
SM N950U1 • ce06xxxxxxxx • android-arm • Android 7.1.1 (API 25)

However, pressing Run in Android Studio 3.x returns this error popup:

No connected devices found; please connect a device, or see flutter.io/setup for getting started instructions.

https://flutter.io/setup/ guides the user to this link https://flutter.io/setup-windows/#android-setup

And that page has no directions on how to setup the IDE to recognize that you have a device attached or to have it work with the virtual device.

The same error window pops up when you select a virtual device and press Play in Android Studio. However, pressing Play on an Android project works fine with virtual and USB devices.

Logs

Run your application with flutter run and attach all the log output.
Run flutter analyze and attach any output of that command also.

N/A. The command line tool works fine. The Android Studio plugin has issues.

Flutter Doctor

[√] Flutter (on Microsoft Windows [Version 10.0.14393], locale en-US, channel alpha)
• Flutter at C:\Users\Tom\flutter
• Framework revision e8aa40eddd (4 weeks ago), 2017-10-17 15:42:40 -0700
• Engine revision 7c4142808c
• Tools Dart version 1.25.0-dev.11.0

[√] Android toolchain - develop for Android devices (Android SDK 27.0.0)
• Android SDK at C:\Users\Tom\AppData\Local\Android\sdk
• Platform android-27, build-tools 27.0.0
• Java binary at: F:\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)

[√] Android Studio (version 3.0)
• Android Studio at F:\Android\Android Studio
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)

[√] Connected devices
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 8.1.0 (API 27) (emulator)

Flutter plugin version 19

Copied from original issue: flutter/flutter#13020

@mit-mit
Copy link
Member Author

mit-mit commented Nov 22, 2017

From @Hixie on November 14, 2017 23:20

cc @devoncarew

@mit-mit
Copy link
Member Author

mit-mit commented Nov 22, 2017

From @macfeaster on November 18, 2017 17:52

Just curious, have you configured the Flutter plugin in IntelliJ under the Languages & Frameworks section? If this configuration does not have the right Flutter installation path, the Flutter plugin will not be able to launch the app via Android Studio.

@mit-mit
Copy link
Member Author

mit-mit commented Nov 22, 2017

From @pawelkw on November 18, 2017 21:10

Same problem here. Same config as OP. Happens in both AS and IntelliJ IDEA CE.

@mit-mit
Copy link
Member Author

mit-mit commented Nov 22, 2017

The Flutter IDE plugin is expected to show the exact same list of devices as flutter devices does. If they don't, then that a bug. I'm going to port this bug over to the intellij specific tracker.

@mit-mit
Copy link
Member Author

mit-mit commented Nov 22, 2017

@pawelkw, just checking are you also on Windows? And also seeing the expected list of devices in flutter devices ?

@mit-mit mit-mit added this to the M20 milestone Nov 22, 2017
@pawelkw
Copy link

pawelkw commented Nov 22, 2017

@mit-mit No, I'm on a Mac with High Sierra,
Yes, all expected devices show up correctly in CLI using flutter devices.

@mit-mit
Copy link
Member Author

mit-mit commented Nov 22, 2017

@pawelkw, @tomnta, would you both mind trying to update to the 19.1 version of the plugin and see if the issue still repros there?

@tomnta
Copy link

tomnta commented Nov 22, 2017

@mit-mit You bet.. ok, updated to version 19.1 but it still doesn't work for me in Android Studio 3.0.1.

F:\Android-Workspace>flutter create my_app
Creating project my_app...
Wrote 64 files.

Running "flutter packages get" in my_app...           9.7s

[√] Flutter is fully installed. (on Microsoft Windows [Version 10.0.14393], locale en-US, channel alpha)
[√] Android toolchain - develop for Android devices is fully installed. (Android SDK 27.0.1)
[√] Android Studio is fully installed. (version 3.0)
[√] IntelliJ IDEA Community Edition is fully installed. (version 2017.2)
[√] Connected devices is fully installed.

All done! In order to run your application, type:

  $ cd my_app
  $ flutter run

Your main program file is lib/main.dart in the my_app directory.

flutter as3 issue

@mit-mit
Copy link
Member Author

mit-mit commented Nov 23, 2017

Thanks for confirming!

@pawelkw
Copy link

pawelkw commented Nov 23, 2017

Working for me now. Pulled repo + 19.1 plugin. Created new project in IntelliJ IDEA CE - devices show up correctly now. Project is deployed to selected device correctly. Mac High Sierra.

@pq pq modified the milestones: M20, M21 Dec 8, 2017
@anaisbetts
Copy link

anaisbetts commented Dec 30, 2017

I also experience this bug, but only on Windows, macOS works correctly. Same physical Android device on both machines, flutter run works on the Windows machine but AS 3.0.1 gets the dialog above.

As a possible clue, the dropdown will always be showing "Loading..." when you click it, I suspect that loading the list of devices is just never returning anything.

@devoncarew devoncarew modified the milestones: M21, M22 Jan 16, 2018
@devoncarew devoncarew changed the title Android Studio 3.0 with Flutter & Dart plugin not recognizing USB or virtual devices when clicking Play Ensure that flutter projects can be opened in Android Studio as well-formed Android Studio projects Jan 30, 2018
@stevemessick stevemessick changed the title Ensure that flutter projects can be opened in Android Studio as well-formed Android Studio projects Android Studio 3.0 with Flutter & Dart plugin not recognizing USB or virtual devices when clicking Play Feb 21, 2018
@stevemessick
Copy link
Member

Restored original title because projects generated by flutter run are well-formed. There may be an issue with device detection in Android Studio, but I am not able to reproduce the problem.

@stevemessick stevemessick modified the milestones: M22, M23 Feb 21, 2018
@kenneth-g-flux
Copy link

I had the same problem today. The device selector in the Android Studio toolbar wouldn't even show up, but the device was in the list of connected devices when running flutter doctor -v.
Yesterday everything worked fine.

I ran the app from the command line with flutter run and after that, the device showed up again in Android Studio and I could run from inside the editor.

@fahmifan
Copy link

What OS do you use ? I run in same problem, i'm using ubuntu 16.04 and android studio 3.0.1 . I can run it from terminal flutter run but when i click run button from android studio it didn't recognize my device.

@kenneth-g-flux
Copy link

I'm on a Windows 10 machine and also using Android Studio 3.0.1.

Here's my flutter doctor -v output:

[√] Flutter (Channel dev, v0.1.5, on Microsoft Windows [Version 10.0.16299.248], locale en-GB)
    • Flutter version 0.1.5 at D:\Coding\Tools\flutter
    • Framework revision 3ea4d06340 (6 days ago), 2018-02-22 11:12:39 -0800
    • Engine revision ead227f118
    • Dart version 2.0.0-dev.28.0.flutter-0b4f01f759

[√] Android toolchain - develop for Android devices (Android SDK 26.0.2)
    • Android SDK at C:\Program Files (x86)\Android\android-sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-27, build-tools 26.0.2
    • ANDROID_HOME = C:\Program Files (x86)\Android\android-sdk
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)

[√] Android Studio (version 3.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)

[√] Connected devices (1 available)
    • Nexus 6P • CVH7N15C21000893 • android-arm64 • Android 8.1.0 (API 27)

• No issues found!

@slhartley
Copy link

Windows 10 and AS3.0.1 Flutter plugin 22.2.1
My issue isn't that AVD devices are not listed, but cannot be selected to run.
Flutter Device Selection lists AVD devices and selecting one will start them, but then resets its selection back to a connected USB device or Android SDK built for X86 and will launch the app there. CLI "Flutter Devices" shows the launched AVD, and "Flutter Run" will also run on the launched AVD. For some reason the Flutter Device Selection button doesn't stay on the opened AVD selection and so Android Studio cannot run the app on the chosen AVD.

@Keats
Copy link

Keats commented Mar 8, 2018

Archinux and latest Flutter:

[✓] Flutter (Channel beta, v0.1.5, on Linux, locale en_GB.UTF-8)
    • Flutter version 0.1.5 at /home/vincent/Code/flutter
    • Framework revision 3ea4d06340 (2 weeks ago), 2018-02-22 11:12:39 -0800
    • Engine revision ead227f118
    • Dart version 2.0.0-dev.28.0.flutter-0b4f01f759

[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
    • Android SDK at /home/vincent/android-sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-27, build-tools 27.0.3
    • ANDROID_HOME = /home/vincent/android-sdk
    • Java binary at: /opt/android-studio/jre/bin/java
    • Java version openjdk version "1.8.0_152-release"

[✓] Android Studio (version 3.0)
    • Android Studio at /opt/android-studio
    • Java version openjdk version "1.8.0_152-release"

[✓] Connected devices (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 8.1.0 (API 27) (emulator)

• No issues found!

I can run flutter run just fine in the directory and it loads the default flutter app in the VM. Clicking the run or debug button in intellij gives: "Unable to locate a development device; please run 'flutter doctor' for information about installing additional components."
The Flutter plugin does find the SDK information.

I get the same message when I change the target to my Android phone.

@stevemessick stevemessick removed their assignment Mar 20, 2018
@devoncarew devoncarew modified the milestones: M23, On Deck Mar 21, 2018
@cisko3000
Copy link

For anyone that's having this problem, check your pubspec.yaml file. I had some invalid syntax and fixing that resulted in the Android device list appearing and letting me run my app. Maybe as a fix, can the plugin catch such bad syntax? I was able to catch it when I ran flutter through the terminal in my project folder.

@devoncarew
Copy link
Member

@cisko3000, that may not be the most common reason why users would see this error (typically, windows specific issues, PATH issues, or needing to restart Android Studio after some path dependency changes).

However, we do check the pubspec.yaml file to determine if the project is a flutter project, so fixing the syntax error is likely why the device list started showing up again (we then recognized it as a flutter project). Do you have an example of the broken version of the file? We can make the flutter pubspec detection more robust, or add additional analysis to show warnings for issues in the pubspec file. Thanks!

@antempus
Copy link

I've also been dealing with this issue. I had added the launcher for Android Studio via alacarte for budgie desktop so I didn't have to launch from a terminal, but when I went back to launching AS from terminal the issue went away.

The specific issue was when running flutter doctor link when on the pubspec.yaml, flutter couldn't find the SDK install location; it didn't have this issue any other time that I could tell, even from the built-in terminal. This is likely related to resolving $ANDROID_HOME when AS is running flutter itself.

Setup
Shell : ZSH, $ANDROID_HOME -> $HOME/dev/android/sdk
Flutter : v0.0.15
Android Studio : v3.0
OS: Ubuntu 16.04.04

@guilhermekrz
Copy link

Same problem here, Ubuntu 16.04; flutter doctor shows the device. But when opening Android Studio via the desktop shortcut it does nor recognize any connected device, only when I open it via CLI.

@zhaozeyx
Copy link

The same problem
image
image
image

MacOS 10.13.4
AndroidStudio 3.1.1

@campanoon
Copy link

Same problem here, XUbuntu 16.04. I can run the app via Terminal but in Android Studio nothing, It doesn't recognize any connected device.

@akash1202
Copy link

just run as administrator
cmd, powershell, android studio in windows
solved my problem...try it once!!!

@Choxmi
Copy link

Choxmi commented May 13, 2018

I had the same issue. @akash1202 solved the problem.

@akash1202
Copy link

akash1202 commented May 14, 2018

just add path of ANDROID_HOME(android sdk location)
in 1)system path as well as in 2)user's PATH will solve
problem of require run as administrator @Choxmi

@omidraha
Copy link

omidraha commented Jun 7, 2018

Same problem,
The sample app run via Terminal but in Android Studio doesn't recognize any connected device.

Ubuntu 18.04 LTS
Android Studio 3.1.3
Flutter Plugin Version: 25.0.1
Dart Plugin Version: 173.4700
Flutter 0.4.4 • channel beta 
     Framework • revision f9bb4289e9 (4 weeks ago) • 2018-05-11 21:44:54 -0700
     Engine • revision 06afdfe54e
     Tools • Dart 2.0.0-dev.54.0.flutter-46ab040e58

@intra
Copy link

intra commented Jun 14, 2018

The same problem on Linux Mint when starting Android Studio from GUI "Menu".
The problem solved by starting Android Studio from command line.

@zdRan
Copy link

zdRan commented Jun 25, 2018

@akash1202 it work!

@kakateeya
Copy link

I am having same issue. Mac High Sierra 10.13.5. flutter devices shows the device, but Android Studio (3.1.3) does not show (it says no devices). I have Dart plugin (173.4700), Flutter 26.0.1, flutter SDK path set correctly, $PATH has flutter and adb, $ANDROID_HOME is correct. adb devices lists the devices. AndroidStudio logcat shows the device and logs from device as well.
I started Android emulator just to check and it does not detect emulator either. But flutter emulators lists all AVDs I have. It just shows "Open iOS simulator" only in devices menu and I was able to run the app on iOS emulator.

@Montanajim
Copy link

I had the same issue while running on a Windows machine. I did the following:

  1. I made sure my AVD was running a x64 version.
  2. I ran Android studio in administrators mode.
    Between the two, this fixed my problem.

@Empdarknight
Copy link

i had the same issue while using flutter first time , i will tell how i solved it for window platform.

  1. first download zip file from https://flutter.io/docs/get-started/install/windows .
  2. create a folder inside c drive named src
  3. extract the downloaded file in this new src folder.
  4. now change the environment variable . please check screenshot to change environment variables
  5. run cmd using administrative write/
  6. type futter doctor -v , if there is no error then create a new flutter project.
  7. change drive in cmd for example to create a new project in D: drive just just D: and hit enter , after that you will be in D: drive.
  8. then type flutter create first_app(name of that project)
  9. now open that new project using android studio.
  10. now go to file->settings->languages and frameworks-> flutter and there change the path of sdk to C:\src\flutter.
  11. also change the dart sdk to C:\src\flutter\bin\cache\dart-sdk and click check box above it to enable dart supoort.
  12. and now restart your android studio, hope your could be solved , please aknowledge

flutter cmd to check
properties on pc
advance system settings
enviroment variables
path and edit
fluuterbin
flutter sdkjpg
dardsdk

@ElTopo
Copy link

ElTopo commented Dec 24, 2018

Just tried to install Android Studio and flutter on my Windows 10 Pro and Home laptops, created a basic flutter app.

When I click 'Run", I've got "No Connected Devices Found" pop up, "Flutter Device Selection" shows "< no devices >", click on the dropdown arrow, it shows "Loading..." (not sure it is actually loading device list or gets stuck), my connected device does not show up.

my "fullter doctor -v"

>flutter doctor -v
[√] Flutter (Channel stable, v1.0.0, on Microsoft Windows [Version
    10.0.17763.195], locale en-US)
    • Flutter version 1.0.0 at C:\Users\xxx\WinUtils\flutter
    • Framework revision 5391447fae (4 weeks ago), 2018-11-29 19:41:26 -0800
    • Engine revision 7375a0f414
    • Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

[√] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    • Android SDK at C:\Users\xxx\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling
      support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_152-release-1136-b06)
    • All Android licenses accepted.

[√] Android Studio (version 3.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 31.3.1
    • Dart plugin version 181.5656
    • Java version OpenJDK Runtime Environment (build
      1.8.0_152-release-1136-b06)

[√] Connected device (1 available)
    • Vivo 8 • ZLEAFI6SFE9DGAMJ • android-arm64 • Android 7.0 (API 24)

• No issues found!

I can use "flutter run"

>flutter run
Launching lib/main.dart on Vivo 8 in debug mode...
Initializing gradle...                                       4.6s
Resolving dependencies...                                    8.8s
Gradle task 'assembleDebug'...
Gradle task 'assembleDebug'... Done                          6.5s
Built build\app\outputs\apk\debug\app-debug.apk.
Syncing files to device Vivo 8...
D/GraphicBuffer(10558): register, handle(0x793dcc5d40) (w:1080 h:1920 s:1088 f:0x1 u:0x000b00)
D/OpenGLRenderer(10558): ProgramCache.generateProgram: 34359738369
I/SurfaceView(10558): updateWindow -- setFrame, this = io.flutter.view.FlutterView{d714505 VFED..... .F...... 0,0-1080,1920}
 3.0s

🔥  To hot reload changes while running, press "r". To hot restart (and rebuild
state), press "R".
An Observatory debugger and profiler on Vivo 8 is available at:
http://127.0.0.1:54392/
For a more detailed help message, press "h". To detach, press "d"; to quit,
press "q".

Besides flutter command, Android Studio's "Connection Assistant" also detected my device, Android Studio's logcat window even shows messages from my device.

However, I can't use Android Studio's "Run" command because it (i.e., flutter's plugin?) does not see my device and thus I can't choose my device in "Flutter Device Selection" droplist.

I treid some suggestions from replies of this issue (such as Run "Android Studio" as administrator), none of them fix the problem.

This happens on both of my Windows 10 laptops (Pro and Home).

Flutter team, please give us a solution for this issue, it's so frustrating.

@grevian
Copy link

grevian commented Feb 21, 2019

I also encountered this problem, I tried running as administrator, and setting ANDROID_HOME as suggested above and neither helped, eventually I resolved it by setting the flutter SDK path in Settings->Languages & Frameworks->Flutter which had come unset somehow, despite it being set during the plugin installation/initialization.

flutter-sdk

@ElTopo
Copy link

ElTopo commented Feb 26, 2019

Update: today I upgraded to Flutter version 1.2.1 and Android Studio (3.3) finally sees my device.
Not sure if this issue is really fixed, need more tests.

EDIT: too bad, the problem is back. "flutter doctor -v" shows a connected device, while Android Studio does NOT.

@vigneshwaranvelmurugan
Copy link

Once Restart your system or run this comment flutter run

@welshcathy
Copy link

I have this same issue intermittently on:
Android Studio 4.0
Build #AI-193.6911.18.40.6514223, built on May 20, 2020
Runtime version: 1.8.0_242-release-1644-b3-6222593 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.15.5
GC: ParNew, ConcurrentMarkSweep
Memory: 1237M
Cores: 12
Registry: ide.new.welcome.screen.force=true
Non-Bundled Plugins: Dart, com.google.services.firebase, com.intellij.plugins.vscodekeymap, com.samdark.intellij-visual-studio-code-dark-plus, io.flutter, org.intellij.plugins.markdown

Flutter plugin 46.0.2

I know Flutter paths etc are correct because the Flutter Target Selector does sometimes show all connected devices and matches what is seen by flutter devices.
But sometimes Flutter Target Selector is 'stuck' on 'Loading ...' even when Android Studio knows about the connected devices!

image

The only way I can get it to work is to restart Android Studio until it decides to pick up the devices correctly.

@zalox
Copy link

zalox commented Jun 10, 2022

This comment is for the Linux users facing this problem.

You are probably setting ANDROID_HOME, ANDROID_SDK_ROOT and DART_SDK etc. in .bashrc.

Set the variables in .profile instead and restart your computer (or load it manually, which is often harder than just restarting).

It seems like Android Studio does not start a shell in order to run. I'm guessing that JetBrains just run java with the system environment. Said easily, the system environment is the variables set by /etc/profile, and the files that this script includes, including .profile in the home directory.

Thanks to @intra s comment about the devices showing up in the command line but not from the GUI. This pointed me towards that the PATH is only set in the shell, but not in the system environment.

@Nashev
Copy link

Nashev commented Sep 2, 2022

I had the issue on Windows 10, my IntelliJ IDEA does not showed any Android emulators in the Devices combo box.
Thanks to antempus, adding an ANDROID_HOME variable to the windows environment solved this problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests