如何修复flutter应用程序中的“jvm目标兼容性应设置为相同的Java版本”?

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

我有一个不简单的 flutter 应用程序,我只在 Linux 桌面上进行测试。当我尝试在 Android 模拟器上测试它时,出现以下错误:

在 sdk gphone64 x86 64 上以调试模式启动 lib/main.dart...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':receive_sharing_intent:compileDebugKotlin'.
> 'compileDebugJavaWithJavac' task (current target is 1.8) and 'compileDebugKotlin' task (current target is 17) jvm target compatibility should be set to the same Java version.

为了尝试修复它,我在同一台计算机上创建了一个新的 flutter 项目,并将以下文件从新的工作项目复制到我的真实项目(相应地更改应用程序名称/id):

  • android/settings.gradle
  • android/build.gradle
  • android/app/build.gradle

此外,两者返回完全相同的flutter doctor -v输出:

[✓] Flutter (Channel stable, 3.24.4, on Fedora Linux 41 (Xfce) 6.11.6-300.fc41.x86_64, locale en_US.utf8)
    • Flutter version 3.24.4 on channel stable at /usr/local/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 603104015d (2 weeks ago), 2024-10-24 08:01:25 -0700
    • Engine revision db49896cf2
    • Dart version 3.5.4
    • DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /home/rodrigo/Android/Sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /usr/lib/jvm/java-17-openjdk-17.0.13.0.11-1.fc41.x86_64/bin/java
    • Java version OpenJDK Runtime Environment (Red_Hat-17.0.13.0.11-1) (build 17.0.13+11)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 19.1.0 (Fedora 19.1.0-1.fc41)
    • cmake version 3.30.5
    • ninja version 1.12.1
    • pkg-config version 2.3.0

[✓] Android Studio (version 2024.2)
    • Android Studio at /home/rodrigo/android-studio-2024.1.1.12
    • Flutter plugin version 82.1.3
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.3+-12282718-b509.11)

[✓] VS Code (version 1.95.2)
    • VS Code at /usr/share/code
    • Flutter extension version 3.100.0

[✓] Connected device (3 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 14 (API 34) (emulator)
    • Linux (desktop)              • linux         • linux-x64      • Fedora Linux 41 (Xfce) 6.11.6-300.fc41.x86_64
    • Chrome (web)                 • chrome        • web-javascript • Google Chrome 130.0.6723.116

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

• No issues found!

新的简单项目在 Android 模拟器上运行得很好。我真正的应用程序没有。我还应该在真实应用程序上检查或更改哪些内容?

flutter
1个回答
0
投票

问题来自 receive_sharing_intent 库。 master 分支上已经有修复,但新版本尚未发布。

作为目前的解决方法,您可以通过在

pubspec.yaml
:

中使用来定位修复提交
receive_sharing_intent:
  git:
    url: https://github.com/KasemJaffer/receive_sharing_intent
    ref: 2cea396843cd3ab1b5ec4334be4233864637874e
© www.soinside.com 2019 - 2024. All rights reserved.