Flutter run error : You have not accepted the license agreements

AndroidFlutterAndroid Sdk-Tools

Android Problem Overview


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.

Android Solutions


Solution 1 - Android

try these:

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

Solution 2 - Android

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 - Android

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 - Android

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 - Android

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 - Android

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 - Android

  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.

  1. Open cmd and run yes | flutter doctor --android-licenses.

Solution 8 - Android

Open the command prompt then run flutter doctor --android-licenses and accept all the licenses given.

Solution 9 - Android

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 - Android

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 11 - Android

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 12 - Android

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 - Android

Go to tools-->sdk manager--> install the android OS we have selected for the emulator and install it.

Solution 14 - Android

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 15 - Android

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 16 - Android

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 - Android

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 - Android

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 - Android

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 - Android

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 - Android

I had java 14 and I faced this issue until I did set java 8

Solution 22 - Android

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMneckoeeView Question on Stackoverflow
Solution 1 - AndroidMuhammad Fauzi MasykurView Answer on Stackoverflow
Solution 2 - AndroidNisansali NikapothaView Answer on Stackoverflow
Solution 3 - AndroidMarco AntonioView Answer on Stackoverflow
Solution 4 - AndroidAhmed ElkoussyView Answer on Stackoverflow
Solution 5 - AndroidTushar PandeyView Answer on Stackoverflow
Solution 6 - AndroidHari PrasathView Answer on Stackoverflow
Solution 7 - AndroidFiqSkyView Answer on Stackoverflow
Solution 8 - AndroidKipngetich Emmanuel RView Answer on Stackoverflow
Solution 9 - AndroidPearlByteView Answer on Stackoverflow
Solution 10 - Androidharun_meView Answer on Stackoverflow
Solution 11 - AndroidPhilView Answer on Stackoverflow
Solution 12 - Androidsaber tabatabaee yazdiView Answer on Stackoverflow
Solution 13 - AndroidMukesh GuptaView Answer on Stackoverflow
Solution 14 - AndroidJohnDView Answer on Stackoverflow
Solution 15 - AndroidCocDapView Answer on Stackoverflow
Solution 16 - AndroidfurqonoofView Answer on Stackoverflow
Solution 17 - AndroidPrince bansalView Answer on Stackoverflow
Solution 18 - AndroidPragsView Answer on Stackoverflow
Solution 19 - AndroidDavid JúniorView Answer on Stackoverflow
Solution 20 - AndroidParesh MangukiyaView Answer on Stackoverflow
Solution 21 - AndroidReyad KhanView Answer on Stackoverflow
Solution 22 - AndroidAditya JainView Answer on Stackoverflow