mcharmas / Android-ReactiveLocation

Small library that wraps Google Play Service API in brilliant RxJava Observables reducing boilerplate to minimum.
2.11k stars 313 forks source link

getLastKnownLocation() crash... #148

Closed lisbejuin closed 7 years ago

lisbejuin commented 7 years ago

Hello, First, thanks for this library it's great ! 👍 But I have a problem :/ When I run your sample all it's OK 👍 But when I run in my application I have this error :

I'm very embarassed... I tried a lot of things and even I have paste the same code of exemple but I have always this error and my app crash. The crash is on the instruction : ReactiveLocationProvider locationProvider = new ReactiveLocationProvider(getBaseContext()); locationProvider.getLastKnownLocation() And its no pass on the doOnError...

Thanks a lot for help ! :)

Logs : I/dalvikvm: Could not find method com.google.android.gms.common.api.Api$zzf., referenced from method com.google.android.gms.location.LocationServices. W/dalvikvm: VFY: unable to resolve direct method 20025: Lcom/google/android/gms/common/api/Api$zzf;. ()V D/dalvikvm: VFY: replacing opcode 0x70 at 0x0002 I/dalvikvm: Could not find method com.google.android.gms.common.internal.zzac.zzb, referenced from method com.google.android.gms.location.LocationServices.zzj W/dalvikvm: VFY: unable to resolve static method 21092: Lcom/google/android/gms/common/internal/zzac;.zzb (ZLjava/lang/Object;)V D/dalvikvm: VFY: replacing opcode 0x71 at 0x0009 W/dalvikvm: Superclass of 'Lcom/google/android/gms/location/LocationServices$1;' is interface 'Lcom/google/android/gms/common/api/Api$zza;' W/dalvikvm: Link of class 'Lcom/google/android/gms/location/LocationServices$1;' failed D/dalvikvm: DexOpt: unable to opt direct call 0x70fc at 0x09 in Lcom/google/android/gms/location/LocationServices;. D/dalvikvm: DexOpt: unable to opt direct call 0x4e43 at 0x1a in Lcom/google/android/gms/location/LocationServices;. W/dalvikvm: Exception Ljava/lang/NoSuchMethodError; thrown while initializing Lcom/google/android/gms/location/LocationServices; D/AndroidRuntime: Shutting down VM W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x40ccd9a8) D/dalvikvm: GC_FOR_ALLOC freed 372K, 14% free 3800K/4376K, paused 13ms, total 13ms E/AndroidRuntime: FATAL EXCEPTION: main java.lang.NoSuchMethodError: com.google.android.gms.common.api.Api$zzf. at com.google.android.gms.location.LocationServices.(Unknown Source) at pl.charmas.android.reactivelocation.observables.BaseLocationObservable.(BaseLocationObservable.java:9) at pl.charmas.android.reactivelocation.observables.location.LastKnownLocationObservable.(LastKnownLocationObservable.java:20) at pl.charmas.android.reactivelocation.observables.location.LastKnownLocationObservable.createObservable(LastKnownLocationObservable.java:16) at pl.charmas.android.reactivelocation.ReactiveLocationProvider.getLastKnownLocation(ReactiveLocationProvider.java:77)

mcharmas commented 7 years ago

Did you add google play services dependency to your gradle configuration?

lisbejuin commented 7 years ago

Yes, its my gradle imports :

compile 'io.reactivex:rxjava:1.2.0' compile 'io.reactivex:rxandroid:1.2.1' compile 'com.jakewharton.rxbinding:rxbinding:0.4.0' compile 'pl.charmas.android:android-reactive-location:0.10@aar' compile 'com.google.android.gms:play-services-maps:9.4.0' compile 'com.google.android.gms:play-services-location:9.4.0' compile 'com.google.android.gms:play-services-places:9.4.0' compile 'com.google.android.gms:play-services-gcm:9.4.0' compile 'com.google.android.gms:play-services-base:9.4.0' compile 'com.tbruyelle.rxpermissions:rxpermissions:0.7.0@aar'

lisbejuin commented 7 years ago

Have I omits somethings ?

mcharmas commented 7 years ago

It looks like you have everything what is necessary. I have no idea what is the reason of your error. Do you use proguard? Maybe you haven't synced project with gradle after modification?

lisbejuin commented 7 years ago

Yes, I use proguard : buildTypes { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } }

and I have Sync gradle after modification... It's very strange... :/

I continue to search the solution of the issue and if I don't found, I will use the basic way without Rx...

Thanks for your reply :)

mcharmas commented 7 years ago

Try turning proguard off and check if you still have this issue. Maybe it's proguard's configuration problem.

lisbejuin commented 7 years ago

It's the same :/

lisbejuin commented 7 years ago

After more and more tests without succes... I decided to create a new project and I transfered my code on it and all in new project works !! I think some wrong things are in old project in generated or build files I don't know... So thanks for your helps !

mcharmas commented 7 years ago

I'm glad it works.