'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:

  1. Open your terminal
  2. type flutter doctor --android-licenses
  3. press y to accept every license.

Solution 2:[2]

This worked for me to solve the problem,

  1. Open android studio(close project if any is open) >> Configure >> Appearance & Behavior >> Android SDK
  2. Go to SDK Tools tab
  3. Install Android SDK Command-line Tools (latest)
  4. Open cmd and run yes | flutter doctor --android-licenses.

enter image description here

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:

  1. Execute command prompt as administrator.
  2. Run the command flutter doctor --android-licenses and accept all licenses.
  3. Run the command flutter doctor -v to check if the issue was solved.
  4. To make sure that is everything is ok, execute the command prompt as a regular user (your user) and execute flutter doctor -v again.

enter image description here

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]

  1. Open Android Studio
  2. File ? Settings ? Appearance & Behavior ? Android SDK ? SDK Tools ? Checklist Android SDK Command-line Tools (lastest) ? Apply ? Download. enter image description here

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:

  1. Open Environment Variable

  2. At System Variable Box

  3. Click Comspec and Edit

  4. On the Variable Value, i paste C:\WINDOWS\System32\cmd.exe

  5. 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

  1. Android SDk
  2. sdkmanager
  3. Java
  4. Flutter

Note:- update variable path with your sys path for example update variable path

  1. Execute command prompt as administrator; Run the command flutter doctor --android-licenses
  2. press y to accept every license.;
  3. flutter doctor -v to 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!

  1. 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.8
    
  2. In the command line just run flutter doctor --android-licenses accept 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

  1. Rename C:\Users\%username%\AppData\Local\Android\Sdk\tools folder to tool

  2. Navigate to cd C:\Users\%username%\AppData\Local\Android\Sdk\tool\bin in cmd

  3. And run sdkmanager --update --verbose, will create a new folder tools

  4. Run flutter doctor --android-licenses

  5. Then Accept the android licenses by clicking y

  6. to check flutter doctor if 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

  1. android studio>>files>>search android sdk>> select SDK tools(TAB)
  2. then select android sdk platform tools(uncheck) then click on apply WAIT
  3. now go back to SDK tools(TAB) then select android sdk platform tools(check) then click on apply
  4. Now run flutter doctor --android-licensesin cmd with admin rights
  5. click on y and accept all. Hope the above steps helped you solve the problem.