Flutter:错误无效源版本:17

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

有人知道为什么我在尝试在 Android 上以调试模式运行我的 flutter 应用程序时可能会收到此错误吗?

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

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

错误:无效源版本:17

  • 尝试:

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

19 秒内构建失败 错误:Gradle 任务 assembleDebug 失败,退出代码为 1

我的flutter版本是:3.3.2。

依赖关系:

flutter_native_splash: ^2.4.0
  provider: ^6.1.2
  shared_preferences: ^2.2.2
  http: ^1.2.1
  internet_connection_checker: ^1.0.0+1
  package_info_plus: ^6.0.0
  permission_handler: ^11.3.1
  flutter_svg: ^2.0.10+1
  flutter_inappwebview: ^6.0.0
  dart_rss: ^3.0.2
  intl: ^0.19.0
  settings_ui: ^2.0.2
  url_launcher: ^6.2.5
  qr_code_scanner: ^1.0.1
  html: ^0.15.4
  share_plus: ^8.0.2
  showcaseview: ^2.0.3
  restart_app: ^1.2.1
  flutter_expandable_fab: ^2.0.0
  flutter_rating_bar: ^4.0.1
  flutter_staggered_grid_view: ^0.7.0
  html_unescape: ^2.0.0
  readmore: ^2.2.0
  cached_network_image: ^3.3.1
  device_info_plus: ^10.0.1
  firebase_core: ^2.27.2
  firebase_analytics: ^10.9.0
  cloud_firestore: ^4.15.10

build.gradle 文件:

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.app"
    compileSdkVersion flutter.compileSdkVersion
    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 {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.app"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdkVersion 23
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName

        multiDexEnabled true
    }

    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 {}

感谢更多需要的信息,我很乐意提供,但不确定可能需要哪些其他信息来调查此问题。

android flutter
1个回答
0
投票

对于遇到此问题的任何人,这里的问题与 android studio 已过时有关。

更新了 android studio 并重新构建了我的项目,现在工作正常。

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