React-native-background-geolocation: java.lang.NoClassDefFoundError: com.marianhello.bgloc.ActivityRecognitionLocationProvider

Created on 19 Nov 2016  路  2Comments  路  Source: mauron85/react-native-background-geolocation

Trying to include your project in my react-native app and run the example in the readme, I get an app crash with the below stacktrace...

D/AndroidRuntime(16589): Shutting down VM
E/AndroidRuntime(16589): FATAL EXCEPTION: main
E/AndroidRuntime(16589): Process: com.astarreactnative, PID: 16589
E/AndroidRuntime(16589): java.lang.NoClassDefFoundError: com.marianhello.bgloc.ActivityRecognitionLocationProvider
E/AndroidRuntime(16589):    at com.marianhello.bgloc.LocationProviderFactory.getInstance(LocationProviderFactory.java:37)
E/AndroidRuntime(16589):    at com.marianhello.bgloc.LocationService.onStartCommand(LocationService.java:237)
E/AndroidRuntime(16589):    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2924)
E/AndroidRuntime(16589):    at android.app.ActivityThread.access$2100(ActivityThread.java:155)
E/AndroidRuntime(16589):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1415)
E/AndroidRuntime(16589):    at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(16589):    at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime(16589):    at android.app.ActivityThread.main(ActivityThread.java:5343)
E/AndroidRuntime(16589):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(16589):    at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(16589):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
E/AndroidRuntime(16589):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:702)
D/ActivityManager(  930): IKSWL-9411 handleMessage SHOW_ERROR_MSG

I do not have the same issue with the other provider, so maybe it is a packaging issue?

Your Environment

  • Plugin version: "^0.2.0-alpha.5",
  • Platform: Android
  • OS version: 5.1.1
  • Device manufacturer and model: Moto G3
  • React Native version: 0.36.0
  • Plugin configuration options: Copied from Readme

One thing to note, I had to fight play services dependencies issues between this app and react-native-google-signin. I'm not sure if I could be causing the issue, but I did pin the following compile dependencies to skirt those transitive dep issues:

/android/app/build.gradle
...
    compile 'com.google.android.gms:play-services-auth:9.8.0'
    compile 'com.google.android.gms:play-services-base:9.8.0'
    compile 'com.google.android.gms:play-services-maps:9.8.0'
    compile 'com.google.android.gms:play-services-gcm:9.8.0'
...

Some more logs,

I/FA      (16589): App measurement is starting up, version: 9877
I/FA      (16589): To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
I/FA      (16589): To enable faster debug mode event logging run:
I/FA      (16589):   adb shell setprop firebase.analytics.debug-mode com.astarreactnative
I/FirebaseInitProvider(16589): FirebaseApp initialization successful
I/com.marianhello.bgloc.LocationService(16589): Creating LocationService
W/AccountManagerService(  930): insertAccountIntoDatabase: Account {name=dummy, type=com.astarreactnative.account}, skipping since the account already exists
I/com.marianhello.bgloc.LocationService(16589): Received start startId: 1 intent: Intent { flg=0x4 cmp=com.astarreactnative/com.marianhello.bgloc.LocationService (has extras) }
I/com.marianhello.bgloc.LocationService(16589): Network condition changed hasConnectivity: true
D/com.marianhello.bgloc.LocationService(16589): Will start service with: Config[distanceFilter=50 stationaryRadius=50.0 desiredAccuracy=10 interval=5000 fastestInterval=2000 activitiesInterval=5000 isDebugging=true stopOnTerminate=false stopOnStillActivity=false startOnBoot=false startForeground=true locationProvider=1 nTitle=Background tracking nText=enabled nIconLarge=null nIconSmall=null nIconColor=null url=null syncUrl=null syncThreshold=100 httpHeaders={} maxLocations=10000]
I/art     (16589): Rejecting re-init on previously-failed class java.lang.Class<com.marianhello.bgloc.ActivityRecognitionLocationProvider>
I/art     (16589): Rejecting re-init on previously-failed class java.lang.Class<com.marianhello.bgloc.ActivityRecognitionLocationProvider>
I/art     (16589): Rejecting re-init on previously-failed class java.lang.Class<com.marianhello.bgloc.ActivityRecognitionLocationProvider>
D/AndroidRuntime(16589): Shutting down VM
E/AndroidRuntime(16589): FATAL EXCEPTION: main
E/AndroidRuntime(16589): Process: com.astarreactnative, PID: 16589
E/AndroidRuntime(16589): java.lang.NoClassDefFoundError: com.marianhello.bgloc.ActivityRecognitionLocationProvider
E/AndroidRuntime(16589):    at com.marianhello.bgloc.LocationProviderFactory.getInstance(LocationProviderFactory.java:37)
E/AndroidRuntime(16589):    at com.marianhello.bgloc.LocationService.onStartCommand(LocationService.java:237)
E/AndroidRuntime(16589):    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2924)
E/AndroidRuntime(16589):    at android.app.ActivityThread.access$2100(ActivityThread.java:155)
E/AndroidRuntime(16589):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1415)
E/AndroidRuntime(16589):    at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(16589):    at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime(16589):    at android.app.ActivityThread.main(ActivityThread.java:5343)
E/AndroidRuntime(16589):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(16589):    at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(16589):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
E/AndroidRuntime(16589):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:702)
D/ActivityManager(  930): IKSWL-9411 handleMessage SHOW_ERROR_MSG
W/ActivityManager(  930): IKSWL-9411 mShowDialogs:true mSleeping:false mShuttingDown:false
W/DropBoxManagerService(  930): Dropping: data_app_crash (1065 > 0 bytes)
D/WindowManager(  930): IKSWL-9411 focusChangedLw lastFocus=Window{2ea3296f u0 com.google.android.googlequicksearchbox/com.google.android.launcher.GEL} newFocus=Window{37c6b616 u0 Application Error: com.astarreactnative}
V/WindowManager(  930): ** SHOWING status bar: top is not fullscreen

The only react-native logs I see:

I/ReactNativeJS(18357): start recording pressed.
I/ReactNativeJS(18357): new route! 1479574664831
I/ReactNativeJS(18357): [DEBUG] BackgroundGeolocation started successfully

I get the same logs using the ANDROID_DISTANCE_FILTER_PROVIDER provider, but it does seem to work.

Thanks in advance, and let me know if I can provide anything else.

Most helpful comment

After finaggling play-services dependencies and multidex, I've narrowed it down to dependencies/proguard. I've resolved my issue by pinning play services deps to a particular version, using multidex, and making sure I have included play-services-location.

Full dependencies for posterity...

dependencies {
  compile fileTree(dir: "libs", include: ["*.jar"])
  compile "com.android.support:appcompat-v7:23.0.1"
  compile "com.facebook.react:react-native:+"
  compile (project(':react-native-mapbox-gl')){
    exclude group: "com.google.android.gms"
  }
  compile (project(':react-native-mauron85-background-geolocation')){
    exclude group: "com.google.android.gms"
  }
  compile(project(":react-native-google-signin")){
    exclude group: "com.google.android.gms"
  }
  compile 'com.google.android.gms:play-services-auth:9.8.0'
  compile 'com.google.android.gms:play-services-gcm:9.8.0'
  compile 'com.google.android.gms:play-services-location:9.8.0'
}

All 2 comments

I also had to add multiDex. Maybe this is the issue? I added the compile dep,

compile 'com.android.support:multidex:1.0.1'

the config to defaultConfig,

multiDexEnabled true

and now extend fromMultiDexApplication in my MainApplication. Not sure if this is right/or contributing to my issue. Thanks!

After finaggling play-services dependencies and multidex, I've narrowed it down to dependencies/proguard. I've resolved my issue by pinning play services deps to a particular version, using multidex, and making sure I have included play-services-location.

Full dependencies for posterity...

dependencies {
  compile fileTree(dir: "libs", include: ["*.jar"])
  compile "com.android.support:appcompat-v7:23.0.1"
  compile "com.facebook.react:react-native:+"
  compile (project(':react-native-mapbox-gl')){
    exclude group: "com.google.android.gms"
  }
  compile (project(':react-native-mauron85-background-geolocation')){
    exclude group: "com.google.android.gms"
  }
  compile(project(":react-native-google-signin")){
    exclude group: "com.google.android.gms"
  }
  compile 'com.google.android.gms:play-services-auth:9.8.0'
  compile 'com.google.android.gms:play-services-gcm:9.8.0'
  compile 'com.google.android.gms:play-services-location:9.8.0'
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

MRolandd picture MRolandd  路  6Comments

sefatunckanat picture sefatunckanat  路  7Comments

vinceprofeta picture vinceprofeta  路  5Comments

theebi picture theebi  路  4Comments

ianaz picture ianaz  路  4Comments