Flutter's doctor and sdkmanager are working against each other - android

Problem:
I am currently installing Flutter and flutter doctor tells me that I have to accept the SDK licenses with flutter doctor --android-licenses. That command in turn tells me (or to be exact it calls <sdk>/cmdline-tools/latest/sdkmanager and sdkmanager in turn tells me) that it could not determine the SDK root and that I should call it (it being the sdkmanager) with --sdk_root= or move this package into its expected location: <sdk>/cmdline-tools/latest.
I have no idea what latter "this package" refers to, but if I run the former sdkmanager with --sdk_root=<sdk>, I can accept all 7 licenses it gives me. So everything should work, right? No. If I run flutter doctor again, it still tells me to accept the SDK licenses. So flutter thinks the licenses are not accepted while the sdkmanager now tells me that all licenses are accepted. What is going on?
Context (for those who need it):
I'm using a newly setup MacBook with Android Studio Electric Eel (ASEE) freshly installed. For some reason there was no /cmdline-tools/ in <sdk> (for me /Users/<my_user_name>/Library/Android/sdk), even though officially it should come with ASEE, so I had to download it manually and put it in <sdk>. That download in turn was also missing many folders. For example the command-line tools documentation tells me that the sdkmanager is in <sdk>/cmdline-tools/<version>/bin/, but it isn't. It's just in /cmdline-tools/bin/. So I found out what the correct version is, made a symbolic link from <version>/bin to /bin, then flutter tells me that it also needs /latest/bin/, so I do the same for latest. And that's where I am right now.

Related

Flutter doctor --> Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)

I have a question so I think I dowlnloaded everything correctly but I still get this massage when I type in "flutter dictir" in cmd.
When I run "path/to/sdkmanager --install "cmdline-tools;latest" as recommended nothing happens.
So could you help me to download it anyways?
thecode
[!] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
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
! Doctor found issues in 1 category.
Open android studio then go to settings then SDK manager. Check the command line tools if it's not checked (most times it's not), then finish and let it download that plugin
Check the Android SDK path.
Go to where flutter is installed flutter config --android-sdk android_sdk_path
execute the command.
ex) flutter config --android-sdk C:\tools\AndroidSDK
Run this flutter config --android-sdk <path where you saved Android studio SDK> for e.g. in my case it was flutter config --android-sdk D:\AS_SDK (basically navigate SDK to the custom location).
Go to Android Studio, on the first page where you start a project, find the option to look for more settings, there you go to SDK manager and then select and install "Android SDK Command-line Tools (latest)" (size at the time of writing this is 108.9mb).
Now that you have the Android SDK navigated to the correct location and the latest command-line tools installed, run this flutter doctor --android-licenses and for every question it asks while confirming the licenses say "y".

Android licenses is toggling between not found and not accepted

Im starting with flutter. I have the flutter sdk setup. When I run flutter doctor sometimes it shows
Android Licenses are not accepted and other times it shows Android licenses are not accepted. Can someone tell me why flutter is gaving this weird behavior.
Another thing is when I run flutter doctor --android-licenses it wont wait for my to input y, otherwise it doestn't show anything
I have
- Sdk 29,28,27,26 platform
- Obsolete Sdk tool package
- Commandline tools
- emulator
- sdk platform tools
I think it should work with the obsolete sdk tools.
But I have no idea why it is acting weird.
It worked when I reset my windows.
Its not a perfect solution but hope it will help someone.
I think reinstalling Android Studio after clearning its cache and all other files will help

“Android license status unknown” in flutter doctor

I am getting an error with Android Sdk when I run flutter doctor on command-line
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v1.4.9-hotfix.1, on Mac OS X 10.14.4 18E226, locale zh-Hans-CN)
[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
✗ Android license status unknown.
Try re-installing or updating your Android SDK Manager.
See https://developer.android.com/studio/#downloads or visit
https://flutter.io/setup/#android-setup for detailed instructions.
[✓] iOS toolchain - develop for iOS devices (Xcode 10.2)
[✓] Android Studio (version 3.3)
[✓] VS Code (version 1.33.1)
[!] Connected device
! No devices available
! Doctor found issues in 2 categories.
After following several possible fixes from the stackoverflow community, i still couldn't get it to work.
Please i need assistance.
Here's what worked for me
Fix 1:
Launch Android studio & Open the SDK manager (Top-right of Android studio)
Navigate to SDK Tab and look for Android SDK Platform-Tools
If it's checked, unchecked it and click 'Apply' (We're trying to uninstall the previous version)
Now the "SDK Tools" is uninstalled. Let's re-install it by checking the box and clicking 'Apply'
Hit Ok & Restart Android studio
Navigate to SDK install location at %USERPROFILE%\AppData\Local\Android\Sdk for windows, you should see a new folder tools
Note: If you don't see the tools folder don't panic, i got you covered.
Open the tools folder & navigate to bin
Copy the folder path (i.e C:\Users\USERNAME%\AppData\Local\Android\Sdk\tools\bin)
Add that path to Environmental variables
Now you should have access to sdkmanager in the command-line. Try it out by typing sdkmanager & hitting enter in CMD.
If you get 'sdkmanager' is not recognized as an internal or external command, operable program or batch file. you probably made a mistake while adding the path to System Environmental Variables. Fix that.
Go to Flutter sdk folder (i.e c:/src/flutter) & launch the flutter_console.bat file
Now type the command flutter doctor --android-licenses and it should work. Accept all by typing y and hitting ENTER
And don't forget to run flutter doctor
Fix 2:
PS: Only if Fix 1 does not work for you!
Open your browser & goto Command line tools only (bottom of the page)
Download the appropriate package for your platform
Unzip it & Yes! You should see the tools folder
After extraction, copy the tools folder to C:\Users\USERNAME%\AppData\Local\Android\Sdk
Now the same as Fix 1 above,
Open the tools folder & navigate to bin
Copy the folder path (i.e C:\Users\USERNAME%\AppData\Local\Android\Sdk\tools\bin)
Add that path to Environmental variables
Now you should have access to sdkmanager in the command-line. Try it out by typing sdkmanager & hitting enter in CMD.
If you get 'sdkmanager' is not recognized as an internal or external command, operable program or batch file. you probably made a mistake while adding the path to System Environmental Variables. Fix that.
NO you're not done
The SDK Platform tools you downloaded is probably outdated (as you can see when you run the sdkmanager command from the command-line)
Now let's handover to Android Studio to do the rest. Restart Android Studio, so it can recognize the tools folder you added.
After Restart, Android Studio should automatically detect the outdated Platform-tools and prompt you to update (You must be connected to the internet!).
IF UPDATE PROMPT DOES NOT SHOW UP
Open SDK Manager in Android studio,
Go to UPDATES
Click Check Now
And you should get the PROMPT to update Platform-Tools
Fix 3:
Do everything in Fix 2
Open Environmental Variables, Create a new Variable JAVA_HOME and set the value to the JRE/bin (get it from Android studio install location in Program Files)
Open the command line type set JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee' for windows & export JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee' for Linux
And that's it you can now run flutter doctor --android-licenses on the command-line; Accept all licenses by typing y and hitting ENTER. And don't forget to run flutter doctor
THAT'S THE FIX. I HOPE IT WORKS FOR YOU TOO

flutter doctor --android-licenses not working on macOS Catalina

Recently I upgraded my Mac to Catalina.
I installed Java, set JAVA_HOME to $(/usr/libexec/java_home) as per the documentation. I installed Android Studio and SDK tools and set the ANDROID_HOME variable to /Users/username/Library/Android/sdk.
I downloaded flutter, and added flutter/bin to my env variable $PATH, and when I run flutter doctor, it's running fine and giving me the results as expected, without all the features checked however as I am setting it up for the first time.
But when I run flutter doctor --android-licenses, it's giving me an error which says:
Android sdkmanager tool was not found, try re-installing or upgrading your Android SDK.
Run the command flutter upgrade.
Then run the command flutter doctor --android-licenses.
Actually it was the then latest version of Flutter 1.12.13+hotfix.8 installed, which was not reading the cmdline-tools folder from the latest Android SDK home.
Also to be on the safer side, just create a folder tools inside <path-to-sdk-home>, and copy the contents of <path-to-sdk-home>/cmdline-tools/latest/ to the folder <path-to-sdk-home>/tools/.

Android SDK cannot be found by flutter

I have installed flutter through AUR. I also have aur/android-sdk 26.0.2-1 installed. When I run flutter run I get:
Warning! This package referenced a Flutter repository via the .packages file that is
no longer available. The repository from which the 'flutter' tool is currently
executing will be used instead.
running Flutter tool: /home/dair/.flutter-sdk
previous reference : /home/dair/flutter
This can happen if you deleted or moved your copy of the Flutter repository, or
if it was on a volume that is no longer mounted or has been mounted at a
different location. Please check your system path to verify that you are running
the expected version (run 'flutter --version' to see which flutter is on your path).
Unable to locate a development device; please run 'flutter doctor' for information about installing additional components.
Firstly, I ran flutter --version, and received:
Flutter • channel alpha • https://github.com/flutter/flutter.git
Framework • revision e2f54df5ab (9 days ago) • 2017-06-02 10:43:54 -0700
Engine • revision 1f2aa07571
Tools • Dart 1.24.0-dev.3.0
Not sure what exactly it means by "to see which flutter is on your path". Next I ran flutter doctor and got:
[✓] Flutter (on Linux, locale en_US.UTF-8, channel alpha)
• Flutter at /home/christopher/.flutter-sdk
• Framework revision e2f54df5ab (9 days ago), 2017-06-02 10:43:54 -0700
• Engine revision 1f2aa07571
• Tools Dart version 1.24.0-dev.3.0
[✗] Android toolchain - develop for Android devices
✗ ANDROID_HOME = /opt/android-sdk
but Android SDK not found at this location.
[✓] Android Studio (version 2.3)
• Android Studio at /usr/local/android-studio
• Gradle version 3.2
• Java version: OpenJDK Runtime Environment (build 1.8.0_112-release-b06)
[✓] Connected devices
• None
However, if I cd into /opt/android-sdk I get:
➜ ~ cd /opt/android-sdk
➜ android-sdk ls
add-ons build-tools emulator platforms tools
So it looks like it is there. The closest question I could find is this one: React Native android build failed. SDK location not found but it seems to be using Mac as opposed to arch as well as some other differences. How can I resolve the flutter doctor and have my app run?
I was running with the same problem when I was trying the flutter doctor command:
The problem is a little clear, it's occurring because the flutter is not founding the path for your Android SDK.
There are two ways to solve it:
You can solve this issue setting only for your current terminal instance the SDK path with the following commands:
flutter config --android-sdk /path/to/android/sdk
flutter config --android-studio-dir /path/to/android/studio
Or to save it forever, exporting the ANDROID_HOME with your Android sdk path.
I solved it by exporting the ANDROID_HOME on my machine (Arch Linux, but this works for any Unix instance).
This will solve your issue, But you can need the sdk, platform-tools, tools and the ndk-build paths too (of course, everything needs to be installed first) on my profile file (in my case the .zshrc file, the same can be done on your .bashrc and etc.):
#SDK exporting - this will solve your issue
export ANDROID_HOME=/home/{user}/Android/Sdk
#Tools exporting - it can be need in your case
export PATH=/home/{user}/Android/Sdk/platform-tools:$PATH
export PATH=/home/{user}/Android/Sdk/tools:$PATH
export PATH=/home/{user}/Android/ndk-build:$PATH
#Flutter binary exporting
export PATH=/home/{user}/flutter/bin:$PATH
Then, I reloaded my profile file (that in my is the .zshrc file, use your file in your case .eg .bashrc):
source ~/.zshrc
After that, the flutter doctor will run properly.
If you're using Android Studio 3, you can configure your platform SDK by going to File -> Project structure and choose your platform SDK.
Hope this works for you.
I have solved this problem by the following command
flutter config --android-sdk <sdk-location>
Where is the location for your sdk. If you're on windows make sure to use double quotes.
For Windows:
Inside Android Studio,
get path from : Apprearance & Behaviour > System Settings > Android SDK > Android SDK path
Make sure your path does not contain any spaces in them, if you have edit path and re-install sdk to a different location.
After that,
flutter config --android-sdk {path}
flutter doctor --android-licenses
You are set!
To get the Android SDK path
- Open Flutter project in Android Studio
- Go to File > Project Structure > SDK Location. Copy the location
To set the Android SDK path
- Type in terminal flutter config --android-sdk /path/that/you/just/copied
i have solved!
i put my android SDK before in F:/androidsdk
so when i run "flutter config" android sdk doesnt linked.
To link flutter wiht android sdk just type command below:
flutter config --android-sdk /path/to/android/sdk
i just change with this
flutter config --android-sdk F:/androidsdk
i hope this is working.
I suffered alot trying to find a solution to it and finally I found the solution by configuring the project SDK
File -> Project structure then choose sdk platform.
Go to the project structure and make sure the sdk version is selected.
Flutter requires the Android SDK platform tools so that it can use the adb command line tool.
It looks like you've installed the Android SDK but you haven't installed the platform tools yet.
Here is the android-sdk-platform-tools Aur package for arch and a guide for how to install it.
Possibly the error message could be improved to indicate that we are actually missing the Android SDK platform tools rather than the Android SDK itself. If you want to, feel free to send a pull request or open an issue.
flutter config --android-studio-dir <path where android studio is installed>
In my case it was "C:\Program Files\Android\Android Studio"
try with double quotes in the command( I tried with double quotes, which might be necessary if there is space in the path)
Source: https://flutter.dev/docs/get-started/install/windows#android-setup
It is saying that your project is using two different path of flutter-sdk. There are two place where sdk paths are defined.
Setting (Setting > Language&Frameworks > Flutter > Flutter SDK path)
local.properties in your root folder
These both place should contain same path to sdk.Compile with flutter run !! done !!
The solution at https://github.com/flutter/flutter/issues/15114#issuecomment-376582281 worked for me, this worked after adding $ANDROID_SDK_PATH\platform-tools to user path variable.
I've set up my Android SDK manually on Windows 10 with the command line, I think this not change a lot in Linux, and I was able to solve this kind of errors while I tried to set up my development environment, if you want to solve it as I did, just follow the next steps that I posted in a GitHub Comment in a related issue:
https://github.com/flutter/flutter/issues/19805#issuecomment-478306166
I hope this can help anyone need it! Bye!
in environment variables
make
Variables: ANDROID_HOME
and add path of SDK get from
Andriod stideo --> settings --> SDK Coppy the Path examlpe
:C:\Users\Omar\AppData\Local\Android
Add the SDK path in variables Value: C:\Users\Omar\AppData\Local\Android
Next Step: Add 2 value in path variables :
%ANDROID_HOME%\tools
%ANDROID_HOME%\platform-tools
For macOS Catalina:
If you have installed android sdk to a custom location (say /Users/your_username/dev/android/sdk) then follow these steps (NOTE: You must change the location according to your sdk location):
Open zshrc file
nano ~/.zshrc
Add the following to the zshrc file
export ANDROID_HOME=Users/your_username/dev/android/sdk
export ANDROID_SDK_ROOT=$ANDROID_HOME
export ANDROID_AVD_HOME=$HOME/.android/avd
Save and close nano using Ctrl+x, when prompted type y
Source your zshrc file using
source $HOME/.zshrc
You can check whether your problem is fixed by typing the following in a terminal window. You should get the sdk path as your output
echo $ANDROID_SDK_ROOT
For Windows 10 Version 2004
I added a user environment variable named ANDROID_HOME and value is {SDK-PATH}\build-tools\{SDK-VERSION}. You have to replace SDK-PATH and SDK-VERSION for your custom values.
And I appended another value named %ANDROID_HOME% to system PATH variable.
Then it worked as expected.
for me, it was very simple.
this kind of issue usually happens if IDE unable to load SDK.
so to solve this follow below steps:
goto file menu -> project structure -> project settings -> select "project"
now set Android SDK path with existing java version.
then select "modules" and configure Android SDK and click on apply and then click ok.
now we may find both ios and android emulators to run your flutter app on both devices.
You Can follow the first answer above. I would like to add a tip. If you are on windows and installed sdk on a path that requires admin rights to modify, then flutter doctor might fail to recognise the sdk. Copy the sdk folder to another non-admin location and then run flutter config --android-sdk command.
Windows command to fix SDK path
As mentioned above by others, using the below command works:
flutter config --android-sdk /path/to/android/sdk
Remember to put quotes in the /path/to/android/sdk
Example: flutter config --android-sdk "C:\Users\UserName\AppData\Local\Android\Sdk"
Under Windows 10 (without Android Studio) I noticed that folder 'sdk/build-tools' is empty. Then I solved this problem by executing:
sdkmanager build-tools;30.0.3
where 'build-tools;30.0.3' was obtained in an output of "sdkmanager --list >list.txt" command.
And, after build-tools's installation the error "Android SDK cannot be found by flutter" was solved too!
PS. It is absolutely essential to read carefully the documentation (there were although another mistakes by me)
PS.PS. The log (for illustration):
[√] Flutter (Channel stable, 1.22.6, on Microsoft Windows [Version 10.0.17763.1697], locale ru-UA)
[!] 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/docs/get-started/install/windows#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.
X No valid Android SDK platforms found in d:/Android\SDK\platforms. Candidates were:
- android-13
- android-19
- android-23
- android-29
[!] Android Studio
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
X android-studio-dir = d:\Android
X Unable to find bundled Java version.
[√] VS Code (version 1.53.1)
[!] Connected device
! No devices available
! Doctor found issues in 3 categories.
C:\Users\Леон>sdkmanager build-tools;30.0.3
[=======================================] 100% Unzipping... android-11/renderscr
C:\Users\Леон>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 1.22.6, on Microsoft Windows [Version 10.0.17763.1697], locale ru-UA)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[!] Android Studio
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
X android-studio-dir = d:\Android
X Unable to find bundled Java version.
[√] VS Code (version 1.53.1)
[!] Connected device
! No devices available
! Doctor found issues in 3 categories.
C:\Users\Леон>
I had a similar error. Adding Flutter path of extracted flutter sdk till flutter fixed it
In my case, I have to accept the android licenses
run this command in the terminal or android studio terminal
flutter doctor --android-licenses
We need to fix this in the tool. You can work around this locally by running flutter config --android-studio-dir='C:\Program Files\Android\Android Studio' , which you can check with explorer. For me this path is C:\Program Files\Android\Android Studio\

Categories

Resources