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

时间:2020-07-27 11:19:04

标签: android flutter kotlin gradle

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

这是错误消息。

在调试模式下为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.

2 个答案:

答案 0 :(得分:0)

尝试将条形码扫描仪更新为最新版本:https://pub.dev/packages/barcode_scan

答案 1 :(得分:0)

当我将flutter版本降级到1.2.1时,我发现了如何解决所有版本问题,一切都很好,我的项目中有很多第三方插件,例如条形码读取器或日期时间选择器,其中一些可以与较旧版本的Flutter,但它们不支持最新版本的Flutter,这就是为什么我需要将Flutter降级为1.2.1的原因。