无法确定任务':url_launcher_android:compileReleaseJavaWithJavac'的依赖关系

问题描述 投票:0回答:1

它以前工作得更好,但是当我将 Android Studio 更新到 Ladybug 时,一切都开始了。我的java版本和一切都改变了,最糟糕的是我不记得我的旧设置。那么,问题就在下面。 当我尝试调试或构建 apk 时,flutter 项目显示此错误:

* What went wrong:
Could not determine the dependencies of task ':url_launcher_android:compileReleaseJavaWithJavac'.
> Cannot query the value of this provider because it has no value available.

* 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

这与许多此类库有关,例如:url_launcher、share_pluse、shared_preferences 和 path_provider。 下面是flutter doctor

[√] Flutter (Channel stable, 3.24.3, on Microsoft Windows [Version 10.0.22621.3880], locale en-US)
    • Flutter version 3.24.3 on channel stable at D:\Installed\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2663184aa7 (5 weeks ago), 2024-09-11 16:27:48 -0500
    • Engine revision 36335019a8
    • Dart version 3.5.3
    • DevTools version 2.37.3

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at D:\Android\Sdk
    • Platform android-35, build-tools 35.0.0
    • Java binary at: D:\Installed\AndroidStudio\jbr\bin\java
    • Java version Java(TM) SE Runtime Environment (build 17.0.12+8-LTS-286)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2022 17.8.2)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools
    • Visual Studio Build Tools 2022 version 17.8.34322.80
    • Windows 10 SDK version 10.0.22621.0

[√] Android Studio (version 2024.2)
    • Android Studio at D:\Installed\AndroidStudio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version Java(TM) SE Runtime Environment (build 17.0.12+8-LTS-286)

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.22621.3880]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 129.0.6668.101
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 126.0.2592.68

[√] Network resources
    • All expected network resources are available.

• No issues found!

gradle.属性

org.gradle.jvmargs=-Xmx4G -XX:+HeapDumpOnOutOfMemoryError
android.useAndroidX=true
android.enableJetifier=true

gradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip

设置.gradle

pluginManagement {
    def flutterSdkPath = {
        def properties = new Properties()
        file("local.properties").withInputStream { properties.load(it) }
        def flutterSdkPath = properties.getProperty("flutter.sdk")
        assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
        return flutterSdkPath
    }()

    includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}

plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version "7.3.1" apply false
    id "org.jetbrains.kotlin.android" version "1.7.10" apply false
}

include ":app"

应用程序/build.gradle

plugins {
    id "com.android.application"
    id "kotlin-android"
    // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
    id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file("local.properties")
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader("UTF-8") { reader ->
        localProperties.load(reader)
    }
}

def flutterVersionCode = localProperties.getProperty("flutter.versionCode")
if (flutterVersionCode == null) {
    flutterVersionCode = "2"
}

def flutterVersionName = localProperties.getProperty("flutter.versionName")
if (flutterVersionName == null) {
    flutterVersionName = "1.0"
}

android {
    namespace = "com.example.xxxx"
    compileSdk = 35
    ndkVersion = flutter.ndkVersion

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId = "com.example.xxxxx"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdk = flutter.minSdkVersion
        targetSdk = flutter.targetSdkVersion
        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 = "../.."
}


这一切都是因为share_plus而发生的。在一切正常之前,但 share_pluse 需要 java 17 才能工作。

帮我解决它。

我已经尝试了很多 gradle 版本,但没有任何效果适合我。我还将 android studio 运行时版本更改为 17.0.12...但没有工作。

请帮我解决它......请..

flutter dart url-launcher share-plus ladybug
1个回答
0
投票

有同样的问题 所以首先从各自的网站下载jdk17。然后在项目的终端中使用此命令

flutter config --jdk-dir /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home

从“/Library”到“/Home”就是你想要的jdk位置。

这是另一个对我有用的修复https://stackoverflow.com/a/73985328/8764293

© www.soinside.com 2019 - 2024. All rights reserved.