Flutter Hot Restart and Hot Reload button greyed out - android-studio

I decided to learn flutter so i downloaded the plugin in Android studio. I followed the docs at Flutter's website in order to run the Hello World program. The project builds without errors and runs but it never gets past
Installing build\app\outputs\flutter-apk\app.apk...
While at this point, the screen goes white and stays that way.
If I stop the process in Android studio and quit the app on my phone (Nokia 3.1plus, Android 9), then open the app manually on my phone, it loads up properly.
What I notice is that sometimes it stays stuck at Running Gradle task 'assembleDebug'... while the screen stays white. At this point, it would have outputed
✓ Built build\app\outputs\flutter-apk\app-debug.apk.
I have tried with an emulator and it is the same. I have tried with VSCode and it is the same.
When I run "flutter run" in Command Line, It run the app on my phone without the white screen issue but I cannot use "r" or "R" for hot refresh or restart.
In VS Code debugger console, when I try to run r or R while the Running Gradle task 'assembleDebug'... is still running, it says
global evaluation requires a thread to have been loaded
This is the result of flutter doctor
[√] Flutter (Channel stable, 1.20.2, on Microsoft Windows [Version 10.0.18363.900], locale en-GB)
• Flutter version 1.20.2 at C:\flutter
• Framework revision bbfbf1770c (4 days ago), 2020-08-13 08:33:09 -0700
• Engine revision 9d5b21729f
• Dart version 2.9.1
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at C:\Users\ADMIN\AppData\Local\Android\sdk
• Platform android-29, build-tools 29.0.2
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[√] Android Studio (version 4.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 48.1.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] VS Code, 64-bit edition (version 1.47.3)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension version 3.13.2
[√] Connected device (1 available)
• Nokia 3 1 Plus (mobile) • ROOGALB8C2201609 • android-arm64 • Android 9 (API 28)
• No issues found!
What I have tried
flutter clean, invalidate cache and restart, changing my target sdk to 29, updating flutter and dart
I have tried most of the suggestions on the flutter github issues section.
Is there anything I am missing?

After weeks of prowling the internet, I decided to do a full reset. I uninstalled Android Studio, deleted flutter completely from regular directory as well as all associated PATH and ENVIRONMENT variable, removed all traces of dart too. I also deleted all gradle, sdk and android files from C:/ directory
Basically started afresh. Worked like a charm.
Apparently something got broken

Open the File menu and click Invalidate cache/ Restart. This solved for me !

I had the same problem however, I closed out all open projects and vscode, returned to open vscode with a prompt to install recommended vscode settings for Dart, Run the code without debugging and everything worked fine.
Closed VsCode with project
Opened VsCode again (system automatically prompted me to use VsCode recommended settings) to install VsCode recommended settings
Run from the menu without debugging.
That solved the problem for me.

Related

Android Studio does not find cocoapods in console

Somehow Android Studio does not find cocoapods, even though it is correctly installed in the system via brew install coocapods. The Android Studio console looks like it doesn't get the correct PATH.
Note: Starting Android Studio through a terminal / iTerm with
open /Applications/Android\ Studio.app
does mitigate the issue, Android Studio then somehow gets the right path. But im wondering how i can archieve the same result for a start directly from the application directory / spotlight-search? Why does Android Studio not resolve the right PATH?
Android Studio Version 2021.1.1, macOS
Console output after click on "Flutter doctor":
/Users/[...]/flutter/bin/flutter doctor --verbose
[✓] Flutter (Channel stable, 2.8.1, on macOS 12.1 21C52 darwin-x64, locale de-DE)
• Flutter version 2.8.1 at /Users/[...]/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 77d935af4d (6 weeks ago), 2021-12-16 08:37:33 -0800
• Engine revision 890a5fca2e
• Dart version 2.15.1
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/[...]/Library/Android/sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
• All Android licenses accepted.
[!] Xcode - develop for iOS and macOS (Xcode 13.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
✗ CocoaPods not installed.
CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/platform-plugins
To install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
...
Starting a terminal in Android Studio or starting iTerm, output:
flutter doctor -v
[✓] Flutter (Channel stable, 2.8.1, on macOS 12.1 21C52 darwin-x64, locale de-DE)
• Flutter version 2.8.1 at /Users/[...]/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 77d935af4d (6 weeks ago), 2021-12-16 08:37:33 -0800
• Engine revision 890a5fca2e
• Dart version 2.15.1
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/[...]/Library/Android/sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.2
...
Fixed in Android Studio Bumblebee 2021.1.1.1.21 Patch 1 for Mac.
I just installed the latest ANDROID STUDIO Bumblebee 2021.1.1.1.21 Patch 1 for Mac Intel. I loaded an older FLUTTER app into it and ran, (from the run arrow in the IDE), it against an iPhone 8 Simulator device. The CocoaPods error did NOT appear and the app launched in the Simulator device. It seems to me that this update has fixed that error.
#scrimau wrote the best description of this issue.
Here's some further info:
echo $PATH (using Android Studio's Terminal) produces different results depending on which of the two methods is used to start Android Studio.
The same directories appear in both echo $PATH results, but the directories are shuffled around.
It almost seems like the sequence of directories (as shown by echo $PATH) might have something to do with the different behaviors.
(Sorry: This should have been a comment. I can't find a way to change an answer to a comment. I'll be more careful next time.)
Android Studio Bumblebee 2021.1.1.1.21 Patch 1 seems to have fixed this issue. In the release notes there is a similar issue mentioned:
Issue #216364005: Env variables not sourced when launched from Mac OS X to Monterey Dock

Error : Parameter format not correct - flutter in android studio

I am new to Flutter & I've been stuck to one problem. I cannot run my app because it says :
flutter run
Using hardware rendering with device sdk gphone x86 arm. If you get graphics artifacts, consider
enabling software rendering with "--enable-software-rendering".
Launching lib\main.dart on sdk gphone x86 arm in debug mode...
Parameter format not correct -
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 24.7s
Exception: Gradle task assembleDebug failed with exit code -1
flutter doctor
[√] Flutter (Channel stable, v1.17.1, on Microsoft Windows [Version 10.0.18362.1139], locale en-IN)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[√] Android Studio (version 4.0)
[√] VS Code (version 1.50.1)
[√] Connected device (1 available)
• No issues found!
It's been three days and I'm totally confused? Please help!
There are multiple way to test this:
Downgrade or Upgrade your Flutter SDK (Easiest One).
Check for Environment Variable you had set either they are correct like Flutter
SDK path, Android Studio Path.
Try changing the Drive where Flutter SDK is setup and continue with step 2.
I was having same issue but downgrading works for me.

How make a portable Intellij IDEA Ultimate be recognised by Flutter Doctor?

I used to have a portable development environment. Where I have a IntelliJ IDEA Ultimate installed in a External SSD Drive (https://portapps.io/app/intellij-idea-ultimate-portable/). I'm starting to code in Flutter and I having this issue.
When I run "flutter doctor -v", the flutter doesn't recognise the portable version (and I understand, because is not in the default directory).
The question is, how to make flutter doctor recognise this external installation (from zip file)?
I have everything configured correctly, here is my current "flutter doctor -v" output:
[√] Flutter (Channel stable, v1.17.5, on Microsoft Windows [Version 10.0.18363.900], locale en-GB)
• Flutter version 1.17.5 at Z:\SDK\Flutter
• Framework revision 8af6b2f038 (10 days ago), 2020-06-30 12:53:55 -0700
• Engine revision ee76268252
• Dart version 2.8.4
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
• Android SDK at Z:\SDK\Android
• Platform android-30, build-tools 30.0.1
• ANDROID_HOME = Z:\SDK\Android
• Java binary at: Z:\SDK\OpenJDK\bin\java
• Java version OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_252-b09)
• All Android licenses accepted.
[!] Android Studio (not installed)
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
[!] Connected device
! No devices available
! Doctor found issues in 2 categories.
You're free to use IntelliJ (or any other IDE) for flutter development, but it won't satisfy the checks made by flutter doctor. It's looking specifically for Android Studio. If you want to use IntelliJ then you have to live with flutter doctor's warnings about Android Studio not being installed.
If you want to use a portable version of Android Studio then use the command
flutter config --android-studio-dir "Z:\MyPortableApps\AndroidStudio"
with the path to your portable application.
If you want to see what has been configured then just use flutter config without any parameters. The output starts with a load of usage text but at the end you'll find a section with the heading Settings: listing anything that has been set. A new install won't have anything set and will just use defaults.
To later unset a value use a quoted empty string "" in the same command.

Flutter SDK is not found in the specified location - in Android Studio

I am installing Flutter and everything is good except one thing, specified above.
Flutter doctor says this:
$ flutter doctor -v
[√] Flutter (Channel beta, v0.7.3, on Microsoft Windows [Version 10.0.17134.228], locale nl-NL)
• Flutter version 0.7.3 at C:\Flutter\flutter_windows_new\flutter
• Framework revision 3b309bda07 (13 days ago), 2018-08-28 12:39:24 -0700
• Engine revision af42b6dc95
• Dart version 2.1.0-dev.1.0.flutter-ccb16f7282
[√] Android toolchain - develop for Android devices (Android SDK 27.0.3)
• Android SDK at C:\Users\iwijsman\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 27.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-1024-b02)
• All Android licenses accepted.
[√] Android Studio (version 3.1)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 28.0.1
• Dart plugin version 173.4700
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
[√] IntelliJ IDEA Community Edition (version 2018.2)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.2.2
• Flutter plugin version 28.0.4
• Dart plugin version 182.4323.44
[√] Connected devices (1 available)
• Pixel 2 • FA83P1A01724 • android-arm64 • Android 9 (API 28)
• No issues found!
I've added the requested path to variables and in Android studio, the plugins are installed and applied but I still get this error.
please help me, where am I going wrong?
The same problem faced me, but trying the above solution was not helpful. So I tried another thing:
Open File
Select settings from the File menu
Select Languages & frameworks from the left panel
Select Flutter
Then from the right panel choose the location of your flutter SDK
The location of flutter SDK is where you copied or cloned the code. In my case it was like the following:
If the specified location contains the flutter SDK, the version section will contain your flutter version. If not, the version section will not contain any versions and there will be a message in the bottom of the setting dialog saying:
Flutter SDK Is Not Found In The Specified Location
Hope this helps.
The path to the SDK should be to the main Flutter folder (e.g. C:\src\flutter and not to the bin folder as set in the Environment Variable Path.
As mentioned in the message it is optional and only used for specific tasks.
You can install it from Android Studio
Menu > Tools > SDK Manager > Android SDK (left side of the dialog) > SDK Tools (tab)
Ensure that this line is enabled
With [OK] it should be installed.
create an android project and see everything works fine.
if Gradle sync problem with kotline : File -> Settings -> Kotlin Compiler -> Target JVM Version Changing to 1.8 fixed the issue.
If everything run fine as android project then proced:
File -> Settings ->Languages & frameworks->Flutter.
select flutter sdk path as src\flutter and ok
if step 4 not works then select path src\flutter\bin;
Note:if android 10.0 not work then try it with 9.0;
Flutter folder put on dekstop and try to again to set flutter sdk path
check this also..
https://flutter.dev/docs/get-started/install/windows
You need to correctly specify the path of the Flutter installation. To find the path, run in your command line:
flutter doctor -v
The second line of the output should be the path:
[√] Flutter (Channel stable, 2.0.6, on Microsoft Windows [Version 10.0.19041.488], locale en-US)
--- THIS LINE CONTAINS THE PATH---
• Flutter version 2.0.6 at C:\src\flutter\flutter_windows_2.0.6-stable\flutter
• Framework revision 1d9032c7e1 (6 days ago), 2021-04-29 17:37:58 -0700
• Engine revision 05e680e202
...
Enter the path into Android Studio.

Flutter Doctor (Incorrectly?) Reporting Android Studio Flutter Plugin Not Installed

When I ran flutter doctor it reports that my Android Studio Flutter and Dart plugins are not installed, even though I have the latest installed - and in fact, I can build and deploy a flutter app to a mobile device from Android Studio. I think either my config somewhere isn't correct or flutter doctor has a bug.
When I run flutter doctor -v I get the following:
d:\Dev\Flutter>flutter doctor -v
[√] Flutter (Channel master, v0.5.8-pre.264, on Microsoft Windows [Version 10.0.17134.165], locale en-AU)
• Flutter version 0.5.8-pre.264 at D:\Dev\Flutter\Flutter
• Framework revision b32c77a012 (12 hours ago), 2018-08-07 17:09:14 -0700
• Engine revision 7f083e54fe
• Dart version 2.0.0-dev.69.5.flutter-b04def964c
[√] Android toolchain - develop for Android devices (Android SDK 27.0.3)
• Android SDK at D:\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-27, build-tools 27.0.3
• ANDROID_HOME = D:\Android\sdk
• Java binary at: d:\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
• All Android licenses accepted.
[√] Android Studio
• Android Studio at d:\Android\Android Studio
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• android-studio-dir = d:\Android\Android Studio
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
[√] Connected devices (1 available)
• HTC PN071 • HT485W903981 • android-arm • Android 5.0.2 (API 21)
• No issues found!
I am running Windows 10 using Android Studio 3.1.4. I have switched flutter git branch to master. I have tried uninstall and reinstall the plugins but no success so far.
Below is my Android Studio plugin screenshot:
Go to
Settings > languages and frameworks > flutter
And then on the sdk path browse the directory where you have downloaded flutter. And check to see if it works
Since you are not using the conventional C: drive. Make sure you do not have another version of android studio installed on your system. This would lead flutter to detect a different version without the flutter plugin.
If there is no duplicate installed, there may just be residual files (ie: a backup).
This is just a guess but I hope this helps :)
Just in case someone else ran into this issue, it turns out that my channel was on 'stable' (1.22.1), switching to 'dev' solved the problem. This is a issue, will certanily been fixed in future 'stable' releases.
enter image description here
in case mine i have both android studio and intellij idea installed on my system so i uninstalled intellij idea that fixed my problem
This isn't an issue. Just ignore it. I also only use vscode and get this "issue". Maybe it would be good changing that issue to a info or warning because it could unsettle new flutter developers.

Resources