Android Gradle 插件仅支持 Kotlin Gradle 插件版本 1.3.10 及更高版本

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

我的项目中遇到了一个奇怪的错误。我尝试了类似问题的解决方案,但没有成功。我和我的同事尝试更新条形码扫描,但没有任何改变。

这是错误消息。

在调试模式下在为 x86 构建的 Android SDK 上启动 lib/main.dart... 运行 Gradle 任务“assembleDebug”...

**FAILURE: Build failed with an exception.

* What went wrong:
The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.10 and higher.
The following dependencies do not satisfy the required version:
project ':barcode_scan' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.51

* 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

BUİLD FAILED in 978ms
Exception: Gradle task assembleDebug failed with exit code 1

这是我的 android/build.gradle 文件

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        //classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.51"
    }
}
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
}

最后是我的 pubspec.yaml 文件

name: myapp
description: A new Flutter project.

version: 1.0.0+1


environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  flutter_datetime_picker: ^1.3.7
  cupertino_icons: ^0.1.0
  barcode_scan: ^0.0.4
  intl: ^0.15.7
  sqflite: any
  path_provider: any
  http: any
  json_serializable: ^2.2.1
  json_annotation: ^2.2.0
  build_runner: ^1.3.3
  image_picker: 0.4.12+1  
  mime: ^0.9.6+3 
  toast: ^0.1.5 
  loading: ^1.0.2
  progress_dialog: ^1.2.0

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_launcher_icons: "^0.7.0"

flutter_icons:
  android: true
  ios: true
  image_path_ios: "assets/launch_logo.jpg"
  image_path_android: "assets/launch_logo.jpg"

flutter:
  uses-material-design: true

  assets:
    - assets/

module:
  androidX: true # Add this line.
android flutter kotlin gradle
3个回答
0
投票

尝试将barcode_scan更新到最新版本:https://pub.dev/packages/barcode_scan


0
投票

当我将 flutter 版本降级到 1.2.1 时,我发现如何解决我的问题,一切都与版本有关,一切正常,我的项目有许多第三方插件,例如条形码阅读器或日期时间选择器,其中一些可以与较旧的版本一起使用版本的 flutter 并且他们不支持最新版本的 flutter,这就是为什么我需要将 flutter 降级到 1.2.1。


0
投票

以上答案都不适合我,因此必须删除 android 文件夹并使用以下命令创建一个新文件夹(确保首先备份您的 android 文件夹):

flutter create .

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