繁体   English   中英

无法确定 flutter 中任务 ':app:compileDebugJavaWithJavac' 的依赖关系

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

Flutter 在之前的设备上运行良好。 我已经更换了我的笔记本电脑,在所有设置之后我收到此错误我无法理解此错误。

  1. 请解释这是什么错误。

  2. 此错误的解决方案

我只是在运行非常基本的应用程序。

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:请配置Android SDK

终端报告

 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

颤振医生-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.

运行此命令以接受来自 Android 的所有许可。 flutter doctor --android-licenses并从 Android Studio 下载 sdk 管理器和构建工具

显然,您可以做的只是前往您的 Android SDK 目录并

cd "/tools/bin"

并运行以下命令

 sdkmanager --licenses

让终端完成它的工作!

这是主要问题

由于某些许可未被接受,因此无法安装以下 Android SDK 包。 build-tools;28.0.3 Android SDK Build-Tools 28.0.3 平台;android-29 Android SDK 平台 29

如错误所示,首先通过运行以下命令接受所有许可证

颤振医生 --android-licenses

接下来转到https://androidsdkmanager.azurewebsites.net/Buildtools并下载与您在这种情况下缺少的构建工具相对应的构建工具 28.0.3 下载后将 zip 文件解压缩到C:\\Android\\Sdk\\build- tools\\28.0.3如果你在 windows 上, / Library/Android/sdk/build-tools/28.0.3如果你在 mac 上

最后,从https://androidsdkmanager.azurewebsites.net/SDKPlatform下载缺少的 Android SDK 平台 29 并将其解压缩到/Library/Android/sdk/platforms/android-29(如果您使用的是 mac 或C:\\Android\\Sdk\\)平台\\android-29如果你在 Windows 上

运行你的项目(flutter run)并享受

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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