在 Android Studio 中构建失败的 Flutter 项目
Posted
技术标签:
【中文标题】在 Android Studio 中构建失败的 Flutter 项目【英文标题】:Build failed Flutter project in Android studio 【发布时间】:2021-12-07 13:54:18 【问题描述】:我将android Studio升级到Arctic Fox 2020.3.1 Patch 3,但是在构建项目时flutter项目失败了。以前效果很好。
这是错误日志:
Launching lib/main.dart on SM G935S in debug mode...
Running Gradle task 'assembleDebug'...
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
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 @44d075e4
* 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 16s
Exception: Gradle task assembleDebug failed with exit code 1
这是我的环境:
[✓] Flutter (Channel stable, 1.22.6, on macOS 11.6 20G165 darwin-arm, locale en-US)
• Flutter version 1.22.6 at /Volumes/WORK/SDK/flutter
• Framework revision 9b2d32b605 (9 months ago), 2021-01-22 14:36:39 -0800
• Engine revision 2f0af37152
• Dart version 2.10.5
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Volumes/WORK/SDK/Android/
• Platform android-31, build-tools 31.0.0
• ANDROID_HOME = /Volumes/WORK/SDK/Android/
• ANDROID_SDK_ROOT = /Volumes/WORK/SDK/Android/
• Java binary at: /Library/Java/JavaVirtualMachines/jdk-16.0.2.jdk/Contents/Home/bin/java
• Java version Java(TM) SE Runtime Environment (build 16.0.2+7-67)
• All Android licenses accepted.
[✓] Xcode - develop for ios and macOS (Xcode 13.0)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 13.0, Build version 13A233
• CocoaPods version 1.10.1
[!] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
✗ Unable to find bundled Java version.
• Try updating or re-installing Android Studio.
[✓] VS Code (version 1.61.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.27.0
请告诉我如何解决这个问题?
【问题讨论】:
【参考方案1】:重新安装dart和Flutter插件,重启ide,就可以了。有时配置不正确。
【讨论】:
谢谢,但同样的问题以上是关于在 Android Studio 中构建失败的 Flutter 项目的主要内容,如果未能解决你的问题,请参考以下文章
Android Studio 和 Gradle - 构建失败
在android studio中构建groovy时,gradle错误“任务':app:compileDebugJava'执行失败”
Android Studio CMake 错误:构建命令失败
Flutter app Android studio 3.2.1,构建失败