AdevintaSpain / Leku

:earth_africa: Map location picker component for Android. Based on Google Maps. An alternative to Google Place Picker.
https://adevintaspain.github.io/Leku/
Apache License 2.0
764 stars 170 forks source link

Found interface com.google.android.gms.location.FusedLocationProviderClient, but class was expected #377

Closed MiguelDAD closed 1 year ago

MiguelDAD commented 1 year ago

Describe the bug Return error when execute:

Intent intent = new LocationPickerActivity.Builder()
                        .withGooglePlacesApiKey("x")
                        .build(getContext());

                startActivityForResult(intent, PLACE_PICKER_REQUEST);

Info Required

Error

E/AndroidRuntime: FATAL EXCEPTION: DefaultDispatcher-worker-1
    Process: com.example.pi_movil, PID: 2326
    java.lang.IncompatibleClassChangeError: Found interface com.google.android.gms.location.FusedLocationProviderClient, but class was expected (declaration of 'com.google.android.gms.location.FusedLocationProviderClient' appears in /data/app/~~-hDMvUUll-HOSJyOR8GDmg==/com.example.pi_movil-z2sisQdKRs_AY7miJ74PmQ==/base.apk)
        at com.adevinta.leku.utils.ReactiveLocationProvider.getLastKnownLocation(ReactiveLocationProvider.kt:25)
        at com.adevinta.leku.geocoder.GeocoderPresenter$getLastKnownLocation$1.invokeSuspend(GeocoderPresenter.kt:46)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
        at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:749)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
        Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@8d22030, Dispatchers.IO]

Smartphone:

Additional context Gradle:

plugins {
    id 'com.android.application'
    id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
}

android {
    namespace 'com.example.pi_movil'
    compileSdk 33

    defaultConfig {
        applicationId "com.example.pi_movil"
        minSdk 33
        targetSdk 33
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    buildFeatures {
        viewBinding true
    }
}

dependencies {

    implementation project(path: ':BracketsLib')

    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'com.google.android.material:material:1.8.0'
    implementation 'androidx.coordinatorlayout:coordinatorlayout:1.2.0'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'com.google.android.gms:play-services-location:21.0.1'
    implementation 'com.google.android.gms:play-services-maps:18.1.0'
    implementation 'com.google.android.gms:play-services-places:17.0.0'

    implementation ('com.adevinta.android:leku:10.1.0') {
        exclude group: 'com.google.android.gms'
        exclude group: 'androidx.appcompat'
    }

    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
ferranpons commented 1 year ago

@MiguelDAD The issue is that you are using a different version of play-services-location than the library on the version 10.1.0. Please update your library to the latest version (10.1.1) to avoid that issue.