Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'. problem on flutter

Viewed 38365

FAILURE: Build failed with an exception.

  • What went wrong: Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.

Failed to install the following Android SDK packages as some licences have not been accepted. build-tools;28.0.3 Android SDK Build-Tools 28.0.3 platforms;android-28 Android SDK Platform 28 To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager. Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html

Using Android SDK: C:\Users\emre\AppData\Local\Android\sdk

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 11s

FAILURE: Build failed with an exception.

  • What went wrong: Could not update C:\Users\emre.gradle\caches\5.6.2\file-changes\last-build.bin

C:\Users\emre.gradle\caches\5.6.2\file-changes\last-build.bin (Access is denied)

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 11s Exception: Gradle task assembleDebug failed with exit code 1

7 Answers

Apparently you should accept the license,so in your command promp:

cd /d "%ANDROID_SDK_ROOT%/tools/bin"

and then

sdkmanager --licenses

just accept the license and the error should goes away.

Here is the main problem

Failed to install the following Android SDK packages as some licenses have not been accepted. build-tools;28.0.3 Android SDK Build-Tools 28.0.3 platforms;android-28 Android SDK Platform 28

As the error suggests, first accept all licenses by running the following command

flutter doctor --android-licenses

next head over to https://androidsdkmanager.azurewebsites.net/Buildtools and download the build tool that corresponds to the one you are missing in this case 28.0.3 After downloading extract the zip file into C:\Android\Sdk\build-tools\28.0.3 if you are on windows and /Library/Android/sdk/build-tools/28.0.3 if you are on mac

finally, download the missing Android SDK platform 28 from https://androidsdkmanager.azurewebsites.net/SDKPlatform and unzip it into /Library/Android/sdk/platforms/android-28 if you are on mac or C:\Android\Sdk\platforms\android-28 if you are on windows

Run your project (flutter run) and enjoy

Try running flutter doctor on cmd. If it shows:

[√] Flutter (Channel stable, 1.22.5, on Microsoft Windows [Version 10.0.19042.685], locale en-US)

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    X Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
[!] Android Studio (version 4.1.0)
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
[!] VS Code (version 1.52.0)
    X Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[√] Connected device (0 available)  

Then run flutter doctor --android-licenses, and accept all the license agreement. The problem must be solved then.

go setting android SDK SDK Tools

and then click show package details

and Android SDK Build-Tools Download 28.0.3

Apply and ok :)

In my own case, Deleting .gradle folder solved the problem. Just head-on into your usual project dir and navigate into android and you'd find .gradle folder waving a hand in there. I hope this helps somebody out there. But make sure you have done

flutter doctor --andriod-licences

Don't do anything, like changing the SDK path or updating tools.

At first, what you should try to do is this:

Remove your physical device from your machine which is connected via USB and instead of the physical device, run your application on a browser (I suggest Chrome) and if there is no other issue then you will find the error will have been tackled. So I am saying that the problem is neither in the path nor in the software or code. Please try this suggestion first, because I wasted a full day trying to tackle this problem!

We just need to install proper Android version manually

  1. Go To SDK Manager
  2. Android SDK
  3. Uncheck Installed Version
  4. Manually Install Android version which it tried and throwing error for(see in error message)
  5. Apply and OK
  6. Restart

It worked for me.

Related