flutter-geolocator icon indicating copy to clipboard operation
flutter-geolocator copied to clipboard

Gradle error configuring project ':google_api_availability'

Open skybur opened this issue 8 years ago • 15 comments

🔙 Regression

Hello, After upgrading to latest flutter beta (0.9.4) I cannot run my app which depends on this plugin. Here is the error occurred when running gradle

           FAILURE: Build failed with an exception.
           
           * What went wrong:
           A problem occurred configuring project ':google_api_availability'.
           > Failed to notify project evaluation listener.
              > java.lang.AbstractMethodError (no error message)

Old (and correct) behavior

No error when running gradle

Current behavior

Error running gradle

Reproduction steps

Update to latest flutter beta (0.9.4), run app that depends on this plugin.

Configuration

Flutter doctor output

[√] Flutter (Channel beta, v0.9.4, on Microsoft Windows [Version 10.0.17763.55], locale en-US)
    • Flutter version 0.9.4 at D:\Devs\Flutter\flutter
    • Framework revision f37c235c32 (2 weeks ago), 2018-09-25 17:45:40 -0400
    • Engine revision 74625aed32
    • Dart version 2.1.0-dev.5.0.flutter-a2eb050044

[√] Android toolchain - develop for Android devices (Android SDK 28.0.2)
    • Android SDK at D:\AndroidSDK
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.2
    • ANDROID_HOME = D:\AndroidSDK
    • Java binary at: D:\AndroidStudio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
    • All Android licenses accepted.

[√] Android Studio (version 3.1)
    • Android Studio at D:\AndroidStudio
    • Flutter plugin version 27.1.1
    • Dart plugin version 173.4700
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)

[√] VS Code, 64-bit edition (version 1.27.2)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 2.19.0

[√] Connected devices (1 available)
    • Redmi 3S • c37ae0927d63 • android-arm64 • Android 6.0.1 (API 23)

• No issues found!

Version: 2.0.1

Platform:

  • [ ] :iphone: iOS
  • [x] :robot: Android

skybur avatar Oct 11 '18 03:10 skybur

Ah sorry I didn't see there is an update to this plugin. Gonna update & check it again.

skybur avatar Oct 11 '18 03:10 skybur

It still happened after upgrading.

skybur avatar Oct 11 '18 03:10 skybur

@skybur we have just release version 2.1.0 of the Geolocator plugin, this should solve you problem.

mvanbeusekom avatar Oct 11 '18 09:10 mvanbeusekom

@mvanbeusekom hello, sorry but I tried with a newly created project, added this plugin and the issue still happened. I don't know if the issue caused by this plugin or my environment. Is there anything I can do?

skybur avatar Oct 12 '18 00:10 skybur

Here is the top level build.gradle & app build.gradle file of newly created project toplevel

buildscript {
    ext.kotlin_version = '1.2.30'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

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.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

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

android {
    compileSdkVersion 27

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.terreciel.testgeo"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        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 {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    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'
}

skybur avatar Oct 12 '18 01:10 skybur

Finally I fixed it by updating my gradle & kotlin version. thank you very much

skybur avatar Oct 12 '18 01:10 skybur

@skybur, happy to hear you managed to solve the problem. I must admit I also ran in to this and indeed could solve it by manually upgrading gradle & kotlin. For other people running into this problem, I simply made the same changes as Flutter did in the following PR: https://github.com/flutter/flutter/pull/22790/files

I bit more background information can be found here: https://github.com/flutter/flutter/issues/22614

mvanbeusekom avatar Oct 12 '18 07:10 mvanbeusekom

please what is the solution because i have the same problem but when i read all comment above it don't fix my problem.

MrMagloire avatar Oct 17 '18 21:10 MrMagloire

@mrmagloire, you will have to manualy upgrade the Gradle and Kotlin versions in your project. The Flutter template still uses outdated versions, which is fixed in https://github.com/flutter/flutter/pull/22790/files.

So what you do is open the link and go through each file and make the same change in your code.

mvanbeusekom avatar Oct 18 '18 05:10 mvanbeusekom

Right now i just finished changing all 49 files in Flutter's folder like https://github.com/flutter/flutter/pull/22790/file and 2 files of my project but i'm having the one and same problem, capturegeolocator

MrMagloire avatar Oct 18 '18 12:10 MrMagloire

Thanks @mvanbeusekom I fixed it by updating my gradle & kotlin version

arleyduarte avatar Oct 19 '18 14:10 arleyduarte

For someone just coming in:

build.gradle (app)

ext.kotlin_version = '1.2.71' and classpath 'com.android.tools.build:gradle:3.2.1'

gradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip

This worked for me, with geolocator: '^2.1.0'

I stumbled on this one after upgrading flutter to 0.11.3, after these changes it works.

ishaanbahal avatar Nov 16 '18 18:11 ishaanbahal

I ran into this error after adding geolocator: 2.1.1 package. I went through above suggestions and updated my build gradle, gradle wrapper and kotlin version and tried to sync project but still seeing same error. Since I am using firebase in my project, I read somewhere that the firebase version could be conflicting as well. So would like to know how to go about fixing this issue in my case (from firebase version perspective).

Flutter doctor:

[✓] Flutter (Channel beta, v0.11.10, on Mac OS X 10.13.2 17C88, locale en-US)
    • Flutter version 0.11.10 at
      /Users/deeptibelsare/Documents/DarshanUdacity/Flutter/flutter
    • Framework revision c27c4a265e (6 weeks ago), 2018-11-26 17:07:24 -0500
    • Engine revision eebc6a5895
    • Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

[!] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    • Android SDK at /Users/deeptibelsare/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling
      support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_152-release-1024-b01)
    ✗ Android license status unknown.

[!] iOS toolchain - develop for iOS devices (Xcode 9.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 9.4.1, Build version 9F2000
    ✗ Verify that all connected devices have been paired with this computer in
      Xcode.
      If all devices have been paired, libimobiledevice and ideviceinstaller may
      require updating.
      To update with Brew, run:
        brew update
        brew uninstall --ignore-dependencies libimobiledevice
        brew uninstall --ignore-dependencies usbmuxd
        brew install --HEAD usbmuxd
        brew unlink usbmuxd
        brew link usbmuxd
        brew install --HEAD libimobiledevice
        brew install ideviceinstaller
    • ios-deploy 2.0.0
    • CocoaPods version 1.5.0

[✓] Android Studio (version 3.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 26.0.1
    • Dart plugin version 173.4700
    • Java version OpenJDK Runtime Environment (build
      1.8.0_152-release-1024-b01)

[✓] Connected device (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 6.0 (API
      23) (emulator)

build.gradle:

buildscript {
    ext.kotlin_version = '1.2.30'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.2.0'
    }
}

distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip

@mvanbeusekom

DK15 avatar Jan 11 '19 07:01 DK15

I ran into this error after adding geolocator: 2.1.1 package. I went through above suggestions and updated my build gradle, gradle wrapper and kotlin version and tried to sync project but still seeing same error. Since I am using firebase in my project, I read somewhere that the firebase version could be conflicting as well. So would like to know how to go about fixing this issue in my case (from firebase version perspective).

Flutter doctor:

[✓] Flutter (Channel beta, v0.11.10, on Mac OS X 10.13.2 17C88, locale en-US)
    • Flutter version 0.11.10 at
      /Users/deeptibelsare/Documents/DarshanUdacity/Flutter/flutter
    • Framework revision c27c4a265e (6 weeks ago), 2018-11-26 17:07:24 -0500
    • Engine revision eebc6a5895
    • Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

[!] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    • Android SDK at /Users/deeptibelsare/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling
      support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_152-release-1024-b01)
    ✗ Android license status unknown.

[!] iOS toolchain - develop for iOS devices (Xcode 9.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 9.4.1, Build version 9F2000
    ✗ Verify that all connected devices have been paired with this computer in
      Xcode.
      If all devices have been paired, libimobiledevice and ideviceinstaller may
      require updating.
      To update with Brew, run:
        brew update
        brew uninstall --ignore-dependencies libimobiledevice
        brew uninstall --ignore-dependencies usbmuxd
        brew install --HEAD usbmuxd
        brew unlink usbmuxd
        brew link usbmuxd
        brew install --HEAD libimobiledevice
        brew install ideviceinstaller
    • ios-deploy 2.0.0
    • CocoaPods version 1.5.0

[✓] Android Studio (version 3.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 26.0.1
    • Dart plugin version 173.4700
    • Java version OpenJDK Runtime Environment (build
      1.8.0_152-release-1024-b01)

[✓] Connected device (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 6.0 (API
      23) (emulator)

build.gradle:

buildscript {
    ext.kotlin_version = '1.2.30'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.2.0'
    }
}

distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip

@mvanbeusekom

I have same case with you but I had tried to remark
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" and kotlin related part, and used classpath 'com.android.tools.build:gradle:3.1.4', it work, not sure why kotlin dependencies crash with google_api_availability ,my gradle wrapper is distributionUrl=https://services.gradle.org/distributions/gradle-4.6-all.zip

xuncoder avatar Jan 15 '19 13:01 xuncoder

Downgrading gradle to 3.1.4 from 3.3.0 worked for me :-

" classpath 'com.android.tools.build:gradle:3.1.4' "

TahaAli07 avatar Feb 05 '19 10:02 TahaAli07