flutter-intellij icon indicating copy to clipboard operation
flutter-intellij copied to clipboard

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

Open mit-mit opened this issue 7 years ago • 39 comments

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 avatar Nov 22 '17 16:11 mit-mit

From @Hixie on November 14, 2017 23:20

cc @devoncarew

mit-mit avatar Nov 22 '17 16:11 mit-mit

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 avatar Nov 22 '17 16:11 mit-mit

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 avatar Nov 22 '17 16:11 mit-mit

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 avatar Nov 22 '17 16:11 mit-mit

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

mit-mit avatar Nov 22 '17 16:11 mit-mit

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

pawelkw avatar Nov 22 '17 16:11 pawelkw

@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?

mit-mit avatar Nov 22 '17 16:11 mit-mit

@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

tomnta avatar Nov 22 '17 20:11 tomnta

Thanks for confirming!

mit-mit avatar Nov 23 '17 09:11 mit-mit

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.

pawelkw avatar Nov 23 '17 19:11 pawelkw

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.

anaisbetts avatar Dec 30 '17 05:12 anaisbetts

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 avatar Feb 21 '18 17:02 stevemessick

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.

kenneth-g-flux avatar Feb 27 '18 11:02 kenneth-g-flux

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.

fahmifan avatar Feb 28 '18 04:02 fahmifan

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!

kenneth-g-flux avatar Feb 28 '18 08:02 kenneth-g-flux

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.

slhartley avatar Mar 02 '18 06:03 slhartley

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.

Keats avatar Mar 08 '18 13:03 Keats

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.

cisko3000 avatar Mar 23 '18 00:03 cisko3000

@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!

devoncarew avatar Mar 23 '18 02:03 devoncarew

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

antempus avatar Mar 23 '18 14:03 antempus

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.

guilhermekrz avatar Apr 21 '18 01:04 guilhermekrz

The same problem image image image

MacOS 10.13.4 AndroidStudio 3.1.1

zhaozeyx avatar Apr 24 '18 01:04 zhaozeyx

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.

campanoon avatar May 05 '18 22:05 campanoon

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

akash1202 avatar May 10 '18 12:05 akash1202

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

Choxmi avatar May 13 '18 04:05 Choxmi

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

akash1202 avatar May 14 '18 06:05 akash1202

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

omidraha avatar Jun 07 '18 18:06 omidraha

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

intra avatar Jun 14 '18 06:06 intra

@akash1202 it work!

zdRan avatar Jun 25 '18 07:06 zdRan

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.

kakateeya avatar Jul 09 '18 07:07 kakateeya