radarlabs / react-native-radar

React Native module for Radar, the leading geofencing and location tracking platform
https://radar.com
Apache License 2.0
170 stars 32 forks source link

Update Documentation #40

Closed neegbeah closed 6 years ago

neegbeah commented 6 years ago

I was trying to integrate the SDK into my React Native project. I was having fatal errors on the Android Application

    Process: com.paccarapp, PID: 32311
    java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/api/Api$zzf;
        at com.google.android.gms.location.LocationServices.<clinit>(Unknown Source:0)
        at com.google.android.gms.location.LocationServices.getGeofencingClient(Unknown Source:0)
        at io.radar.sdk.di.LocationModule.geofencingClient(LocationModule.kt:20)
        at io.radar.sdk.di.LocationModule_GeofencingClientFactory.proxyGeofencingClient(LocationModule_GeofencingClientFactory.java:31)
        at io.radar.sdk.di.LocationModule_GeofencingClientFactory.provideInstance(LocationModule_GeofencingClientFactory.java:23)
        at io.radar.sdk.di.LocationModule_GeofencingClientFactory.get(LocationModule_GeofencingClientFactory.java:19)
        at io.radar.sdk.di.LocationModule_GeofencingClientFactory.get(LocationModule_GeofencingClientFactory.java:10)
        at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
        at io.radar.sdk.location.LocationManager_Factory.provideInstance(LocationManager_Factory.java:55)
        at io.radar.sdk.location.LocationManager_Factory.get(LocationManager_Factory.java:37)
        at io.radar.sdk.location.LocationManager_Factory.get(LocationManager_Factory.java:11)
        at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
        at io.radar.sdk.di.DaggerRadarComponent.injectRadar(DaggerRadarComponent.java:135)
        at io.radar.sdk.di.DaggerRadarComponent.inject(DaggerRadarComponent.java:125)
        at io.radar.sdk.internal.RadarInitProvider.onCreate(RadarInitProvider.kt:24)
        at android.content.ContentProvider.attachInfo(ContentProvider.java:1917)
        at android.content.ContentProvider.attachInfo(ContentProvider.java:1892)
        at android.app.ActivityThread.installProvider(ActivityThread.java:6239)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:5805)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5722)
        at android.app.ActivityThread.-wrap1(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.api.Api$zzf" on path: DexPathList[[zip file "/data/app/com.paccarapp-Z8y_kb4NP1h6KL0O6MGjew==/base.apk"],nativeLibraryDirectories=[/data/app/com.paccarapp-Z8y_kb4NP1h6KL0O6MGjew==/lib/x86, /data/app/com.paccarapp-Z8y_kb4NP1h6KL0O6MGjew==/base.apk!/lib/x86, /system/lib, /vendor/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at com.google.android.gms.location.LocationServices.<clinit>(Unknown Source:0) 
        at com.google.android.gms.location.LocationServices.getGeofencingClient(Unknown Source:0) 
        at io.radar.sdk.di.LocationModule.geofencingClient(LocationModule.kt:20) 
        at io.radar.sdk.di.LocationModule_GeofencingClientFactory.proxyGeofencingClient(LocationModule_GeofencingClientFactory.java:31) 
        at io.radar.sdk.di.LocationModule_GeofencingClientFactory.provideInstance(LocationModule_GeofencingClientFactory.java:23) 
        at io.radar.sdk.di.LocationModule_GeofencingClientFactory.get(LocationModule_GeofencingClientFactory.java:19) 
        at io.radar.sdk.di.LocationModule_GeofencingClientFactory.get(LocationModule_GeofencingClientFactory.java:10) 
        at dagger.internal.DoubleCheck.get(DoubleCheck.java:47) 
        at io.radar.sdk.location.LocationManager_Factory.provideInstance(LocationManager_Factory.java:55) 
        at io.radar.sdk.location.LocationManager_Factory.get(LocationManager_Factory.java:37) 
        at io.radar.sdk.location.LocationManager_Factory.get(LocationManager_Factory.java:11) 
        at dagger.internal.DoubleCheck.get(DoubleCheck.java:47) 
        at io.radar.sdk.di.DaggerRadarComponent.injectRadar(DaggerRadarComponent.java:135) 
        at io.radar.sdk.di.DaggerRadarComponent.inject(DaggerRadarComponent.java:125) 
        at io.radar.sdk.internal.RadarInitProvider.onCreate(RadarInitProvider.kt:24) 
        at android.content.ContentProvider.attachInfo(ContentProvider.java:1917) 
        at android.content.ContentProvider.attachInfo(ContentProvider.java:1892) 
        at android.app.ActivityThread.installProvider(ActivityThread.java:6239) 
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:5805) 
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5722) 
        at android.app.ActivityThread.-wrap1(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:164) 
        at android.app.ActivityThread.main(ActivityThread.java:6494) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 

Then find out you need to add the following dependencies on the app module. Note the documentation suggests adding Google Play Services but just adding that alone will produce the same error:

compile 'com.google.android.gms:play-services-maps:16.0.0' compile 'com.google.android.gms:play-services-location:16.0.0'

Probably need to add this on the SDK Documentation. This will make newcomers for React Native pretty inconvenient to setup.

russellcullen commented 6 years ago

Actually that specific version of play-services-location is not needed unless you are also including a conflicting library version. Gradle will pull in the transitive dependencies of react-native-radar automatically.

We'll keep in mind build errors with conflicting versions and add a note in the future. Sorry for the inconvenience here.