Disclaimer: I am a newbie to using the emulators and flutter.
Question: How do I get flutter to connect to an emulator for debugging? Or, how do I create/set-up an emulated device properly so that my android studio flutter application recognizes it as a valid device?
I am not sure if it matters but I am currently working behind a proxy server. However, I have already added the appropriate certificates to the android ide.
The emulator I created is a Pixel 2, with API-28. I set it to allow developer options.
Using the new project part of the IDE I created a new flutter project in offline mode.
I expected the application to open in debug mode on my emulator but instead it says it doesn't think any device is connected. I ran flutter doctor and this is the output I received.
F:\SDKs\flutter_windows_v1.5.4-hotfix.2-stable\flutter\bin\flutter.bat doctor --verbose
[√] Flutter (Channel stable, v1.5.4-hotfix.2, on Microsoft Windows [Version 6.1.7601], locale en-US)
• Flutter version 1.5.4-hotfix.2 at F:\SDKs\flutter_windows_v1.5.4-hotfix.2-stable\flutter
• Framework revision 7a4c33425d (8 weeks ago), 2019-04-29 11:05:24 -0700
• Engine revision 52c7a1e849
• Dart version 2.3.0 (build 2.3.0-dev.0.5 a1668566e5)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
• Android SDK at C:\Users\SWahlin-Rhoades\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.0
• Java binary at: F:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
• All Android licenses accepted.
[√] Android Studio (version 3.4)
• Android Studio at F:\Program Files\Android\Android Studio
• Flutter plugin version 36.1.1
• Dart plugin version 183.6270
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
[!] Connected device
• Device emulator-5554 is not authorized.
You might need to check your device for an authorization dialog.
! Doctor found issues in 1 category.
Process finished with exit code 0
I am aware of the thread device-emulator-55-is-not-authorized-android however, it didn't solve my problem. Within the thread it doesn't specify what new AVD was created in the solution and the other option of turing on developer settings didn't work.
I took another look at the Device_emulator_5554 answer and attempted to create another emulator Nexus S API 28 and I can now use it for debugging.
Related
Steps to Reproduce
I'm not sure there is an exact way to reproduce this issue as it seems to happen at random instances when building or running the project on a physical device.
I hope this is the right place to post this.
Here is an outline of how it occurs.
I have looked at issue #36763 and its not resolving the issue.
You run a project on an ADB connected device. The app will successfully build and/or run on the devices.
Step 1 will randomly get stuck on assembling the project. This will not complete even if you wait for hours(tried it)
Ordinarily when you have a problem you will go for flutter clean . if you try this it gets also stuck for hours with no completion.
Upon inspecting this you find a file in your assembled assets with a number like "8043e5b2" but no extension. This might be an svg, png , or jpeg image which was stripped off the extension and renamed, I found out by looking inside the file or copying it outside of build and adding the extension. This file will not rename, delete or be modified on any application on windows and yes that includes the IDEs.
The only solution that I found to delete this was to boot into safe mode with CMD and delete it from there.
If you pick to go with step 5 you are going to build the app successfully for a couple of times and then it happens again. The you have to go to safe boot to delete the build again.
Version info
$ flutter doctor -v
[√] Flutter (Channel stable, 3.3.10, on Microsoft Windows [Version 10.0.19045.2364], locale en-UK)
• Flutter version 3.3.10 on channel stable at C:\Flutter\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 135454af32 (2 weeks ago), 2022-12-15 07:36:55 -0800
• Engine revision 3316dd8728
• Dart version 2.18.6
• DevTools version 2.15.0
Checking Android licenses is taking an unexpectedly long time...[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at C:\Usname\AppData\Local\Android\sdk
• Platform android-33, build-tools 33.0.0
• Java binary at: C:\Program Files\Android\Android Studio1\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\xxxxx\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 (version 2021.3)
• Android Studio at C:\xxx\Android\Android Studio1
• 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.13+0-b1751.21-8125866)
[√] VS Code (version 1.74.2)
• VS Code at C:\mypathtoinstallation\Microsoft VS Code
• Flutter extension version 3.56.0
[√] Connected device (4 available)
•X683 (mobile) • 192.168.xx.xx:xxxx • android-arm64 • Android
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19045.2364]
• Chrome (web) • chrome • web-javascript • Google Chrome 108.0.5359.125
• Edge (web) • edge • web-javascript • Microsoft Edge 108.0.1462.54
[√] HTTP Host Availability
• All required HTTP hosts are available
I've been trying to get my Flutter project to run after upgrading it to 2.10.4 and it's been a headache from the start. The project runs fine on a browser, but I'm having difficulty running on an Android emulator. I think I'm at the last hurdle, but I'm stumped right now. I'm receiving this error when running on VS Code:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Failed to install the following SDK components:
build-tools;30.0.2 Android SDK Build-Tools 30.0.2
The SDK directory is not writable (C:\Program Files (x86)\Android\android-sdk)
Here's my Flutter Doctor:
PS D:\Documents\Flutter_Projects\glance> flutter doctor -v
[√] Flutter (Channel stable, 2.10.4, on Microsoft Windows [Version 10.0.19043.1586], locale en-US)
• Flutter version 2.10.4 at D:\Programs\flutter_windows_v1.2.1-stable\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision c860cba910 (3 weeks ago), 2022-03-25 00:23:12 -0500
• Engine revision 57d3bac3dd
• Dart version 2.16.2
• DevTools version 2.9.2
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at C:\Program Files (x86)\Android\android-sdk
• Platform android-31, build-tools 30.0.3
• ANDROID_HOME = C:\Users\reff1\AppData\Local\Android\Sdk
• ANDROID_SDK_ROOT = C:\Users\reff1\AppData\Local\Android\Sdk
• Java binary at: D:\AndroidStudio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822)
X Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\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 (version 2021.1)
• Android Studio at D:\AndroidStudio
• 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)
[!] Android Studio (version 4.1)
• Android Studio at D:\Programs\AndroidStudio
• 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
X Unable to determine bundled Java version.
• Try updating or re-installing Android Studio.
[√] VS Code, 64-bit edition (version 1.50.1)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension version 3.17.0
[√] Connected device (4 available)
• sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 12 (API 32) (emulator)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19043.1586]
• Chrome (web) • chrome • web-javascript • Google Chrome 100.0.4896.88
• Edge (web) • edge • web-javascript • Microsoft Edge 99.0.1150.46
[√] HTTP Host Availability
• All required HTTP hosts are available
Here's the part that keeps getting me. I'm seeing I need to run flutter doctor --android-licenses and this is what I get:
PS D:\Documents\Flutter_Projects\glance> flutter doctor --android-licenses
Error: Could not find or load main class Files
I have no clue where to go from here. Any help would be greatly appreciated here. Thank you in advance.
It appears that you have two sets of Android Studio and Android SDK.
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at C:\Program Files (x86)\Android\android-sdk <--- 1
...
• ANDROID_HOME = C:\Users\reff1\AppData\Local\Android\Sdk <--- 2
[√] Android Studio (version 2021.1) <--- 1
• Android Studio at D:\AndroidStudio
...
[!] Android Studio (version 4.1) <--- 2
• Android Studio at D:\Programs\AndroidStudio
Android Studio version 4.1 is a bit older so I guess you installed it in the past and forgot about it.
Also, it is not normal (or up-to-date) to have Android SDK placed under Program Files.
This is the direct cause of the error. In Windows, writing files under Program Files requires administrator privileges.
Your system is possibly confused because you have a mixed environment with an SDK that requires administrator privileges and one that does not.
My advice is to first uninstall all of them.
Before you begin, find out where the Android Studio configuration files are stored and backup them.
It is documented in here.
Now, completely uninstall all versions of Android Studio and Android SDK, manually delete all environment variables related to Android if any, manually delete (and backup) all configuration files if the uninstaller did not, then make sure all four directories above are empty.
Next, install the latest version of Android Studio and install the Android SDK via Android Studio. At this point, make sure that the installation directory is not under Program Files or Program Files (x86). If it is, then something in the older version is still there and is doing bad things so you have to restart from the first step.
Finally, run flutter clean (just to be sure), then flutter doctor to make sure only one of each is detected.
In android studio update your sdk 30
Unable to determine bundled Java version.
• Try updating or re-installing Android Studio
See in your error in flutter doctor
Change the ownership of Android SDK:
sudo chown -R $(whoami) $ANDROID_HOME
For this issue : Android license status unknown.
Type in command prompt
flutter doctor --android-licenses
Type Yes/y/Y to accept licenses
Maybe it's an emulator specific issue, did you try to run it on a real device?
Regarding the android license issue you are getting, I guess that the system is not recognizing JAVA or it needs to be updated so please check that.
Also make sure that the emulator itself is updated and not only the android SDK, go to SDK manager and check all the dashed components:
If this didn't work, delete the emulator and create a new one, and if that didn't help, delete all instances of android studio as I see 2 on your system that might conflict the SDK path.
On my device, flutter does not hot reload, I initially thought this was a problem with flutter or android studio or vs code but when I use a different device, the hot reload is working. How do I resolve this, it's just been driving me crazy and I have already spent a lot of hours trying to figure this out.
And btw, it was initially working on this device until it wasn't, and I have already restarted my phone, I have even reinstalled flutter, basically every suggestion from the internet I have tried but so far, no fruits.
Any help would be highly appreciated, here is the flutter doctor -v.
[✓] Flutter (Channel stable, v1.12.13+hotfix.9, on Linux, locale en_US.UTF-8)
• Flutter version 1.12.13+hotfix.9 at /home/hamisi/flutter
• Framework revision f139b11009 (5 weeks ago), 2020-03-30 13:57:30 -0700
• Engine revision af51afceb8
• Dart version 2.7.2
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /home/hamisi/android
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• ANDROID_HOME = /home/hamisi/android/
• Java binary at: /home/hamisi/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.
[✓] Android Studio (version 3.5)
• Android Studio at /home/hamisi/android-studio
• Flutter plugin version 44.0.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[✓] Connected device (1 available)
• LG H845 • LGH845e35cd375 • android-arm • Android 7.0 (API 24)
• No issues found!
The output from flutter run -v --trace-startup is https://pastebin.com/9X4S5LWr
I had this exact problem with a Pixel 2. Fine one minute, then boom - hot reload / restart was not available. I could deploy the app to the device, but hot reload options were greyed out in Android Studio and hot reload keyboard shortcuts did nothing. Pressing r after flutter run also did nothing. Nothing significant happened in between it working and it not working - no updates to Android Studio, Flutter or the device. I tried restarting the device, Android Studio, flutter clean, I tried swapping the USB cable, nothing seemed to work.
It did eventually start working again: I did a flutter clean followed immediately by a reboot of my computer. I have no idea if this was the fix, or whether it was just one of those random who-the-f-knows, but hopefully it will help anyone else.
[√] Flutter (Channel stable, v1.17.0, on Microsoft Windows [Version 10.0.18362.778], locale en-GB)
• Flutter version 1.17.0 at D:\flutter
• Framework revision e6b34c2b5c (10 days ago), 2020-05-02 11:39:18 -0700
• Engine revision 540786dd51
• Dart version 2.8.1
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at C:\Users\james\AppData\Local\Android\sdk
• Platform android-29, build-tools 29.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
• All Android licenses accepted.
[√] Android Studio (version 3.6)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 45.1.1
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
[√] Connected device (1 available)
• Pixel 2 • HT7C11A06689 • android-arm64 • Android 10 (API 29)
• No issues found!
I had this issue some days ago I did a couple of things:
In some files may be added file:/// before the file name in the above file. Search in the whole project and remove file:/// line and again import that package again.
flutter upgrade
Clean project(flutter clean)
I also change my emulator.
that worked for me
Since you have all necessary plugin installed and your flutter-doctor has no issues.
Try running the command flutter clean.
Hopefully that is going to work.
I hope this helps.
if you are using an android virtual device. navigate to its settings => proxy then untick 'Use android studio http proxy settings' select 'No proxy'... that worked for me.
For anyone else who runs into this issue and has installed VS Code Hotkeys/Keymap for Android Studio, the default VS Code hotkey for "Save All" will immediately stop hot reload from working. (With VS Code hotkeys this is Ctrl+K or S)
Simply removing the "Ctrl+K, S" and replacing it with Ctrl+S worked after days of trying to fix this. Screenshot below.
File -> Settings -> Keymap -> Search for "save"
Screenshot with Instructions (Settings -> Keymap)
HotReload was not working me as well, but I searched for it and found the solution.
When you click on the HotReload it will work only in the changes inside the Build() Widget, if your code is outside the build() widget then it will not work...
Thanks
I had the same problem, All you need to do:
Wipe data in the Android Emulator
Cold boot the device and done.
If you are still not able to figure it out check this method.
When you import widget from another .dart file. sometime android studio will import this path.
import file:///C:/kharag/.../.../< App Name >/lib/filename.dart
Hot reload and hot restart will not work in that case. To fix that you should find and remove file path and replace with given path format below
import package:< App Name >/filename.dart
Note: To see the change stop your app and run again
Before anyone points me to this link I would like to mention, that I don't think these are directly related.
As one can see my flutter doctor -v command is error free:
➜ flutter git:(stable) flutter doctor -v
[✓] Flutter (Channel stable, v1.12.13+hotfix.9, on Mac OS X 10.15.3 19D76, locale en-US)
• Flutter version 1.12.13+hotfix.9 at /Users/johannes/.flutter-cli/flutter
• Framework revision f139b11009 (5 weeks ago), 2020-03-30 13:57:30 -0700
• Engine revision af51afceb8
• Dart version 2.7.2
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /Users/johannes/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.4.1, Build version 11E503a
• CocoaPods version 1.8.4
[✓] Android Studio (version 3.6)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 45.1.1
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
[✓] Connected device (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)
• No issues found!
Yet I to have the issue of a grayed out emulator device with the message Device not applicable for the “main.dart” configuration like this:
I can now only start the emulator using the dropdown menu <no device> like this:
Interestingly I am then actually able to run my app on the device, while the device is still grayed out:
Flutters hot-reloading feature seems to not work properly though.
I have already added the main folder to the project as suggested here and I also made sure to change NO SDK to ANDROID API PLATFORM as suggested in the same link. All dependencies in Project Structure > Modules are found by Android Studio. I cloned the Flutter SKD from the stable branch on GitHub.
Does anyone have an idea why my setup is behaving this way?
Close Android Studio and Run again as Administrator
It solved my problem:
1- Make sure Flutter plugin is installed in android studio, you can install the plugin from file > setting > plugin
2- choose flutter SDK path from File > setting> Language & Framework > flutter.
I have the same issue before.
Uninstall Flutter and Dart plugin from Android Studio then reinstall Flutter (Dart will be installed automatically)
Remove created emulators from AVD Manager and create new one
Try making new project, and set SDK version same as emulators API version or lower from File > Project Structure...
Hopefully worked for you.
I am trying to work on flutter . Flutter doctor is not detecting my Android device.But it is detecting the Android emulator.
I am using brand new Redmi Note 7 with developer options on.
UBUNTU 18.04 OS
1) Tried with all three USB options
Use USB for
No Data transfer
File Transfer
Transfer Photos (PTP)
2) when I check with adb devices
The device is not getting detected
adb devices
I am working on Flutter Flutter doctor is not recognising my android device. I am using brand new Redmi Note 7 for testing
krishvek#krishvek-Inspiron-N4030:~$ flutter doctor -v
[✓] Flutter (Channel stable, v1.2.1, on Linux, locale en_IN)
• Flutter version 1.2.1 at /home/krishvek/flutter_dev/flutter
• Framework revision 8661d8aecd (7 weeks ago), 2019-02-14 19:19:53 -0800
• Engine revision 3757390fa4
• Dart version 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /home/krishvek/Android/Sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• Java binary at: /home/krishvek/Desktop/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
• All Android licenses accepted.
[✓] Android Studio (version 3.3)
• Android Studio at /home/krishvek/Desktop/android-studio
• Flutter plugin version 34.0.1
• Dart plugin version 182.5215
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
[✓] IntelliJ IDEA Community Edition (version 2019.1)
• IntelliJ at /home/krishvek/intellJ/idea-IC-191.6183.87
• Flutter plugin version 34.0.4
• Dart plugin version 191.6183.88
[!] Connected device
! No devices available
! Doctor found issues in 1 category.
krishvek#krishvek-Inspiron-N4030:~$ adb devices
List of devices attached
adb server version (40) doesn't match this client (36); killing...
* daemon started successfully *
krishvek#krishvek-Inspiron-N4030:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/home/krishvek/flutter_dev/flutter/bin:/home/krishvek/Android/sdk/platform-tools:/home/krishvek/Android/sdk/platform-tools/:/home/krishvek/Android/sdk/platform-tools:/home/krishvek/Android/sdk/platform-tools/
It should recognize android device