【问题标题】:Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'. - Flutter Issue无法确定任务 ':app:compileDebugJavaWithJavac' 的依赖关系。 - 颤振问题
【发布时间】:2020-10-25 20:00:24
【问题描述】:

尝试运行 Flutter 应用并遇到此问题。尝试了所有解决方案,但没有成功。以下是我在运行应用程序时收到的错误。任何帮助将不胜感激。

谢谢!

Running "flutter pub get" in sample_app...
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all dependencies for configuration ':app:debugCompileClasspath'.
   > Problems reading data from Binary store in /private/var/folders/lj/7jcbbmp507v0bxbdfnlh56_c0000gn/T/gradle6036859919611612075.bin offset 322825 exists? true

* 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 1s
Exception: Gradle task assembleDebug failed with exit code 1

扑医生结果:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.20.3, on Mac OS X 10.15.7 19H2, locale en)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 12.1)
[✓] Android Studio (version 4.0)
[✓] VS Code (version 1.50.1)
[✓] Connected device (1 available)

• No issues found!

app/build.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: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 28

    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.sample_app"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    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"
    implementation 'com.android.support:multidex:1.0.3'
    //implementation 'com.google.firebase:firebase-messaging:<latest_version>'
    //implementation 'com.google.firebase:firebase-analytics'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

android/build.gradle

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

    dependencies {
        classpath 'com.google.gms:google-services:4.3.3'
        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
}

【问题讨论】:

  • 运行颤振医生并分享其输出
  • 编辑了上面的答案。请检查
  • 你的 build.gradle 文件呢?可以分享一下吗?
  • @Akif 添加了两个 build.gradles。请检查
  • 你能试试这个吗:stackoverflow.com/a/33404698/10659482

标签: android flutter gradle plugins


【解决方案1】:

尝试使用命令升级flutter

颤振升级

【讨论】:

    【解决方案2】:

    我也遇到了同样的问题。它刚刚开始,没有任何理由或代码更改。在我升级flutter然后又回到之前的flutter版本时不小心解决了:

    flutter upgrade    
    flutter downgrade vX.X.X
    

    【讨论】:

      猜你喜欢
      • 2020-10-28
      • 1970-01-01
      • 2021-09-10
      • 2020-04-15
      • 2019-12-23
      • 2021-06-18
      • 2021-09-02
      • 2021-10-26
      • 2022-01-05
      相关资源
      最近更新 更多