DmDev
DmDev

Reputation: 602

Could not determine the dependencies of task ':app:compileDebugJavaWithJavac' in flutter

Flutter was working perfectly on previous device. I have changed my laptop, after all the setup I am getting this error I am unable to understand this error.

  1. please explain what is this error for.

  2. Solution for this error

I am just running very basic application.

app gradle

> def localProperties = new Properties() def localPropertiesFile =
> rootProject.file('local.properties') if (localPropertiesFile.exists())
> {
>     localPropertiesFile.withReader('UTF-8') { reader ->
>         localProperties.load(reader)
>     } }
> 
> def flutterRoot = localProperties.getProperty('flutter.sdk') if
> (flutterRoot == null) {
>     throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") }
> 
> def flutterVersionCode =
> localProperties.getProperty('flutter.versionCode') if
> (flutterVersionCode == null) {
>     flutterVersionCode = '1' }
> 
> def flutterVersionName =
> localProperties.getProperty('flutter.versionName') if
> (flutterVersionName == null) {
>     flutterVersionName = '1.0' }
> 
> apply plugin: 'com.android.application' apply plugin: 'kotlin-android'
> apply from:
> "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
> 
> android {
>     compileSdkVersion 29
> 
>     sourceSets {
>         main.java.srcDirs += 'src/main/kotlin'
>     }
> 
>     lintOptions {
>         disable 'InvalidPackage'
>     }
> 
>     defaultConfig {
>         // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
>         applicationId "com.example.flutter_app"
>         minSdkVersion 16
>         targetSdkVersion 29
>         versionCode flutterVersionCode.toInteger()
>         versionName flutterVersionName
>     }
> 
>     buildTypes {
>         release {
>             // TODO: Add your own signing config for the release build.
>             // Signing with the debug keys for now, so `flutter run --release` works.
>             signingConfig signingConfigs.debug
>         }
>     } }
> 
> flutter {
>     source '../..' }
> 
> dependencies {
>     implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" }

android gradle

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Logcat: Please configure Android SDK

Terminal report

 C:\Users\HP\StudioProjects\flutter_app>flutter run
    Using hardware rendering with device sdk gphone x86. If you notice graphics artifacts, consider enabling software rendering with "--enable-software-rendering".
    Launching lib\main.dart on sdk gphone x86 in debug mode...
    Checking the license for package Android SDK Build-Tools 28.0.3 in C:\Users\HP\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 29 in C:\Users\HP\AppData\Local\Android\sdk\licenses
    Warning: License for package Android SDK Platform 29 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-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\HP\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 1s
    Running Gradle task 'assembleDebug'...
    Running Gradle task 'assembleDebug'... Done                         2.5s
    Exception: Gradle task assembleDebug failed with exit code 1

Flutter doctor - V

[√] Flutter (Channel stable, 1.22.0, on Microsoft Windows [Version 10.0.18362.1082], locale en-US)
    • Flutter version 1.22.0 at C:\src\flutter
    • Framework revision d408d302e2 (4 days ago), 2020-09-29 11:49:17 -0700
    • Engine revision 5babba6c4d
    • Dart version 2.10.0


[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at C:\Users\HP\AppData\Local\Android\sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses

[√] Android Studio (version 4.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 50.0.1
    • Dart plugin version 193.7547
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] VS Code (version 1.49.2)
    • VS Code at C:\Users\HP\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.14.1

[√] Connected device (1 available)
    • sdk gphone x86 (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator)

! Doctor found issues in 1 category.

Upvotes: 0

Views: 3820

Answers (3)

Kartik Gupta
Kartik Gupta

Reputation: 43

Apparently, what you can do is simply head to your Android SDK directory and

cd "/tools/bin"

and run the following command

 sdkmanager --licenses

and let the terminal do its job !

Upvotes: 1

ARMEL FOPA
ARMEL FOPA

Reputation: 244

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-29 Android SDK Platform 29

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 29 from https://androidsdkmanager.azurewebsites.net/SDKPlatform and unzip it into /Library/Android/sdk/platforms/android-29 if you are on mac or C:\Android\Sdk\platforms\android-29 if you are on windows

Run your project (flutter run) and enjoy

Upvotes: 0

Abhishek Ghaskata
Abhishek Ghaskata

Reputation: 1960

Run this command to accept all license from Android. flutter doctor --android-licenses and download sdk manager and build tools from Android studio

Upvotes: 3

Related Questions