在Flutter_Windows_2.5.1中获取Gradle错误

发布于 2025-01-24 00:07:01 字数 9064 浏览 0 评论 0原文

我知道这是一个非常普遍的错误,但我真的陷入了困境。我正在Flutter Project工作,在该项目中,我在运行该应用程序时会遇到Gradle错误。我不是在构建窗户,而是在窗户中遇到gradle错误。

/C:/flutter_windows_2.5.1-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_fonts-2.3.0/lib/google_fonts.dart:133996:7: Error: No named parameter with the name 'displayLarge'.
      displayLarge: GoogleFonts.tourney(textStyle: textTheme.displayLarge),
FAILURE: Build failed with an exception.

* Where:
Script 'C:\flutter_windows_2.5.1-stable\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1005

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\flutter_windows_2.5.1-stable\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 52s
Exception: Gradle task assembleDebug failed with exit code 1

我还更新了App.build,Gradle文件中的Min SDK版本,但仍然无法正常工作。我的app/build.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 FileNotFoundException("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: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 32
    // ndkVersion 21 for Github actions CI build, ( 23 doesn't work on github actions)
    ndkVersion "21.4.7075529"
    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.devex.giraffe"
        minSdkVersion 21
        targetSdkVersion 32
        multiDexEnabled true
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation platform('com.google.firebase:firebase-bom:28.4.0')
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:multidex:1.0.3'
}
apply plugin: 'com.google.gms.google-services'

我的pubspec.yml文件是

name: girafee
description: A new Flutter application.

publish_to: none

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 0.11.6

environment:
  sdk: ">=2.14.0 <3.0.0"
  flutter: ">=2.5.0 <=3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter
  animated_text_kit: ^4.2.1
  google_fonts: ^2.1.0
  http: ^0.13.3
  #  date_format: ^1.0.8

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.3
  google_maps_flutter: ^2.0.6
  flutter_rating_bar: ^4.0.0
  carousel_slider: ^4.0.0
  provider: ^5.0.0
  geolocator: ^7.3.1
  flutter_polyline_points: ^1.0.0
  geocoding: ^2.0.0
  video_thumbnail: ^0.4.3
  font_awesome_flutter: ^9.1.0
  dotted_border: ^2.0.0
  country_code_picker: ^2.0.2
  fluttertoast: ^8.0.7
  flutter_datetime_picker: ^1.5.1
  pdf: ^3.4.2
  mailer: ^5.0.1
  image_picker: ^0.8.2
  string_extensions: ^0.2.4
  cached_network_image: ^3.1.0
  tutorial_coach_mark: ^1.0.3
  json_annotation: ^4.0.1
  linkedin_login: ^2.0.1
  multi_image_picker: ^4.8.1
  # flutter_twitter: ^1.1.3
  flutter_keyboard_size: ^1.0.0+3
  flutter_time_picker_spinner: ^2.0.0
  numberpicker: ^2.1.1
  mask_text_input_formatter: ^2.0.0
  google_sign_in: ^5.0.5
  dio: ^4.0.0
  pretty_dio_logger: ^1.2.0-beta-1
  flutter_credit_card: ^3.0.1
  get: ^4.6.1
  shared_preferences: ^2.0.6
  address_search_field: ^4.0.1
  file_picker: ^3.0.3
  flutter_plugin_android_lifecycle: ^2.0.2
  collection: ^1.15.0
  copy_with_extension: ^2.0.2
  permission_handler: ^8.1.4+1
 # bezier_chart:
#    git:
#      url: git://github.com/aeyrium/bezier-chart
#      ref: release
  html_editor_enhanced: ^2.2.0+1-dev.1
  flutter_facebook_auth: ^3.5.0
  webview_flutter: ^2.0.10
  flutter_html: ^2.1.1
  flutter_cache_manager: ^3.1.2
  video_player: ^2.1.15
  background_location: ^0.8.1
    # git:ijjuiin
      # url: git://github.com/cybrnode/background_location
  flutter_local_notifications: ^8.2.0
  firebase_messaging: ^10.0.9
  firebase_core: ^1.8.0
  equatable: ^2.0.3
  crypto: ^3.0.1
  sqflite: ^2.0.0+4
  rxdart: ^0.27.2
  url_launcher: ^6.0.12
  twitter_login: ^4.0.1
  flutter_svg: ^0.22.0
  audioplayers: ^0.20.1
  flutter_stripe: ^2.0.1
  intl: ^0.17.0-nullsafety.2
  flutter_colorpicker: ^0.5.0
  auto_size_text: ^3.0.0
  super_string: ^1.0.3
  webview_flutter_plus:
  selectable_container: ^1.0.2
  location: ^4.3.0
  path_provider: ^2.0.9
  get_storage: ^2.0.3

# dependency_overrides:
#  https://github.com/tneotia/html-editor-enhanced/issues/80#issuecomment-873307618

dev_dependencies:
  build_runner: ^2.0.6
  flutter_launcher_icons: ^0.9.1
  json_serializable: ^4.1.4
  copy_with_extension_gen: ^2.0.2
  awesome_dialog: ^2.1.2
  csc_picker: ^0.2.6
  chips_choice: ^2.0.1
  screenshot: ^1.2.3
  share_plus: ^3.1.0
  path:


flutter_icons:
  android: "launcher_icon"
  ios: true
  image_path: "assets/appIcons/mainLogo.png"

  flutter_test:
    sdk: flutter

# 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

  # To add assets to your application, add an assets section, like this:
  assets:
    - assets/
    - assets/appIcons/drawer_svg_icons/
    - assets/appIcons/
    - assets/MapDesign/
    - assets/legal/
    - i18n/en.json
    - i18n/fr.json
    - assets/audio/
    - assets/svg/
  #  - images/a_dot_ham.jpeg
  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  fonts:
    - family: RobotoL
      fonts:
        - asset: assets/fonts/RobotoCondensed-Light.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages

I know it is a very common error in flutter but i am really stuck on this. I am working in flutter project in which i am getting gradle errors while running the app. i am not building the windows but getting the gradle errors in windows like.

/C:/flutter_windows_2.5.1-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_fonts-2.3.0/lib/google_fonts.dart:133996:7: Error: No named parameter with the name 'displayLarge'.
      displayLarge: GoogleFonts.tourney(textStyle: textTheme.displayLarge),
FAILURE: Build failed with an exception.

* Where:
Script 'C:\flutter_windows_2.5.1-stable\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1005

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\flutter_windows_2.5.1-stable\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 52s
Exception: Gradle task assembleDebug failed with exit code 1

I also updgrade the min sdk versions in app.build,gradle file but still it is not working. My app/build.gradle file is:

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 FileNotFoundException("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: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 32
    // ndkVersion 21 for Github actions CI build, ( 23 doesn't work on github actions)
    ndkVersion "21.4.7075529"
    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.devex.giraffe"
        minSdkVersion 21
        targetSdkVersion 32
        multiDexEnabled true
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation platform('com.google.firebase:firebase-bom:28.4.0')
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:multidex:1.0.3'
}
apply plugin: 'com.google.gms.google-services'

my pubspec.yml file is

name: girafee
description: A new Flutter application.

publish_to: none

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 0.11.6

environment:
  sdk: ">=2.14.0 <3.0.0"
  flutter: ">=2.5.0 <=3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter
  animated_text_kit: ^4.2.1
  google_fonts: ^2.1.0
  http: ^0.13.3
  #  date_format: ^1.0.8

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.3
  google_maps_flutter: ^2.0.6
  flutter_rating_bar: ^4.0.0
  carousel_slider: ^4.0.0
  provider: ^5.0.0
  geolocator: ^7.3.1
  flutter_polyline_points: ^1.0.0
  geocoding: ^2.0.0
  video_thumbnail: ^0.4.3
  font_awesome_flutter: ^9.1.0
  dotted_border: ^2.0.0
  country_code_picker: ^2.0.2
  fluttertoast: ^8.0.7
  flutter_datetime_picker: ^1.5.1
  pdf: ^3.4.2
  mailer: ^5.0.1
  image_picker: ^0.8.2
  string_extensions: ^0.2.4
  cached_network_image: ^3.1.0
  tutorial_coach_mark: ^1.0.3
  json_annotation: ^4.0.1
  linkedin_login: ^2.0.1
  multi_image_picker: ^4.8.1
  # flutter_twitter: ^1.1.3
  flutter_keyboard_size: ^1.0.0+3
  flutter_time_picker_spinner: ^2.0.0
  numberpicker: ^2.1.1
  mask_text_input_formatter: ^2.0.0
  google_sign_in: ^5.0.5
  dio: ^4.0.0
  pretty_dio_logger: ^1.2.0-beta-1
  flutter_credit_card: ^3.0.1
  get: ^4.6.1
  shared_preferences: ^2.0.6
  address_search_field: ^4.0.1
  file_picker: ^3.0.3
  flutter_plugin_android_lifecycle: ^2.0.2
  collection: ^1.15.0
  copy_with_extension: ^2.0.2
  permission_handler: ^8.1.4+1
 # bezier_chart:
#    git:
#      url: git://github.com/aeyrium/bezier-chart
#      ref: release
  html_editor_enhanced: ^2.2.0+1-dev.1
  flutter_facebook_auth: ^3.5.0
  webview_flutter: ^2.0.10
  flutter_html: ^2.1.1
  flutter_cache_manager: ^3.1.2
  video_player: ^2.1.15
  background_location: ^0.8.1
    # git:ijjuiin
      # url: git://github.com/cybrnode/background_location
  flutter_local_notifications: ^8.2.0
  firebase_messaging: ^10.0.9
  firebase_core: ^1.8.0
  equatable: ^2.0.3
  crypto: ^3.0.1
  sqflite: ^2.0.0+4
  rxdart: ^0.27.2
  url_launcher: ^6.0.12
  twitter_login: ^4.0.1
  flutter_svg: ^0.22.0
  audioplayers: ^0.20.1
  flutter_stripe: ^2.0.1
  intl: ^0.17.0-nullsafety.2
  flutter_colorpicker: ^0.5.0
  auto_size_text: ^3.0.0
  super_string: ^1.0.3
  webview_flutter_plus:
  selectable_container: ^1.0.2
  location: ^4.3.0
  path_provider: ^2.0.9
  get_storage: ^2.0.3

# dependency_overrides:
#  https://github.com/tneotia/html-editor-enhanced/issues/80#issuecomment-873307618

dev_dependencies:
  build_runner: ^2.0.6
  flutter_launcher_icons: ^0.9.1
  json_serializable: ^4.1.4
  copy_with_extension_gen: ^2.0.2
  awesome_dialog: ^2.1.2
  csc_picker: ^0.2.6
  chips_choice: ^2.0.1
  screenshot: ^1.2.3
  share_plus: ^3.1.0
  path:


flutter_icons:
  android: "launcher_icon"
  ios: true
  image_path: "assets/appIcons/mainLogo.png"

  flutter_test:
    sdk: flutter

# 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

  # To add assets to your application, add an assets section, like this:
  assets:
    - assets/
    - assets/appIcons/drawer_svg_icons/
    - assets/appIcons/
    - assets/MapDesign/
    - assets/legal/
    - i18n/en.json
    - i18n/fr.json
    - assets/audio/
    - assets/svg/
  #  - images/a_dot_ham.jpeg
  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  fonts:
    - family: RobotoL
      fonts:
        - asset: assets/fonts/RobotoCondensed-Light.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

若有似无的小暗淡 2025-01-31 00:07:01

使用Google_fonts: ^2.3.1

然后flutter Clean&amp;&amp; Flutter Pub Get

您为什么要尽其所能地保持扑朔迷离的版本

flutter: ">=2.5.0 <=3.0.0"


只是使用

environment:
  sdk: ">=2.14.0 <3.0.0"
dependencies:
  flutter:
    sdk: flutter

Use google_fonts: ^2.3.1

then flutter clean && flutter pub get.

Why are you keeping flutter version additionallly as

flutter: ">=2.5.0 <=3.0.0"

Cant it be omiited?
and just use

environment:
  sdk: ">=2.14.0 <3.0.0"
dependencies:
  flutter:
    sdk: flutter
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文