我在执行“flutter run”时在终端中得到了此错误的任何解决方案。该怎么办?

问题描述 投票:0回答:1

在调试模式下在为 x86 构建的 Android SDK 上启动 lib\main.dart...

FAILURE:构建失败并出现异常。

  • 出了什么问题: 任务“:package_info_plus:compileDebugJavaWithJavac”执行失败。

错误:无效源版本:17

  • 尝试:

使用 --stacktrace 选项运行以获取堆栈跟踪。 使用 --info 或 --debug 选项运行以获得更多日志输出。 使用 --scan 运行以获得完整的见解。

1m 23 秒内构建失败 运行 Gradle 任务“assembleDebug”... 86.6s 错误:Gradle 任务 assembleDebug 失败,退出代码为 1

我已经尝试并更改了jdk版本但没有任何反应

name: grihum
description: "A new Flutter project."
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

# 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 is used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+1

environment:
  sdk: '>=3.2.0 <4.0.0'

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.2
  get: ^4.6.6
  animated_splash_screen: ^1.3.0
  http: ^1.2.0
  shared_preferences: ^2.2.2
  flutter_secure_storage: ^9.0.0
  image: ^4.1.7
  cached_network_image: ^3.3.1
  path_provider: ^2.1.2
  screenshot: ^2.1.0
  flutter_image: ^4.1.11
  flutter_file_dialog: ^3.0.2
  dio: ^5.4.1
  share_plus: ^8.0.2
  image_picker: ^1.0.7
  file_picker: ^6.2.0
  dotenv: ^4.2.0
  crypto: ^3.0.3
  image_gallery_saver: ^2.0.3
  video_player: ^2.8.3
  chewie: ^1.7.5
  shimmer: ^3.0.0
  permission_handler: ^11.3.0
  connectivity_plus: ^5.0.2
  native_video_player: ^1.3.1
  flutter_pdfview: ^1.3.2
  pdf: ^3.10.8
  get_storage: ^2.1.1
  flutter_launcher_icons: ^0.13.1
  flutter_local_notifications: ^17.0.0
  flutter_dotenv: ^5.1.0
  dotted_border: ^2.1.0
  loading_animation_widget: ^1.2.1
  package_info_plus: ^5.0.1
  
flutter_icons:
  android: "launcher_icon"
  ios: true
  image_path_android: "assets/logo.jpeg"
  image_path_ios: "assets/logo.jpeg"
  remove_alpha_ios: true

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^3.0.1
  flutter_launcher_icons: ^0.13.1

# 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 packages.
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/
         - .env

  # 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: Times
      fonts:
        - asset: fonts/times-ro.ttf
        # - asset: fonts/Schyler-Italic.ttf
          # style: Regular
    - family: serif
      fonts:
        - asset: fonts/serif/AbhayaLibre-Bold.ttf
        - asset: fonts/serif/AbhayaLibre-ExtraBold.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages

plugins {
    id "com.android.application"
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

android {
    namespace "com.example.grihum"
    compileSdkVersion 34
    ndkVersion flutter.ndkVersion
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        applicationId "com.example.grihum"
        minSdkVersion 26
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    buildTypes {
        release {
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
}
flutter dart flutter-dependencies flutter-pubspec
1个回答
0
投票

您好,有几个软件包与最新版本的 flutter 不兼容,可能有多种原因,其中一个主要原因是您使用的软件包不是最新的 flutter 版本,我发现了同样的问题flutter 中的唤醒锁插件尝试使用较低版本的软件包并运行它应该可以解决问题

快乐编码

© www.soinside.com 2019 - 2024. All rights reserved.