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

Class file for com.google.android.gms.common.api.GoogleApi not found when compile

Open xuncoder opened this issue 7 years ago • 3 comments

Hi,when compiling the Geolocator plugin using Flutter Channel master, v1.1.5-pre.32 (master channel) we receive the following exception: Running "flutter packages get" in quick_app... 5.4s Launching lib\main.dart on Android SDK built for x86 in debug mode... Initializing gradle... Resolving dependencies... Gradle task 'assembleDebug'... Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: C:\Users\user\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\flutter_webview_plugin-0.3.0+2\android\src\main\java\com\flutter_webview_plugin\WebviewManager.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. C:\Users\user\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\geolocator-2.1.1\android\src\main\java\com\baseflow\flutter\plugin\geolocator\tasks\LastKnownLocationUsingLocationServicesTask.java:25: error: cannot access GoogleApi mFusedLocationProviderClient.getLastLocation() ^ class file for com.google.android.gms.common.api.GoogleApi not found Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':geolocator:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 57s Finished with error: Gradle task assembleDebug failed with exit code 1

My flutter doctor below: [√] Flutter (Channel master, v1.1.5-pre.32, on Microsoft Windows [Version 10.0.17134.472], locale en-US) • Flutter version 1.1.5-pre.32 at C:\Flutter Dev\flutter • Framework revision fe1a51ab89 (11 hours ago), 2018-12-27 14:55:07 -0800 • Engine revision 220ea0e1ec • Dart version 2.1.1 (build 2.1.1-dev.0.1 d1817ddc91)

[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3) • Android SDK at C:\Users\user\AppData\Local\Android\sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-28, build-tools 28.0.3 • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06) X Android license status unknown.

[√] Android Studio (version 3.2) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin version 31.1.1 • Dart plugin version 181.5656 • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[√] IntelliJ IDEA Community Edition (version 2018.2) • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.2.4 • Flutter plugin version 31.1.3 • Dart plugin version 182.5124

[√] VS Code (version 1.29.1) • VS Code at C:\Users\user\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 2.19.0

[√] Connected device (1 available) • Android SDK built for x86 • emulator-5554 • android-x86 • Android 8.0.0 (API 26) (emulator)

! Doctor found issues in 1 category.

Version: 2.1.1

Platform:

🤖 Android

Below is my build.gradle setting:

buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
    }
}

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
}

subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex') ) {
                details.useVersion "26.1.0"
            }
        }
    }
}

xuncoder avatar Dec 28 '18 10:12 xuncoder

Please use location plugin, instead of geolocator :p

htetwaiyan avatar Jan 17 '19 04:01 htetwaiyan

Please use location plugin, instead of geolocator :p

Any sample code for retrieve location from location plugin?

xuncoder avatar Jan 17 '19 07:01 xuncoder

it is easy to use https://github.com/Lyokone/flutterlocation/blob/master/example/lib/main.dart you should watch there

htetwaiyan avatar Jan 17 '19 08:01 htetwaiyan