任务':path_provider_android:compileDebugJavaWithJavac'执行失败

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

我的 android studio 遇到这个问题,所以每当我在 android studio 中运行实际的默认 flutter 项目时,它就会运行。一旦我在 pubspec.yaml 中添加包,我就会收到错误。我正在尝试运行一个项目,该项目已经运行良好一段时间了。突然,当我回到该项目并运行它时,我收到了这个奇怪的错误。我问ChatGPT,说是jdk不兼容问题。这是错误。


    Launching lib\main.dart on AOSP on IA Emulator in debug mode...
    Running Gradle task 'assembleDebug'...
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':path_provider_android:compileDebugJavaWithJavac'.
    > Could not resolve all files for configuration ':path_provider_android:androidJdkImage'.
       > Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
          > Execution failed for JdkImageTransform: C:\Users\Mr. Wolfe\AppData\Local\Android\sdk\platforms\android-34\core-for-system-modules.jar.
             > Error while executing process C:\Program Files\Android\Android Studio\jbr\bin\jlink.exe with arguments {--module-path C:\Users\Mr. Wolfe\.gradle\caches\transforms-3\4a46fc89ed5f9adfe3afebf74eb8bfeb\transformed\output\temp\jmod --add-modules java.base --output C:\Users\Mr. Wolfe\.gradle\caches\transforms-3\4a46fc89ed5f9adfe3afebf74eb8bfeb\transformed\output\jdkImage --disable-plugin system-modules}
    
    * 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 9s
    Error: Gradle task assembleDebug failed with exit code 1

这就是我的 app/build.gradile 的样子;


    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"
    }
    
    android {
        namespace = "com.example.new_flutter"
        compileSdk = flutter.compileSdkVersion
        ndkVersion = flutter.ndkVersion
    
        compileOptions {
            sourceCompatibility = JavaVersion.VERSION_1_8
            targetCompatibility = JavaVersion.VERSION_1_8
        }
    
        kotlinOptions {
            jvmTarget = JavaVersion.VERSION_1_8
        }
    
        defaultConfig {
            // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
            applicationId = "com.example.new_flutter"
            // You can update the following values to match your application needs.
            // For more information, see: https://flutter.dev/to/review-gradle-config.
            minSdk = flutter.minSdkVersion
            targetSdk = flutter.targetSdkVersion
    //        multiDexEnabled true
            versionCode = flutter.versionCode
            versionName = flutter.versionName
        }
    
        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 = "../.."
    }

java flutter dart android-studio gradle
1个回答
0
投票

我没有在 Flutter 项目中使用 Android Studio,因为我发现使用 VS Code 很方便。然而,

据你说,

我正在尝试运行一个项目,这个项目运行得很好 有一段时间了。当我回到项目时突然 运行它我得到这个奇怪的错误。

您尝试过Flutter clean 和rebuild吗?您的情况是确保构建的缓存不会与项目构建的当前状态冲突。

为了帮助您,我做了一些研究以了解如何在 Android Studio 中执行此操作。那么具体方法如下:如何清除 Flutter 的构建缓存?

希望有帮助! 😉

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