How to accept licenses with flutter doctor?

2019-07-30 05:09发布

问题:

When running flutter doctor in the cmd it is indicated that android licenses need to be accepted by running the command flutter doctor --android-licenses.

Running the command got me an error that a repositories.cfg could not be found at a specific directory. I did create the empty file in the directory and waited 4~5 minutes as suggested in this SO post repositories.cfg could not be loaded.

Running the command again results in a new error:

Warning: An error occurred during installation: Failed to move away or delete existing target file: C:\installs\sdk\tools Move it away manually and try again..

Deleting the tools folder did not solve the issue.

What do I have to do to be prompted to accept the Android licenses?

回答1:

A way to resolve the issue is to copy the tools folder to another place (e. g. C:\temp). Then navigate the cmd to the directory with cd C:\temp\tools\bin

sdkmanager.bat --sdk_root=YOUR_DIRECTORY_HERE --licenses

YOUR_DIRECTORY_HERE should be replaced with the path to your original SDK folder (C:\installs\sdk). Once that is done, delete the C:\temp\tools copied folder.

This answer was influenced by Can't update \tools - Android SDK Command Line Tools for Windows