Flutter 运行失败
Posted
技术标签:
【中文标题】Flutter 运行失败【英文标题】:Flutter run with failure 【发布时间】:2021-10-07 03:06:04 【问题描述】:我正在做一个移动实习和学习颤振,我已经将我的机器配置为在我的手机上运行和构建我的应用程序 apk,昨天我将我的 HDD 切换到 SSD,然后我们再次下载并安装所有东西,现在什么时候我尝试运行我的应用,我得到了这个:FAILURE: Build completed with 2 failures. 这就是两次失败:
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':compileReleaseRenderscript'.
Could not resolve all files for configuration ':releaseCompileClasspath'.
Could not resolve com.google.guava:guava:28.1-android.
Required by:
project :
Could not resolve com.google.guava:guava:28.1-android.
Could not parse POM https://jcenter.bintray.com/com/google/guava/guava/28.1-android/guava-28.1-android.pom
O conteúdo não é permitido no prólogo.
* 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.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':javaPreCompileRelease'.
Could not resolve all files for configuration ':releaseCompileClasspath'.
Could not resolve com.google.guava:guava:28.1-android.
Required by:
project :
Could not resolve com.google.guava:guava:28.1-android.
Could not parse POM https://jcenter.bintray.com/com/google/guava/guava/28.1-android/guava-28.1-android.pom
O conteúdo não é permitido no prólogo.
* 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
另外,当我运行颤振医生时,我遇到了这个问题:
[!] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
X Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
但是当我尝试运行 flutter doctor --android-licenses 时,我收到了这个日志错误:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 5 more
```
【问题讨论】:
确实尝试运行flutter doctor --android-licenses
是的,我试过了,但我也遇到了另一个错误,日志在我的问题的最后
【参考方案1】:
我解决它只是卸载并重新安装 Android Studio 和 Flutter,如果您遇到此问题,可能您的 Android Studio 已损坏。
【讨论】:
以上是关于Flutter 运行失败的主要内容,如果未能解决你的问题,请参考以下文章
Android项目创建Flutter module后运行编译失败问题
Android项目创建Flutter module后运行编译失败问题
使用新的 Flutter 2.2.2 版本为 Riverpod 运行“flutter pub get”时版本解决失败