升级 Android Studio 后,我的 Flutter 项目在 macOS 上无法构建

3
我刚刚升级了我的Android Studio,这导致我的Flutter构建过程出现问题。我现在尝试构建之前正常工作的项目时遇到了以下错误。附上我的Android Studio设置。感谢任何帮助。
错误:构建失败。
原因: 执行任务“:app:processDebugMainManifest”失败。 无法使私有最终字段java.io.File.path可访问:模块java.base未向未命名模块@4be5c282“打开java.io”。
尝试: 使用--stacktrace选项运行以获取堆栈跟踪。 使用--info或--debug选项运行以获取更多日志输出。 使用--scan运行以获取完整的洞察力。
https://help.gradle.org获取更多帮助。
FAILURE: Build failed with an exception.
What went wrong:
 Execution failed for task ':app:processDebugMainManifest'.
[> Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not
"opens java.io" to unnamed module @4be5c282
[        ] * 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 4s
[        ] Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
[        ] Use '--warning-mode all' to show the individual deprecation warnings.
[        ] See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings
[        ] 20 actionable tasks: 4 executed, 16 up-to-date
[ +498 ms] Running Gradle task 'assembleDebug'... (completed in 5.0s)
[+1124 ms] Exception: Gradle task assembleDebug failed with exit code 1
[  +14 ms] "flutter run" took 7,187ms.
[  +15 ms] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:663:9)
           <asynchronous suspension>
           #2      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1043:27)
           <asynchronous suspension>
           #3      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #4      CommandRunner.runCommand (package:args/command_runner.dart:196:13)
           <asynchronous suspension>
           #5      FlutterCommandRunner.runCommand.<anonymous closure>
           (package:flutter_tools/src/runner/flutter_command_runner.dart:284:9)
           <asynchronous suspension>
           #6      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #7      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:232:5)
           <asynchronous suspension>
           #8      run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
           <asynchronous suspension>
           #9      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #10     main (package:flutter_tools/executable.dart:91:3)
           <asynchronous suspension>

Android Studio北极狐|2020.3.1补丁1,构建版本#AI-203.7717.56.2031.7621141,制作于2021年8月7日,运行时版本为11.0.10+0-b96-7281165 x86_64,VM使用由JetBrains s.r.o提供的OpenJDK 64位服务器VM,在macOS 11.5.1下运行,使用G1 Young Generation和G1 Old Generation进行GC,具有1280M的内存和8个核心,外部系统自动导入已禁用,非捆绑插件为org.jetbrains.kotlin


你也是这样啊,兄弟。你找到解决方案了吗? - Ben Ajax
我遇到了问题,插件“Dart”与构建203.5981不兼容。 - puzzled
我将我的Java降级到11,然后它就可以工作了。不知道为什么。 - rami1988
2个回答

1
我更新了 Android SDK 工具和 NDK(NDK 在 SDK 工具下),才解决了我的问题。

0

我曾经遇到过同样的问题,通过安装JDK解决了它。

进入 项目结构 -> 平台设置 -> SDKs,选择一个平台,然后选择 Java SDK,并下载最新版本(你可以下载你的项目所需的版本)。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接