颤振| Android Gradle插件仅支持Kotlin Gradle插件版本1.3.0及更高版本

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

我正在尝试添加firebase依赖项。当我运行flutter run时,我得到了

The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.0 and higher.
The following dependencies do not satisfy the required version:
project ':google_api_availability' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.71

Pubscec.yaml

dependencies:
  flutter:
    sdk: flutter
  firebase_auth: ^0.8.1
  google_sign_in: ^4.0.1
  cloud_firestore: ^0.9.0+1
  firebase_core: ^0.3.0+1
  firebase_storage: ^2.0.1
  cupertino_icons: ^0.1.2
  font_awesome_flutter: ^8.0.1
  country_code_picker: ^1.1.0
  fluttertoast: ^2.0.7
  image_picker: ^0.4.6
  shared_preferences: ^0.4.2
  cached_network_image: ^0.4.1
  intl: ^0.15.7
  geolocator: ^2.1.1
  http: ^0.11.3+14
  flutter_google_places: ^0.1.4+1
  location: ^1.1.6
  uuid: ^1.0.3
  auto_size_text: 0.3.0

的build.gradle

buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'
        classpath 'com.google.gms:google-services:4.2.0'
    }
}

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
}

应用程序/的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 GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 28

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.myapp"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.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 {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
apply plugin: 'com.google.gms.google-services'  // Gradle plugin
android gradle build flutter
2个回答
4
投票

您可以通过在项目的根目录上运行google_api_availability来找到依赖于flutter packages pub deps的包 - 这将在树视图中列出项目的所有直接和传递依赖项。

我找不到显示包的插件依赖关系的方法 - 我想你只会在尝试构建它时找到它。

问题是你正在使用Android Gradle插件的版本3.3.1,它强制执行Kotlin 1.3.0或更高版本。与此同时,geolocator包依赖于google_api_availability,它似乎使用Kotlin 1.2.71。目前没有使用Kotlin google_api_availability或更高版本的1.3.0版本,因此您只有1个解决方案 - 将Android Gradle插件降级为版本3.2.1


3
投票
The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.0 and higher.
The following dependencies do not satisfy the required version:
project ':google_api_availability' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.71

我们使用的解决方案是将包及其所有依赖项直接包含在flutter构建环境中。 !从长远来看,这可能不太理想,但在AndroidX迁移发生时会帮助您,并且会破坏您的构建。

在pubspec.yaml中,我们包含了特定的版本

geolocator: 3.0.0               # AndroidX - Breaking! 
google_api_availability: 1.0.6  # Geolocator Dependency. 
meta: 1.1.6                     # Geolocator Dependency. 
permission_handler: 2.2.0       # Geolocator & Meta Dependency.

我们的破损发生在google_api_availability v1.0.6和v2.0.0之间

您可以通过执行Ovidiu说明或打开https://pub.dartlang.org/并在搜索栏中输入“dependency:google_api_availability”来查找哪个包依赖于google_api_availability。此外,在每个包页面上,您都可以看到依赖关系以及依赖关系的人员。

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