66

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,802
  • 6
  • 23
  • 34
  • 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

23 Answers23

117

try these:

  1. Open your terminal
  2. type flutter doctor --android-licenses
  3. press y to accept every license.
Muhammad Fauzi Masykur
  • 1,994
  • 1
  • 15
  • 18
  • mine didn't show me anything ... 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 Oct 02 '21 at 05:39
  • 5
    For CI systems - use `yes | flutter doctor --android-licenses` to avoid the prompt – Meir Gabay Dec 14 '21 at 15:36
  • @MeirGabay that one actually worked for me, though I don't realy understand why. Isn't this the same as answering the prompt with "y"? – Hkrie Jul 19 '22 at 19:57
  • @Hkrie to be honest, I got to a point where I don’t care as long as it works, took me a few hours to make it run in my CI – Meir Gabay Jul 20 '22 at 10:45
  • @MeirGabay, I am also facing the same issue and this command doesn't work for me. it says as 'yes' not recognized. Have you faced any issues like this with the latest android studio version 4.2 and android SDK version 33. – srk_sync Oct 20 '22 at 04:31
  • I have followed your suggestion but it is still taking more than 30 minutes, still waiting.... – Kamlesh Aug 28 '23 at 02:14
82

This worked for me to solve the problem,

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

enter image description here

Then open the command prompt software and run flutter doctor

Kamlesh
  • 5,233
  • 39
  • 50
35

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
  • 14,885
  • 4
  • 25
  • 52
Marco Antonio
  • 557
  • 6
  • 15
  • 3
    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
  • @Emil right on point. This was exactly it, this should be the first step to resolve this. – NewBie1234 Apr 08 '23 at 13:46
31

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

Zoe
  • 27,060
  • 21
  • 118
  • 148
Ahmed Elkoussy
  • 8,162
  • 10
  • 60
  • 85
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
  • 521
  • 5
  • 9
8
  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
  • 892
  • 10
  • 27
FiqSky
  • 2,250
  • 1
  • 9
  • 8
7

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
  • 246
  • 4
  • 6
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 verifying solution)

Kamlesh
  • 5,233
  • 39
  • 50
harun_me
  • 111
  • 1
  • 4
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
  • 4,404
  • 3
  • 42
  • 58
1

My problem with Windows was that when I ran the flutter command doctor --android-licenses, I was using git for windows, and the process would hang after selecting the letter y and pressing enter. I tried using CMD and it worked. I was able to accept the missing licenses.

Quimbo
  • 634
  • 6
  • 17
0

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

Ranjul Arumadi
  • 109
  • 1
  • 2
  • 11
Mukesh Gupta
  • 101
  • 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,805
  • 1
  • 28
  • 38
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
  • 180
  • 4
0

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
  • 30,962
  • 25
  • 85
  • 135
Phil
  • 21
  • 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
0

i faced the same issue in Linux today and below solution worked for me:

android-sdk is saved in /opt and the path will be /opt/android-sdk.

run sudo /opt/android-sdk/cmdline-tools/latest/bin/sdkmanager --licenses.

and if u run flutter doctor -v it will ask for licenses again.

Note: i am using android cli cmd tools not android studio.

shiva
  • 5,083
  • 5
  • 23
  • 42
0

try these for resolve this problem:-

1- Open your cmd from run win + R

enter image description here

2- run this flutter doctor --android-licenses in cmd and press Enter key.

enter image description here

3- press y to accept every license.

enter image description here

enter image description here

4- finally All SDK package licenses accepted.

enter image description here

5- run flutter doctor -v

-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,533
  • 4
  • 29
  • 51
-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,457
  • 2
  • 21
  • 38
-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

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

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

Reyad Khan
  • 1
  • 1
  • 2