Develop Flutter web app on Windows Subsystems for Linux - android

I'm trying to develop web app with flutter on WSL2. However I could not get it work with chrome.
[✓] Flutter (Channel stable, 2.2.3, on Linux, locale C.UTF-8)
• Flutter version 2.2.3 at /home/rayl/development/flutter
• Framework revision f4abaa0735 (4 weeks ago), 2021-07-01 12:46:11 -0700
• Engine revision 241c87ad80
• Dart version 2.13.4
[!] Android toolchain - develop for Android devices
• Android SDK at /home/rayl/development/android/sdk
✗ Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, please use
`flutter config --android-sdk` to update to that location.
• ANDROID_HOME = /home/rayl/development/android/sdk
✗ No valid Android SDK platforms found in /home/rayl/development/android/sdk/platforms. Directory was empty.
• Try re-installing or updating your Android SDK,
visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions.
[✗] Chrome - develop for the web (Cannot find Chrome executable at /mnt/c/Program\ Files\/Google\/Chrome\/Application/chrome.exe)
! /mnt/c/Program\ Files\/Google\/Chrome\/Application/chrome.exe is not executable.
[!] 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/linux#android-setup for detailed instructions).
[!] Connected device
! No devices available
if i run /mnt/c/Program\ Files/Google/Chrome/Application/chrome.exe on cmdline. It will open chrome on windows side. but flutter doctor say its not executable.

Related

Unable to run Flutter project on Android after update

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.

Having a problem with Flutter Doctor on Arch Linux

I am running Arch Linux.
I have a problem where flutter doctor doesn't recognize my Android Sdk.
My Flutter Doctor output:
[✓] Flutter (Channel stable, 2.10.3, on Arch Linux 5.16.15-arch1-1, locale en_US.UTF-8)
[✗] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, please use
`flutter config --android-sdk` to update to that location.
[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Android Studio (version 2021.1)
[✓] Android Studio
[!] Connected device
! No devices available
[✓] HTTP Host Availability
! Doctor found issues in 3 categories.
Here is a more detailed summary:
[✓] Flutter (Channel stable, 2.10.3, on Arch Linux 5.16.15-arch1-1, locale en_US.UTF-8)
• Flutter version 2.10.3 at /home/tt/Downloads/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 7e9793dee1 (3 weeks ago), 2022-03-02 11:23:12 -0600
• Engine revision bd539267b4
• Dart version 2.16.1
• DevTools version 2.9.2
[✗] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, please use
`flutter config --android-sdk` to update to that location.
[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Android Studio (version 2021.1)
• Android Studio at /home/tt/.local/share/JetBrains/Toolbox/apps/AndroidStudio/ch-0/211.7628.21.2111.8193401
• Flutter plugin version 65.2.2
• Dart plugin version 211.7808
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
[✓] Android Studio
• Android Studio at /opt/android-studio
• 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+0-b60-7590822)
[!] Connected device
! No devices available
[✓] HTTP Host Availability
• All required HTTP hosts are available
As you can see, it doesn't recognize my Android Sdk.
I tried this:
flutter config --android-sdk /home/tt/Android/Sdk/platforms/android-32/android.jar
and I got:
Setting "android-sdk" value to "/home/tt/Android/Sdk/platforms/android-32/android.jar".
You may need to restart any open editors for them to read new settings.
I ran flutter doctor but didn't work. I restarted my machine and it still doesn't work.
I already had Android Studio from the Toolbox Application. I tried installing it from the .tar.gz version. Still doesn't work. I installed from the AUR, but nothing works.
Can you please help..
Try to set ANDROID_HOME in your environment variable.
On ~/.bashrc of you are using bash or ~/.zshrc if you are using zsh in the last line put
export ANDROID_HOME=[SDK-PATH]
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
I believe the problem is in the PATH of Android SDK Command-Line Tools and Android SDK Build Tools.
Put the following lines at the end of the ~/.bachrc file:
export ANDROID_HOME="/home/XXX/Android/Sdk/"
export PATH="$PATH:${ANDROID_HOME}cmdline-tools/latest/bin/:${ANDROID_HOME}build-tools/33.0.0/:${ANDROID_HOME}platform-tools/"
Note that XXX, latest, and 33.0.0 must be changed according to your installation.

When I want to create a new flutter project, flutter just returns to the welcome screen

I have already installed Flutter and Dart plugins in Android Studio. I go through all the stages of creating a Flutter project but when I click on Finish I get the dialog "creating a new flutter project" but after a few seconds the welcome screen keeps showing up and I'm back at square one. Can anyone help, please?
Here's the information of "flutter doctor -v" command:
CreateProcessW failed 87
[!] Flutter (Channel stable, v1.12.13+hotfix.8, on Microsoft Windows [Version 10.0.18362.418], locale en-US)
• Flutter version 1.12.13+hotfix.8 at C:\src\flutter
• Framework revision 0b8abb4724 (4 weeks ago), 2020-02-11 11:44:36 -0800
• Engine revision e1e6ced81d
• Dart version 2.7.0
X Downloaded executables cannot execute on host.
See https://github.com/flutter/flutter/issues/6207 for more information
[X] Android toolchain - develop for Android devices
X Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/setup/#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, set ANDROID_HOME to that location.
You may also want to add it to your PATH environment variable.
[√] Android Studio (version 3.6)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 44.0.2
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
[!] Connected device
! No devices available
! Doctor found issues in 3 categories.
It seems that you have a problem with Flutter installation. You can try to reinstall it (make sure you get version for your OS).
The second problem is with Android SDK. Installing Android Studio is not enough. Try going through this setup instructions: https://flutter.dev/docs/get-started/install#android-setup.

Error ":app:transformClassesWithDexBuilderForDebug" when upgrade to new version of flutter

I upgrade flutter from v1.91. hotfix 6 by using flutter upgrade --force.
Then i build an example "layers" - flutter run, it shows this message, while if i switch to 1.91, everything built ok
flutter run --stacktrace gives this error
Could not find an option named "stacktrace".
flutter doctor -v
G:\new\new_exam>flutter doctor -v [√] Flutter (Channel stable,
v1.12.13+hotfix.5, on Microsoft Windows [Version 10.0.18362.535],
locale en-US) • Flutter version 1.12.13+hotfix.5 at G:\Flutter\flutter
• Framework revision 27321eb (12 days ago), 2019-12-10 18:15:01 -0800
• Engine revision 2994f7e1e6 • Dart version 2.7.0
[√] Android toolchain - develop for Android devices (Android SDK
version 29.0.2) • Android SDK at G:\Flutter\android • Android NDK
location not configured (optional; useful for native profiling
support) • Platform android-29, build-tools 29.0.2 • ANDROID_HOME =
G:\Flutter\android • ANDROID_SDK_ROOT = G:\Flutter\android\sdk • Java
binary at: G:\flutter\openjdk\bin\java • Java version OpenJDK Runtime
Environment (build 1.8.0_232-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/setup/#android-setup for detailed
instructions).
[!] IntelliJ IDEA Community Edition (version 2019.3) • IntelliJ at
C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.3.1 X
Flutter plugin not installed; this adds Flutter specific
functionality. X Dart plugin not installed; this adds Dart specific
functionality. • For information about installing plugins, see
https://flutter.dev/intellij-setup/#installing-the-plugins
[!] Connected device ! No devices available
! Doctor found issues in 3 categories.
1: https://i.stack.imgur.com/B4DTX.png
I feel the solution is pretty straight forward. Usually, it's always a best practice to use Android Studio when working with Flutter and Dart. Reasons are there are some dependencies that would require you to use Android Studio to have it work well for you, especially when you're just starting to work with Flutter and Dart.
Flutter Doctor is pretty precise as to the issues you're experiencing.
After downloading Android Studio, do the following;
Navigate to your Preferences or Android Studio Settings on PC, then select, Plugins, ensure the following plugins are installed.
Android APK Support
Android NDK Support
Dart
Flutter
EditorConfig
App Links Assistant
Google Services
Gradle
Properties Support
Java Bytecode Decompiler
Java Stream Debugger
Task Management
YAML
Among others which would be automatically installed by Android Studio for you, this should take that error away and you should be fine.
Then, before you probably run your App, if you see the get dependencies at the Top of your Android Studio, click the get dependencies so that Android studio can get the latest dependencies to run your App without issues.
Ensure you run a cold restart after each time you add a new dependency to your pubspec.yaml file.

Installing Flutter on Mac OS

on running flutter doctor i get the below dependency lacking :
Android toolchain - develop for Android devices (Android SDK 28.0.3)
Could not determine java version
Android Studio (not installed)
But i have already installed both and developing apps on Android Studio.Then why flutter is not able to find these two?
It is complaining for the jre version as well.But internally Android Studio uses the jre which is already installed with it.
flutter doctor -v gives below output :
[✓] Flutter (Channel stable, v1.0.0, on Mac OS X 10.13.6 17G65, locale en-IN)
• Flutter version 1.0.0 at /Users/<myusername>/Downloads/development/flutter
• Framework revision 5391447fae (3 months 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 /Users/<myusername>/Library/Android/sdk
• Android NDK at /Users/<myusername>/Library/Android/sdk/ndk-bundle
• Platform android-28, build-tools 28.0.3
• Java binary at: /usr/bin/java
✗ Could not determine java version
[!] iOS toolchain - develop for iOS devices
✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
Download at: https://developer.apple.com/xcode/download/
Or install Xcode via the App Store.
Once installed, run:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
• ios-deploy 1.9.4
• CocoaPods version 1.6.0
[!] Android Studio (not installed)
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.io/setup/#android-setup for detailed instructions).
[!] Connected device
! No devices available
Solution for Xcode:
Install Xcode (get it from https://developer.apple.com/xcode/)
Ensure Xcode app is in the /Applications directory (NOT /Users/{user}/Applications).
Point xcode-select to the Xcode app Developer directory using the following command:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
Note: Make sure your Xcode app path is correct.
Xcode: /Applications/Xcode.app/Contents/Developer
Xcode-beta: /Applications/Xcode-beta.app/Contents/Developer

Categories

Resources