我是 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 (!)