Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter | The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.0 and higher

I am trying to add firebase dependencies. When I run flutter run I get

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
like image 223
TSR Avatar asked Feb 14 '19 15:02

TSR


People also ask

How do I upgrade my kotlin gradle plugin in flutter?

Go to External Libraries / Flutter Plugins / google_api_availability / android / build. gradle and changed ext. kotlin_version to LATEST_VERSION. Save this answer.

Does flutter use gradle?

Your Flutter module uses a plugin that has no additional Android Gradle dependency because it only uses Android OS APIs, such as the camera plugin.


2 Answers

You can find which package depends on google_api_availability by running flutter packages pub deps on the root of the project - this will list all the direct and transitive dependencies of your project in a tree view.

I couldn't find a way to display the plugin dependencies of a package - I guess you'll only find out once you try to build it.

The problem is you are using version 3.3.1 of the Android Gradle plugin, which enforces Kotlin 1.3.0 or above. At the same time, the geolocator package depends on google_api_availability, which seems to be using Kotlin 1.2.71. At the moment there is no version of google_api_availability that uses Kotlin 1.3.0 or above, so you only have 1 solution - downgrade the Android Gradle plugin to version 3.2.1.

like image 187
Ovidiu Avatar answered Sep 16 '22 15:09

Ovidiu


   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

}

Just added the two line above to build.gradle and it worked. Even if there is a warning like;"Kotlin version that is used for building with Gradle (1.6.10) differs from the one bundled into the IDE plugin (1.3.72) " Anyway i think i need to update IDE plugin soon.

like image 44
avill blbn Avatar answered Sep 16 '22 15:09

avill blbn