Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 484
Mneckoee Avatar asked Feb 04 '18 05:02

Mneckoee


People also ask

How do I accept my SDK license agreement?

Open a terminal 2. Write: "cd $ANDROID_HOME/tools/bin (this path can be /home/your-user/Android/Sdk/tools/bin)" 3. Write: "./sdkmanager --licenses" 4. To accept All licenses listed, write: "y" 5.

How do I fix some Android licenses not accepted?

STEP 3: Open your Android Studio, File-> Settings->System settings(left tab) ->Android SDK, go to SDK Tool section on that page, untick hide obsolete packages, select Android SDL tools(obsolete) and press apply.


2 Answers

try these:

  1. Open your terminal
  2. type flutter doctor --android-licenses
  3. press y to accept every license.
like image 197
Muhammad Fauzi Masykur Avatar answered Sep 27 '22 18:09

Muhammad Fauzi Masykur


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

like image 34
Nisansali Nikapotha Avatar answered Sep 27 '22 18:09

Nisansali Nikapotha