'Flutter run error : You have not accepted the license agreements
I'm developing android and ios app with Google flutter.
when I add a new dependency like shared_preferences to pubspec.yaml and then execute flutter run in terminal, I got this error:
- What went wrong: A problem occurred configuring project ':shared_preferences'.
 
You have not accepted the license agreements of the following SDK components: [Android SDK Platform 27].
I know why it happens! because the latest Android SDK platform on my system is 26 . it trys to download sdk 27 and then fails. no problem! I go to library cached folder which located here :
C:\Users...\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\shared_preferences-0.3.1\android
and edit build.gradle file and change compileSdkVersion 27 to compileSdkVersion 26. it works.
so far I have to do this for all new dependencies,
Is there any way such as defining a global build.gradle file for all dependencies? so no need to edit each buil.gradles individually.
Solution 1:[1]
try these:
- Open your terminal
 - type 
flutter doctor --android-licenses - press 
yto accept every license. 
Solution 2:[2]
This worked for me to solve the problem,
- Open android studio(close project if any is open) >> Configure >> Appearance & Behavior >> Android SDK
 - Go to SDK Tools tab
 - Install Android SDK Command-line Tools (latest)
 - Open cmd and run 
yes | flutter doctor --android-licenses. 
Then open the cmd and run flutter doctor
Solution 3:[3]
I think is a little late to answer this question, but I think this can be useful for those who are starting in Flutter like me.
In my case (at my machine), I've executed the steps below:
- Execute command prompt as administrator.
 - Run the command 
flutter doctor --android-licensesand accept all licenses. - Run the command 
flutter doctor -vto check if the issue was solved. - To make sure that is everything is ok, execute the command prompt as a regular user (your user) and execute 
flutter doctor -vagain. 
Solution 4:[4]
For me, flutter doctor --android-licenses didn't work for some reason.
The only command that worked & solved the issue was:
(your android_sdk folder exact path)\tools\bin\sdkmanager --licenses
Solution 5:[5]
First make sure Android SDK is installed on your device. Also see if 2 Android SDK's are not Installed!
Then just simply type on Terminal or CMD flutter doctor --android-licenses
Then press y until it acquires all permissions.
Solution 6:[6]
If you are in windows open command prompt as admin and run the following command.
flutter doctor --android-licenses
Then enter y for all (y/n) to accept agreement.
Solution 7:[7]
- Open Android Studio
 - File ? Settings ? Appearance & Behavior ? Android SDK ? SDK Tools ? Checklist Android SDK Command-line Tools (lastest) ? Apply ? Download.

 
3. Done.
4. Open cmd and run yes | flutter doctor --android-licenses.
Solution 8:[8]
Open the command prompt then run flutter doctor --android-licenses and accept all the licenses given.
Solution 9:[9]
For newer installations (especially on MacOS) flutter doctor --android-licenses does not work. Run the following command (notice the new path to sdk cmdline tools) and you will able to accept the licenses:
~/Library/Android/sdk/cmdline-tools/latest/bin/sdkmanager --licenses
Solution 10:[10]
I encountered the same issue when I reinstalled flutter.
What I did was, I went to Android Studio's welcome page> configuration>SDK Manager>SDK tools>
placed a check mark on ??"Android SDK Command-line Tools (latest)"
After that, I was able to run run
flutter doctor --android-licenses
and accept the SDK licenses.
It may not work for some but it did for me so I'll just share.
Solution 11:[11]
Open Android Studio:
File > Settings> Appearance & Behavior> Android SDK> SDK Tools >Checklist Android SDK Command-line Tools (latest) ? Apply ? Download.
after that run these two commands on your CLI
flutter doctor --android-licenses flutter doctor(for verify solution)
Solution 12:[12]
for me, CMD didn't show me anything, in prompt, after this command:
flutter doctor --android-licenses 
after hours find this solution:
If the command line did not show (y/n) please install CMake and NDK or install other versions of Command-line tools
Solution 13:[13]
Installing Android SDK Tools (Obsolete) 26.1.1 worked for me. I found this at another link. I will try to find and pasted here. Remember to un-select show obsolete so you can find the SDK.
After this, I was able to do Flutter doctor Android Licenses and select y.
Solution 14:[14]
First you install https://developer.android.com/studio#command-tools
Unzip You have a folder like this ...\cmdline-tools Create name "latest" folder inside cmdline-tools folder and contain other folder then copy into android-sdk path like this enter image description here
Update sdkmanager like this enter image description here
Finally run flutter doctor --android-licenses
Solution 15:[15]
Go to tools-->sdk manager--> install the android OS we have selected for the emulator and install it.
Solution 16:[16]
For me, what i did was i installed NDK and CMake Tools in Android Studio. But still doesn't work. So all i did was:
Open Environment Variable
At System Variable Box
Click Comspec and Edit
On the Variable Value, i paste C:\WINDOWS\System32\cmd.exe
Click OK and open CMD to run flutter doctor --android-licenses
Solution 17:[17]
C:\Users\bansal>flutter doctor --android-licenses
A newer version of the Android SDK is required. To update, run:
D:\android SDK\tools\bin\sdkmanager --update
    					Solution 18:[18]
I think is a little late to answer this question, but I think this can be useful for those who are starting in Flutter like me.
In my case (at my machine), I've executed the steps below:
Before run given command please make sure that you have done with environment variable setup on windows/mac/i/Linux/Unix for
- Android SDk
 - sdkmanager
 - Java
 - Flutter
 
Note:- update variable path with your sys path
for example

- Execute command prompt as administrator; Run the command 
flutter doctor --android-licenses - press 
yto accept every license.; flutter doctor -vto check if the issue was solved;
Solution 19:[19]
I had java SE 11 installed and its variables set up.
It somehow interfered with flutter!
Double-check your java path entry. Go to your java environment variables and double-check your path entry. Keep one of them in the bin and remove the other.
Mine:
C:\Program Files\Java\jdk-11.0.8\bin C:\Program Files\Java\jdk-11.0.8In the command line just run
flutter doctor --android-licensesaccept everything (by clicking y key followed by enter key).
Solution 20:[20]
I tried running flutter -v doctor --android-licenses but it looks like --android-licenses doesn't use the usual ways to launch apps.
In this case I solved it by following this command
Rename
C:\Users\%username%\AppData\Local\Android\Sdk\toolsfolder totoolNavigate to
cd C:\Users\%username%\AppData\Local\Android\Sdk\tool\binin cmdAnd run
sdkmanager --update --verbose, will create a new folder toolsRun
flutter doctor --android-licensesThen Accept the android licenses by clicking
yto check
flutter doctorif the issue was solved:
Solution 21:[21]
I had java 14 and I faced this issue until I did set java 8
Solution 22:[22]
This worked for me to solve this problem go follow the steps below
- android studio>>files>>search android sdk>> select SDK tools(TAB)
 - then select android sdk platform tools(uncheck) then click on apply WAIT
 - now go back to SDK tools(TAB) then select android sdk platform tools(check) then click on apply
 - Now run 
flutter doctor --android-licensesin cmd with admin rights - click on y and accept all. Hope the above steps helped you solve the problem.
 
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow


