SDK and android studio issue in flutter doctor - flutter

How do i resolve these 2 errors in flutter
Unable to locate SDK and
Android studio directory
flutterError

Make sure that you installed Android SDK, also make sure that you setup C:..\android\SDK\tools and C:..\android\plateform-tools in your environment variables

Related

Getting error : "Target dart2js failed: Exception: Warning: The 'dart2js' entrypoint script is deprecated, please use 'dart compile js' instead "

Im trying to build flutter web app on release mode using flutter build web(also tried flutter build web --no-sound-null-safety).When i do,im getting the below error.
D:\saves\reset_password>flutter build web
Building without sound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety
Target dart2js failed: Exception: Warning: The 'dart2js' entrypoint script is deprecated, please use 'dart compile js' instead.
.dart_tool/flutter_build/1916f9367c0e6ad6c929bd88cf5227e5/web_plugin_registrant.dart:14:38:
Error: Null safety features are disabled for this library.
void registerPlugins([final Registrar? pluginRegistrar]) {
^
Error: Compilation failed.
Compiling lib\main.dart for the Web... 44.9s
Exception: Failed to compile application for the Web.
It works fine when i run it directly in debug mode using flutter run.
Note: I recently upgraded to flutter 3.0 and im using Android studio.
Below is my flutter doctor( i am aware of the android tools missing.since im building for web,i didnt pay much attention to it)
D:\saves\reset_password>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, 3.1.0-0.0.pre.966, on Microsoft Windows [Version 10.0.19044.1706], locale en-IN)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
X cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
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
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.8.5)
[√] Android Studio (version 4.1)
[√] VS Code (version 1.66.2)
[√] Connected device (3 available)
[√] HTTP Host Availability
! Doctor found issues in 1 category.
For me was launching flutter clean && flutter pub get on the cmd/terminal, the solution.
flutter build web worked on my local but not on my server, after sudo reboot it worked again. the above sugestet answer didnt work for me...
I had a similar problem.
It was on server based on Ubuntu.
In my case I had:
Target dart2js failed: Exception: Warning:
The 'dart2js' entrypoint script is deprecated, please use 'dart compile js' instead.
flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_web-3.3.19/lib/firebase_auth_web.dart:402:16:
Error: The method 'FirebaseAuthWeb.verifyPhoneNumber' has fewer named arguments than those of overridden method 'FirebaseAuthPlatform.verifyPhoneNumber'.
...
I discovered that a firebase_auth_web dependency had a deprecated version and wasn't used in the project. Hence I removed this dependency. After that the problem disappears.
The fix for this issue is now available on the stable channel 3.3.0. It was due to a change in one of the 3.0 builds that put null safe features in the web plugins registrant. Any web project without null safety would have been affected.
Delete /flutter/bin/cache folder.
Run flutter doctor.
Then, run flutter clean, flutter pub get and flutter build web.
Delete .dart_tool
flutter clean
flutter pub get
flutter build web
I fixed this error by myself.Here's what i did:
I found that there are few dependencies in pubspec.yaml file that are not used currently.I navigated to my .dart_tool\flutter_build\cb8031cdd1bfbcb95122aae4ad9a63d5\web_plugin_registrant.dart and found that those dependencies are being referenced inside registerPlugins().
I cleared all those unused dependencies shown in registerPlugins() and did the following steps:
1.flutter pub get
2.flutter clean
3.flutter build web
And VIOLA! The error went away and i got my files in the build\web folder.

Flutter doctor --android-licenses not finding sdkmanager without Android Studio

I'm trying to get my very first Flutter application up and running. When I ran flutter doctor it was saying that I was missing Android SDK, so I installed sdkmanager and ran:
sdkmanager "platform-tools" "platform;android-29" "build-tools;28.0.3"
From there I ran flutter config --android-sdk /opt/android-sdk
I got an error saying that I'm missing cmdline-tools, however I don't have Android Studio and don't want to as well. So I went on Android Studio's website and downloaded a manual cmdline-tools and moved the file to android-sdk. OK so far so good, right? No, now I needed to run flutter doctor --android-licenses and it's saying Android sdkmanager not found. Why? Is there something I'm missing? I'm doing all of this in Ubuntu.
Below is the image of flutter doctor status
Shows me running flutter doctor --android-licenses
As well as shows the path to the android-sdk in the terminal
I have as well set flutter config --android-sdk to the correct path
and is the reason why flutter doctor has no issues with finding the
android-sdk
Image!!
Android toolchain - develop for Android devices X cmdline-tools component is missing run path/to/sdkmanager --install "cmdline-tools;latest"
This error means your "Android SDK Command-line Tools are missing"
Open Android Studio
In the Menu bar , click Tools(4th last)
choose SDK Tools panel
Tick Android SDK Command-line Tools
Click Apply at bottom of the window
I gave up and just downloaded android studio using snap package manager and within android studio I did the steps discussed above.
After downloading cmdline-tools from android studio. I have just set the android config --android-sudio-dir "toMyAndroidStudioPath" example. /home/myName/Android/Sdk....

flutter android studio not applicable for the main.dart configuration

i just installed flutter ,and i created a project ,but when I open android studio and I want to run it on my device I got an error like this
somoene can help me please i spent hours and hours but still got this probleme
and when i run flutter doctor command i got this
I resolved this on MacOS by downloading both the Flutter SDK and the Dart SDK and then setting the Flutter SDK and Dark SDK paths in Android Studio Preferences. See screenshots below:

Android Studio Dart And Flutter Plugin is not installed

Here is the flutter doctor result:
[√] Flutter (Channel stable, 1.22.1, on Microsoft Windows [Version 10.0.18362.30], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[!] Android Studio
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
[!] Connected device
! No devices available
! Doctor found issues in 2 categories.
I have already installed the flutter plugin. But the problem still exists. How can I fix this?
Just run this on your terminal (Mac users)
ln -s ~/Library/Application\ Support/Google/AndroidStudio4.1/plugins ~/Library/Application\ Support/AndroidStudio4.1
Well hello all
I would suggest you all to follow the steps what flutter documentation sites tells you to do
For windows-->There are some people who got detected flutter and dart plugins by the flutter doctor and few are not
I got this issue when I tried to install ...
I did everything like installed flutter and dart plugin still my flutter doctor haven't detected the plugins ...
following steps worked for me
flutter channel dev
flutter upgrade
flutter config --android-studio-dir="C:\Program Files\Android\Android Studio"
flutter doctor -v
note :--- flutter config --android-studio-dir="C:\Program Files\Android\Android Studio" should be example flutter config "C:\Program Files\Android\Android Studio"
above steps worked for me i hope it will helps you too :)
change channel master to dev.
then upgrade.
flutter channel dev
flutter channel upgrade
try again
flutter doctor
Note: I think it's Android Studio 4.1 issue...
Since you say you have flutter plugin installed in Android Studio, and if Android Studio correctly shows your installed plugin, there is no reason to believe any third-party tool reporting otherwise.
Also, this will not affect your flutter development and your IDE plugins will work as expected inside the IDE and flutter tool's commands work independent of the IDE in use.
Android Studio 4.1 apparently changed its default plugin install path.
Related github issue: [flutter_tools] IDE plugin validators should be deprecated #61246
Flutter does not directly use the IDE plugins, so doctor failing to detect them does not affect any behavior (it's just annoying).
open terminal:
run> flutter channel dev
run> flutter channel updrade
open terminal:
Mac User:
flutter config --android-studio-dir=/Applications/Android\ Studio.app
Reinstall Flutter Plugin from Android Studio
Are you using Android Studio V 4.1?
With Android Studio V4.1 there is a problem.
Try to reinstall Android Studio but Version 4.0.1 and try it again, chances are this will fix your problem.
Open Android studio
Follow the Path Configure > Plugins > marketplace > search Flutter & Dart > Install
Restart IDE(Android studio)
Open Terminal and Export Flutter Path
and run flutter doctor -v
If you are upgrading for an existing project:
Run
git clone https://github.com/flutter/flutter.git
in your terminal.
The be sure to delete the Flutter folder in your App's root directory. Otherwise you will get over 50k errors popping up
Check your flutter PATH
which flutter
if you get /path-to-flutter-sdk/bin//flutter or similar you may have added an extra / in your $HOME/.rc_file. Remove the last '/', restart terminal and try again
this worked for me
flutter channel dev
flutter doctor

How to get flutter sdk path in android studio?

I'm trying to install flutter sdk in android studio ... Everytime I install flutter sdk in android studio it again shows me the same error "Flutter sdk is not found in specified location"This is what I'm getting everytime
Just give the path till you flutter SDK not for the flutter bin.
Set it like D:\flutter