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

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

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
Go To SDK Manager
Android SDK
Uncheck Installed Version
Manually Install Android version which it tried and throwing error for(see in error message)
Apply and OK
Restart
It worked for me.

Related

How to solve "target died before we could attach" message in Flutter console?

i am new to android app development, i just started learning flutter and there is so much information to take in , i downloaded a project from github to try and make sense out the things that i only read about online and when i run the app this is what i get :
Screenshot1
Screenshot2
in the red boxes you can see there is a lot of things saying " target died before we could attach " what exactly is this ? is it something to be concerned about ? i tried googling it to see if i find some information about em but i couldn't find anything useful , maybe i was searching it the wrong way ...
Update: After running the "flutter doctor" this is what i got :
C:\src\flutter\flutter>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 1.22.4, on Microsoft Windows [Version 10.0.19042.631], locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
X Android license status unknown.
Run flutter doctor --android-licenses to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[!] 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 (1 available)
! Doctor found issues in 3 categories.
but i am sure that i have installed the flutter and dart plugin
I have no idea what causes this error but this is how I resolved mine.
Confirm that flutter doctor generates no errors.
Uninstall any versions of the application from your emulator.
flutter run
Now you should be okay.
From a console window that has the Flutter directory in the path, run the following command to see if there are any platform dependencies you need to complete the setup:
C:\src\flutter>flutter doctor
This command checks your environment and displays a report of the status of your Flutter installation. Check the output carefully for other software you might need to install or further tasks to perform
source here
# Edit
If the doctor command does not indicate an error, then try to create a new project and copy and paste the classes from the project you downloaded to your new project. Flutter need to download the Gradle, it may be some IDE bug that can be solved by creating a new project

why i cannot run any flutter project?

I am using android studio to run flutter project, now i can not run any project and i get the same error every time:
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-29 Android SDK Platform 29
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\moham\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 29s
Exception: Gradle task assembleDebug failed with exit code 1
it seem you did not accepted all licences after install.
Try to run this:
flutter doctor --android-licenses
and then press y every time it ask, to accept the licence
seems like duplicate of this
you should delete config Android studio folder and reinstall that whit all requirements.
C:\Users[your name folder]

Build failed- Flutter

I had to reinstall my windows and so I had to freshly install Android studio, flutter sdk and everything.
After completing all my installations I am unable to run my project. Before upgrading the system my project was working all fine with 0 errors.
Flutter doctor:
C:\Users\Admin>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.17.5, on Microsoft Windows [Version 10.0.18362.959], locale en-GB)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
[√] Android Studio (version 4.0)
[√] Connected device (1 available)
• No issues found!
Error:
Launching lib\main.dart on Mobile in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':agora_rtc_engine:extractDebugAnnotations'.
> Could not resolve all files for configuration ':agora_rtc_engine:lintClassPath'.
> Could not download kotlin-compiler.jar (com.android.tools.external.com-intellij:kotlin-compiler:26.6.3)
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/external/com-intellij/kotlin-compiler/26.6.3/kotlin-compiler-26.6.3.jar'.
> Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/external/com-intellij/kotlin-compiler/26.6.3/kotlin-compiler-26.6.3.jar'.
> dl.google.com
> Could not download uast.jar (com.android.tools.external.org-jetbrains:uast:26.6.3)
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/external/org-jetbrains/uast/26.6.3/uast-26.6.3.jar'.
> Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/external/org-jetbrains/uast/26.6.3/uast-26.6.3.jar'.
> dl.google.com
> Could not download groovy-all.jar (org.codehaus.groovy:groovy-all:2.4.15)
> Could not get resource 'https://jcenter.bintray.com/org/codehaus/groovy/groovy-all/2.4.15/groovy-all-2.4.15.jar'.
> Could not GET 'https://jcenter.bintray.com/org/codehaus/groovy/groovy-all/2.4.15/groovy-all-2.4.15.jar'.
> jcenter.bintray.com
* 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 1m 46s
Exception: Gradle task assembleDebug failed with exit code 1
This is the first time I am moving my project from my original system to this new one.
I don't have enough reputation to comment so I will write it as an answer. Since it is the first time running the app, make sure you have an internet connection so it can download the required files.
Solution:
As of now what I have done is the following:
agora_rtc_engine that was showing up as error I have removed it. (I will be re-adding this package as this is required for my app)
java jdk download i have added I was getting error on keytool to generate SHA1 Key Fingerprint.
I updated my SHA1 Key Fingerprint in Firebase. I have to do this as I was getting error when login in using Google sign-in.
Now my App is working fine with no errors.
This might not be the correct solution for the issue, so feel free to give your suggestion on the above error that I had faced.

I was running the default flutter code on android studio, and this error came up saying something about license agreement

I just installed android studio and flutter on my laptop, and i was running the default code to test my settings, but this error(exception) came up. I am very new to this, can someone help me with this error please -
Launching lib\main.dart on sdk gphone x86 arm in debug mode...
Running Gradle task 'assembleDebug'...
Checking the license for package Android SDK Build-Tools 28.0.3 in C:\Users\Shreyansh\AppData\Local\Android\sdk\licenses
Warning: License for package Android SDK Build-Tools 28.0.3 not accepted.
Checking the license for package Android SDK Platform 28 in C:\Users\Shreyansh\AppData\Local\Android\sdk\licenses
Warning: License for package Android SDK Platform 28 not accepted.
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\Shreyansh\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 19s
Exception: Gradle task assembleDebug failed with exit code 1
Open your Android Studio
Open the "Tools" menu
Select "SDK Manager"
In the following screen, make sure API Level 28 says "Installed".
If it doesn't, install it. You will have to agree to the license agreement.

Flutter Integration in android Studio issue

While integrating Flutter in Android studio getting error as * Error running Gradle: Unable to download needed Android SDK components, as the following licenses have not been accepted: Android SDK Build-Tools 26.0.2, Android SDK Platform 27 To resolve this, please run the following command in a Terminal: flutter doctor --android-licenses
Problem was with sdk path in local.properties. By default its pointing to different location. It works for me when change android sdk home dir in sdk.dir

Resources