我正在尝试添加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
}
app/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
9条答案
按热度按时间ztyzrc3y1#
你可以通过在项目的根目录下运行
flutter packages pub deps
来找到哪个包依赖于google_api_availability
-这将在树状视图中列出项目的所有直接和传递依赖项。我找不到一种方法来显示一个包的插件依赖关系-我想你只有在尝试构建它时才会发现。
问题是您正在使用Android Gradle插件的
3.3.1
版本,该版本强制执行Kotlin1.3.0
或更高版本。与此同时,geolocator
包依赖于google_api_availability
,它似乎使用了Kotlin1.2.71
。目前没有使用Kotlin1.3.0
或更高版本的google_api_availability
版本,因此您只有一个解决方案-将Android Gradle插件降级到3.2.1
版本。uyhoqukh2#
只需将上面的两行添加到build.gradle,它就可以工作了。即使有像这样的警告;"用于构建Gradle的Kotlin版本(1.6.10)与IDE插件捆绑的版本(1.3.72)不同"无论如何,我认为我需要尽快更新IDE插件。
3df52oht3#
在android文件夹中,您将看到名为build.gradle的文件
你会看到一段代码
通过将x.x.xx替换为1.3.10来编辑属性ext.Kotlin_version的版本
这将帮助您解决错误
wi3ka0sx4#
我们使用的解决方案是将包及其所有依赖项直接包含在flutter构建环境中。!!从长远来看,这可能不是理想的,但会帮助你,而这个AndroidX迁移正在发生,并扰乱你的构建。
在pubspec.yaml中,我们包含了如下的特定版本
我们的中断发生在google_API_availability v1.0.6和v2.0.0之间
你可以按照Ovidiu说的那样或者打开https://pub.dartlang.org/并在搜索栏中输入“
dependency:google_api_availability
”来找到哪个包依赖于google_API_availability。在每个包页面上,您还可以看到依赖关系以及依赖它们的人。nbysray55#
我只需要更改android/build.gradle文件中的Kotlin_version:
在BuildScript和依赖项中进行更改后,错误消失了。
webghufk6#
转到External Libraries / Flutter Plugins / google_API_availability / android / build.gradle并将ext.Kotlin_version更改为LATEST_VERSION。
busg9geu7#
我的问题开始于一个HTTP连接提前关闭。然后这个问题变成了Android X问题。
为了解决这个android x问题,我遵循了www.example.com的步骤https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility#not-recommended-manually-migrate-your-app,但相反,它导致了另一个版本问题。我使用的是geolocator 1.6.3,它调用了在Kotlin1.2.x中开发的Google API。当前的gradle 3.4.1需要Kotlin1.3.1及更高版本,但这是不可能的。因此出现了版本瓶颈。
所以呢
uklbhaso8#
ext.Kotlin_version = '1.3.50' => ext.kotlin_version = '1.6.0'这对我来说很好。我希望这可以解决你的问题。
xam8gpfp9#
问题是您使用的是3.3.1或更高版本的Android Gradle插件,它强制要求使用Kotlin1.3.0或更高版本。所以你只有一个解决方案-将Android Gradle插件降级到版本3.2.1。