60

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.

Community
  • 1
  • 1
Mneckoee
  • 2,422
  • 5
  • 18
  • 31
  • http://d.android.com/r/studio-ui/export-licenses.html check this – Tree Apr 09 '18 at 18:35
  • also try to install android studio and run https://developer.android.com/studio/intro/update.html#sdk-manager – Tree Apr 09 '18 at 18:35
  • if it still doesnt work, report at https://github.com/flutter/flutter/issues/8438 – Tree Apr 09 '18 at 18:36
  • See this also! (Includes screenshots.) https://stackoverflow.com/questions/60460429/android-studio-installs-without-sdkmanager – cbizzle Apr 26 '20 at 00:14
  • In Android Studio, you should check to ensure that the Android SDK Command-line Tools are installed. Adding this fixed the issue for me in Flutter. https://stackoverflow.com/a/67791870/8094969 – bm888 Jun 01 '21 at 15:36

22 Answers22

106

try these:

  1. Open your terminal
  2. type flutter doctor --android-licenses
  3. press y to accept every license.
Muhammad Fauzi Masykur
  • 1,628
  • 1
  • 13
  • 17
69

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

Pasindu Jayanath
  • 789
  • 9
  • 24
32

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

MendelG
  • 8,523
  • 3
  • 16
  • 34
Marco Antonio
  • 519
  • 6
  • 15
  • 2
    running cmd as administrator was the key point for me. If you dont run as administrator, although i said yes to all, it was still showing that licenses arent accepted – Emil Feb 20 '20 at 18:59
  • This answer should be marked as the answer. When I came to the page I scroll down the whole page to find the answer and after that, I tried this and it's working. – Feroz Khan Apr 17 '20 at 15:51
  • This is the actual answer. – Murat Can OĞUZHAN Jan 17 '21 at 00:45
  • @Emil, thank you. Additional info for all: for launch cms as administrator you should. 1. Press "win" button to open the start menu. 2. Type in the EditText "cmd" to search for Command Prompt. 3. Press ctrl+shift+enter to launch Command Prompt as administrator. – kirkadev Aug 18 '21 at 10:30
29

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

Ahmed Elkoussy
  • 7,040
  • 6
  • 51
  • 80
12

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.

Tushar Pandey
  • 431
  • 5
  • 9
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.

Hari Prasath
  • 190
  • 3
  • 6
6
  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.

Pasindu Jayanath
  • 789
  • 9
  • 24
FiqSky
  • 1,912
  • 1
  • 8
  • 8
2

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

phrogg
  • 788
  • 1
  • 12
  • 25
2

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

PearlByte
  • 59
  • 3
1

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)

saber tabatabaee yazdi
  • 3,175
  • 3
  • 39
  • 52
harun_me
  • 21
  • 3
1

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.

Dharman
  • 26,923
  • 21
  • 73
  • 125
Phil
  • 21
  • 2
1

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

saber tabatabaee yazdi
  • 3,175
  • 3
  • 39
  • 52
0

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

Ranjul Arumadi
  • 101
  • 1
  • 2
  • 10
Mukesh Gupta
  • 81
  • 1
  • 1
  • 6
0

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.

Mete
  • 2,767
  • 1
  • 25
  • 37
JohnD
  • 1
0

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

CocDap
  • 39
  • 3
0

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

furqonoof
  • 1
  • 1
-1
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
Jitesh Prajapati
  • 2,661
  • 4
  • 28
  • 47
-1

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;
Prags
  • 2,401
  • 2
  • 19
  • 37
-1

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

-1

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:

Paresh Mangukiya
  • 37,512
  • 17
  • 201
  • 182
-1

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

Reyad Khan
  • 1
  • 1
  • 2
-1

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.