TSR*_*TSR 3 android build gradle flutter
我正在尝试添加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
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
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
}
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
    您可以google_api_availability通过flutter packages pub deps在项目的根目录上运行来找到哪个软件包依赖-这将在树形视图中列出项目的所有直接和传递依赖项。
我找不到一种显示软件包的插件依赖性的方法-我猜您只有在尝试构建它时才会发现。
问题是您使用3.3.1的是Android Gradle插件版本,该版本强制执行Kotlin 1.3.0或更高版本。同时,该geolocator软件包取决于google_api_availability,似乎使用的是Kotlin 1.2.71。目前尚无google_api_availability使用Kotlin 1.3.0或更高版本的版本,因此您只有1种解决方案-将Android Gradle插件降级为version 3.2.1。
小智 8
   buildscript {
    ext.kotlin_version = '1.6.10' //-> i added
    repositories {
        google()
        mavenCentral()
    }
dependencies {
  classpath 'com.android.tools.build:gradle:4.1.3'
  classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"//->added
}
Run Code Online (Sandbox Code Playgroud)
只需将上面的两行添加到 build.gradle 即可。即使有这样的警告:“用于使用 Gradle 构建的 Kotlin 版本 (1.6.10) 与捆绑到 IDE 插件 (1.3.72) 的版本不同”无论如何,我认为我需要尽快更新 IDE 插件。
在 android 文件夹中,您将看到名为 build.gradle 的文件
你会看到一段代码
buildscript {
    ext.kotlin_version = 'x.x.xx'
    repositories {
        google()
        jcenter()
    }
Run Code Online (Sandbox Code Playgroud)
编辑属性 ext.kotlin_version 的版本,将 xxxx 替换为 1.3.10
这应该可以帮助您解决错误
|   归档时间:  |  
           
  |  
        
|   查看次数:  |  
           5499 次  |  
        
|   最近记录:  |