pixel
pixel

Reputation: 10587

Flutter Does Not Recognize Android SDK Build-Tools 25.0.3

Literary, just started looking at Flutter, installed the Flutter plug in in Android Studio 3.0.1, restarted Android Studio, created a simple hello world app according to Flutter documentation.

This also installed Flutter SDK in C:\flutter, so app creation process selected that location for SDK location correctly.

However, running app (on emulator), shows me this error

Launching lib\main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
Finished with error: 

* Error running Gradle:
Unable to download needed Android SDK components, as the following licenses have not been accepted:
Android SDK Build-Tools 25.0.3

To resolve this, please run the following command in a Terminal:
flutter doctor --android-licenses

But when I look in Android SDK, every Build-Tools from 25.0.0 to 27.0.1 is installed including 25.0.3.

Running flutter doctor --android-licenses from terminal as suggested above shows this error

C:\Users\user\Desktop\work\flutter\first_flutter_app>doctor --android-licences
'flutter' is not recognized as an internal or external command,
operable program or batch file.

UPDATE

Then I added my C:\flutter\bin to system path and tried again issuing

flutter doctor --android-licenses

but got error "Unknown argument --licenses".

Next I run:

flutter upgrade

this completed, too but running my app still produced same error re license issue.

flutter upgrade shows following output:

Running flutter doctor...
[√] Flutter (on Microsoft Windows [Version 10.0.15063], locale en-US, channel alpha)
    • Flutter at C:\flutter
    • Framework revision d957c8f040 (4 days ago), 2017-11-30 13:29:59 -0800
    • Engine revision 77d8acb9be
    • Tools Dart version 1.25.0-dev.11.0
    • Engine Dart version 2.0.0-dev.9.0

[√] Android toolchain - develop for Android devices (Android SDK 25.0.2)
    • Android SDK at C:\Program Files (x86)\Android\android-sdk
    • Unable to locate Android NDK.

    • Unable to locate compiler in Android NDK.

    • Platform android-25, build-tools 25.0.2
    • ANDROID_HOME = C:\Program Files (x86)\Android\android-sdk
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)

[√] Android Studio (version 3.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)

[√] Connected devices
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 7.1.1 (API 25) (emulator)

I literaly keep going in circles with this. Here is what happens when I run my app from terminall using flutter (above I explained what happens if I run it from the IDE:

C:\Users\user\Desktop\work\flutter\flutter_app_myapp>flutter run
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...                                0.7s
Resolving dependencies...                                |

* Error running Gradle:
Unable to download needed Android SDK components, as the following licenses have not been accepted:
Android SDK Build-Tools 25.0.3

To resolve this, please run the following command in a Terminal:
flutter doctor --android-licenses                                                                                                        /
C:\Users\user\Desktop\work\flutter\flutter_app_myapp>>flutter doctor --android-licenses
Error: Unknown argument --licenses

UPDATE2

Output of flutter -v doctor --android-licenses

C:\Users\user\Desktop\work\flutter\flutter_app_dino>flutter -v doctor --android-licenses
[  +23 ms] [C:\flutter\] git rev-parse --abbrev-ref --symbolic @{u}
[  +45 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] origin/alpha
[        ] [C:\flutter\] git rev-parse --abbrev-ref HEAD
[  +20 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] alpha
[        ] [C:\flutter\] git ls-remote --get-url origin
[  +19 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[        ] [C:\flutter\] git log -n 1 --pretty=format:%H
[  +20 ms] Exit code 0 from: git log -n 1 --pretty=format:%H
[        ] d957c8f040902aa3fd44b367150bde56b64cec83
[        ] [C:\flutter\] git log -n 1 --pretty=format:%ar
[  +21 ms] Exit code 0 from: git log -n 1 --pretty=format:%ar
[        ] 5 days ago
[ +222 ms] C:\Program Files (x86)\Android\android-sdk\tools\bin\sdkmanager.bat --licenses
**Error: Unknown argument --licenses**
Usage:
  sdkmanager [--uninstall] [<common args>] \
    [--package_file <package-file>] [<packages>...]
  sdkmanager --update [<common args>]
  sdkmanager --list [<common args>]

In its first form, installs, or uninstalls, or updates packages.
    <package> is a sdk-style path (e.g. "build-tools;23.0.0" or
             "platforms;android-23").
    <package-file> is a text file where each line is a sdk-style path
                   of a package to install or uninstall.
    Multiple --package_file arguments may be specified in combination
     with explicit paths.
In its second form (with --update), currently installed packages are
    updated to the latest version.
In its third form, all installed and available packages are printed out.

Common Arguments:
    --sdk_root=<sdkRootPath>: Use the specified SDK root instead of the SDK containing this tool
    --channel=<channelId>: Include packages in channels up to <channelId>.
                           Common channels are:
                           0 (Stable), 1 (Beta), 2 (Dev), and 3 (Canary).

    --include_obsolete: With --list, show obsolete packages in the
                        package listing. With --update, update obsolete
                        packages as well as non-obsolete.
    --no_https: Force all connections to use http rather than https.
    --proxy=<http | socks>: Connect via a proxy of the given type.
    --proxy_host=<IP or DNS address>: IP or DNS address of the proxy to use.
    --proxy_port=<port #>: Proxy port to connect to.

* If the env var REPO_OS_OVERRIDE is set to "windows",
  "macosx", or "linux", packages will be downloaded for that OS.
[ +152 ms] "flutter doctor" took 301ms.
[ +198 ms] ensureAnalyticsSent: 196ms
[   +2 ms] exiting with code 0

However, if I navigate to my Android\sdk\tools\bin, I do have sdkmanager and issuing sdkmanager --licenses from there shows:

C:\Users\user\AppData\Local\Android\sdk\tools\bin>sdkmanager --licenses
All SDK package licenses accepted.======] 100% Computing updates...

So, it looks like Flutter is full of bugs at the moment, not sure if it is worth spending time with it at this alpha stage, as you can see, I have several circular problems where it says it cannot find a command, but the command exists. I followed exact installation steps and if it takes days to figure it out and still have no solution, I'd say, it is not even close to being ready.

Upvotes: 3

Views: 5532

Answers (1)

Amit Toren
Amit Toren

Reputation: 353

The reason you're getting this error when running flutter doctor is because you didn't put the flutter.bat location file in your PATH (Windows environment variable). Or maybe flutter just screwed up.
Let's say you don't wanna do it, just refer to flutter as "$FLUTTER_DIR\bin\flutter" doctor --android-licences.

Upvotes: 3

Related Questions