简体   繁体   中英

Problem while setting up Flutter in Android Studio

I'm trying to setup Flutter on Android Studio but when I'm running the default counter app present in Flutter, although the project is getting built successfully, while running it is giving an exception and exiting execution.

Running Gradle task 'assembleDebug'...
Exception: Gradle task assembleDebug failed with exit code -1

When I run flutter doctor in command prompt, I receive the following:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.17.5, on Microsoft Windows [Version 10.0.18363.959], locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
    X Android license status unknown.
      Try re-installing or updating your Android SDK Manager.
      See https://developer.android.com/studio/#downloads or visit visit
      https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions.
[√] Android Studio (version 4.0)
[√] Connected device (1 available)

And then when I run flutter doctor --android-licenses, it shows this:

Android sdkmanager tool not found (C:\Users\siddp\AppData\Local\Android\Sdk\tools\bin\sdkmanager).
Try re-installing or updating your Android SDK,
visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions.

I've installed the latest flutter SDK from the official flutter site: https://storage.googleapis.com/flutter_infra/releases/stable/windows/flutter_windows_1.17.5-stable.zip

I've also saved the Path variable in the system & user environment variables. I've also downloaded & installed the Flutter and Dart plugins in Android Studio. My Android Studio has the latest SDKs and their version is compatible with the virtual device(and physical device as well). I've also downloaded all the tools from the SDK manager. There is no issue with my Android Studio running a normal Android application; it is only causing a problem for a Flutter app. I've also tried reinstalling everything(Flutter, Android Studio, even Java) but still I'm unable to get it to execute. I've also tried troubleshooting with various online solutions from StackOverflow and GitHub among others; I can't link them all as there are many and I've been doing this for the last 5 days.

Every solution is appreciated. Thank You !

(1) Android Studio > SDK Manager > Android SDK > SDK Tools > Uncheck "Hide Obsolete Packages" > Check "Android SDK Tools" (Obsolete) > OK to Install

(2) flutter doctor --android-licenses

Added (3): Can you check if Android Studio > SDK Manager > Android SDK > SDK Platforms > Is the latest API Level installed?

I also recently setup Flutter, but without Android Studio, by downloading Android SDK directly. So 2 things -

  1. Android sdkmanager tool not found (C:\Users\siddp\AppData\Local\Android\Sdk\tools\bin\sdkmanager)

So, is the sdkmanager present at this location & not detected or not present at all?

  1. I think flutter may not have been configured with Android_sdk path. So, can you set that -> flutter config --android-sdk <path-to-android-sdk>

Post this, try flutter doctor --android-licenses

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM