android - Flutter:无法使用 GradleScopeCompileServices.createGeneralCompileCaches() 创建 DefaultGeneralCompileCaches 类型的服务
问题描述
我是 Flutter 的新手,正处于学习阶段。我根据创建飞镖程序的演示创建了一个 Flutter 应用程序。当我运行初始程序时,它运行良好并且演示应用程序出现,但是当我更改并继续创建一些新程序时,它失败并出现主题错误。我在下面放置了 main.dart 和 gradle 属性和依赖项的代码。
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(primaryColor: Colors.purpleAccent),
home: Scaffold(
appBar: AppBar(title: Text("Word Generator")),
),
);
}
}
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.3
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
#android.useAndroidX=true
#android.enableJetifier=true
Log for the error:
C:\Git\flutter\wordpairgenerator>flutter run --enable-software-rendering
Using software rendering with device SM G615FU. You may get better performance with hardware mode by
configuring hardware rendering for your device.
Launching lib\main.dart on SM G615FU in debug mode...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Could not create service of type DefaultGeneralCompileCaches using
GradleScopeCompileServices.createGeneralCompileCaches().
* 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 49s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 57.5s
Exception: Gradle task assembleDebug failed with exit code 1
Log for the app ran correctly:
C:\Git\flutter\myapp>flutter run --enable-software-rendering
Using software rendering with device SM G615FU. You may get better performance with hardware mode by
configuring hardware rendering for your device.
Launching lib\main.dart on SM G615FU in debug mode...
F/AdjustPurchase(12613): PRODUCTION: AdjustPurchase is running in production mode. Use this setting
only for the build that you want to publish. Set the environment to `sandbox` if you want to test
your app!
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 123.6s (!)
√ Built build\app\outputs\apk\debug\app-debug.apk.
D/Surface (13245): Surface::connect(this=0xd0815400,api=2)
D/GraphicBuffer(13245): register, handle(0xe7f34100) (w:1080 h:1920 s:1088 f:0x4 u:0x000933)
Syncing files to device SM G615FU...
3,033ms (!)
解决方案
我最近遇到了这个问题,并通过更改android/gradle/wrapper/gradle-wrapper.properties文件中的 distributionUrl 来更新 gradle 文件,从而从这个问题中恢复过来
https://services.gradle.org/distributions/gradle-5.6.2-all.zip 到 https://services.gradle.org/distributions/gradle-6.1.1-all.zip
我等了一段时间才下载 gradle 文件,它对我来说很好,希望它对你也有帮助。
推荐阅读
- django - django.core.exceptions.ImproperlyConfigured:不支持 Django 3.0.1
- c# - Dotnet Core - 查找与您所在文件夹相关的文件夹中的所有文件,然后查找最后添加的 csv 文件
- javascript - 如何在超链接点击时用 JavaScript 打开 PDF 文件?
- javascript - 角度 8 和sailsJs 的套接字io 请求错误
- firebase - 如何限制对特定 Firebase 节点的读写
- uiscrollview - 故事板自由形式模式下的视图控制器最大高度
- angular - Twitter 的 Fabric 密钥
- javascript - 在 reactjs 和 nextjs 构造函数中获取参考错误:未定义本地存储
- javascript - 从左到右,向下或对角向左(向上或向下)出现在矩阵中的单词的出现
- ios - 如何从 iOS 中的框架访问主机应用程序版本?