我得到这个错误执行失败的任务':app:compileFlutterBuildDebug'.这个错误突然来了,我不知道为什么.如何修复它
/C:/Users/dell/AppData/Local/Pub/Cache/hosted/pub.dev/printing-5.9.3/lib/src/widget_wrapper.dart:234:9: Error: Type 'ui.ViewConfiguration' not found.
final ui.ViewConfiguration configuration;
^^^^^^^^^^^^^^^^^^^^
/C:/Users/dell/AppData/Local/Pub/Cache/hosted/pub.dev/printing-5.9.3/lib/src/widget_wrapper.dart:241:3: Error: Type 'ui.ViewConfiguration' not found.
ui.ViewConfiguration get viewConfiguration => configuration;
^^^^^^^^^^^^^^^^^^^^
/C:/Users/dell/AppData/Local/Pub/Cache/hosted/pub.dev/printing-5.9.3/lib/src/widget_wrapper.dart:174:27: Error: Method not found: 'ViewConfiguration'.
configuration: ui.ViewConfiguration(
^^^^^^^^^^^^^^^^^
/C:/Users/dell/AppData/Local/Pub/Cache/hosted/pub.dev/printing-5.9.3/lib/src/widget_wrapper.dart:232:3: Error: The superclass, 'ui.FlutterView', has no unnamed constructor that takes no arguments.
_FlutterView({required this.configuration});
^^^^^^^^^^^^
/C:/Users/dell/AppData/Local/Pub/Cache/hosted/pub.dev/printing-5.9.3/lib/src/widget_wrapper.dart:234:12: Error: 'ViewConfiguration' isn't a type.
final ui.ViewConfiguration configuration;
^^^^^^^^^^^^^^^^^
/C:/Users/dell/AppData/Local/Pub/Cache/hosted/pub.dev/printing-5.9.3/lib/src/fonts/font.dart:47:15: Error: 'AssetManifest' is imported from both 'package:flutter/src/services/asset_manifest.dart' and 'package:printing/src/fonts/manifest.dart'.
if (await AssetManifest.contains(asset)) {
^^^^^^^^^^^^^
/C:/Users/dell/AppData/Local/Pub/Cache/hosted/pub.dev/package_info_plus_windows-2.1.0/lib/src/file_version_info.dart:13:17: Error: Field 'wLanguage' cannot be nullable or have type 'Null', it must be `int`, `double`, `Pointer`, or a subtype of `Struct` or `Union`.
external int? wLanguage;
^
/C:/Users/dell/AppData/Local/Pub/Cache/hosted/pub.dev/package_info_plus_windows-2.1.0/lib/src/file_version_info.dart:16:17: Error: Field 'wCodePage' cannot be nullable or have type 'Null', it must be `int`, `double`, `Pointer`, or a subtype of `Struct` or `Union`.
external int? wCodePage;
^
Target kernel_snapshot failed: Exception
FAILURE: Build failed with an exception.
* Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1153
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* 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 1m 1s
Exception: Gradle task assembleDebug failed with exit code 1
这是我的app/buld.gradle文件
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 33
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.bellaz"
minSdkVersion 21
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:multidex:2.0.1'
}
这是我的gradle文件
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
这是我的pubspex.ymal文件
version: 1.0.0+2
environment:
sdk: '>=2.12.0 <3.0.0'
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: ^1.0.3
pin_code_fields: ^7.3.0
intl: ^0.17.0
# dropdown_formfield: ^0.1.3
fluttertoast: ^8.0.8
carousel_slider: ^4.0.0
flutter_rating_bar: ^4.0.0
url_launcher: ^6.0.12
clipboard: ^0.1.3
# dart_notification_center: ^1.0.0+1
maps_launcher: ^2.0.1
share_plus: ^4.0.8
http: ^0.13.4
shared_preferences: ^2.0.8
skeletons: ^0.0.3
geolocator: ^7.4.0
flutter_geocoder: ^0.2.2-nullsafety
cool_dropdown: ^1.4.1
image_picker: ^0.8.3+2
another_flushbar: ^1.10.26
razorpay_flutter: ^1.3.0
location: ^4.3.0
google_maps_flutter: ^2.1.1
map_picker: ^0.0.3
geocoding: ^2.0.1
flutter_google_places: ^0.3.0
pdf: ^3.7.3
path_provider: ^2.0.9
open_filex: ^4.3.2
printing: ^5.9.3
provider: ^6.0.5
dev_dependencies:
flutter_test:
sdk: flutter
flutter_launcher_icons: ^0.9.2
flutter_icons:
android: "launcher_icon"
ios: true
image_path: "lib/Assets/app_icon.png"
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
2条答案
按热度按时间mcvgt66p1#
在应用级别build.gradle文件中将targetSdkVersion更改为30,将minSdkVersion更改为21
到
t9eec4r02#
issue是
printing
和package_info_plus_windows
的问题,您的代码中导入了它们。Upgrade或downgrade
packages
。使用此命令更新
printing
和package_info_plus_windows
包。如果它不工作,请遵循此How to downgrade packages in flutter?。
Clean您的项目与命令:
然后
Invalidate caches and restart .
我还将检查Flutter SDK和导入。它们可能会在代码之间创建冲突。