Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NullPointerException · Attempt to invoke virtual method 'void android.app.Activity.runOnUiThread(java.lang.Runnable)' on a null object reference #181

Closed
Yusiro85 opened this issue Apr 20, 2018 · 18 comments

Comments

@Yusiro85
Copy link

Your Environment

  • Plugin version: 0.5.0-alpha.10
  • Platform: Android
  • OS version: 6.0
  • Device manufacturer and model: Google Nexus 5 - 6.0.0 - API 23 - 1080x1920
  • React Native version: 0.51.0
  • Plugin configuration options:
    BackgroundGeolocation.configure({
    distanceFilter: 50,
    debug: false,
    startOnBoot: false,
    stationaryRadius: 50,
    stopOnTerminate: true,
    desiredAccuracy: 10,
    interval: 15000
    });
  • Link to your project:

Context

Expected Behavior

Having these two lines of codes in my ComponentWillUnmount(),
BackgroundGeolocation.stop();
BackgroundGeolocation.events.forEach(event => BackgroundGeolocation.removeAllListeners(event));

When I press home key and close the app, it should not crash.

Actual Behavior

Tested on different android devices and emulator had different behaviors,
some would not crashed but some would.

Possible Fix

Steps to Reproduce

Context

Debug logs

BackgroundGeolocationFacade.java:432com.marianhello.bgloc.BackgroundGeolocationFacade.runOnUiThread
BackgroundGeolocationFacade.java:377com.marianhello.bgloc.BackgroundGeolocationFacade.safeUnbindService
BackgroundGeolocationFacade.java:219com.marianhello.bgloc.BackgroundGeolocationFacade.stop
BackgroundGeolocationModule.java:133com.marianhello.react.BackgroundGeolocationModule$2.run
Thread.java:818java.lang.Thread.run
error

@mauron85
Copy link
Owner

Thank you for reporting. This has been fixed in 0.5.0-alpha.21.

Don't take following anyhow personally. But it would offload lot of burden from me, if I don't have to check if reported issue was not fixed in some later releases. This is specially valid for alpha releases.
So I want to please before reporting issue on alpha channel, make sure you can also replicate on latest alpha version.

@Yusiro85
Copy link
Author

Thanks. How do I replicate on the latest alpha version?
Sorry I'm quite new to this

@mauron85
Copy link
Owner

mauron85 commented Apr 20, 2018

Well that's something I would like know too. I don't know how you managed to get this exception.
There is PR mauron85/background-geolocation-android#2 I accepted and looks like it should handle this exception, but there are no steps how to reproduce. Maybe @chuece can answer that.

@Yusiro85
Copy link
Author

After upgrading to 0.5.0-alpha.21, the null exception issue gone but I'm getting another exception.
The following is the exception log,

java.lang.IllegalArgumentExceptioncom.android.launcher3.Launcher
Receiver not registered: com.marianhello.bgloc.BackgroundGeolocationFacade$2@239b55d

LoadedApk.java:780android.app.LoadedApk.forgetReceiverDispatcher
ContextImpl.java:1195android.app.ContextImpl.unregisterReceiver
ContextWrapper.java:576android.content.ContextWrapper.unregisterReceiver
BackgroundGeolocationFacade.java:227com.marianhello.bgloc.BackgroundGeolocationFacade.unregisterLocationModeChangeReceiver
BackgroundGeolocationFacade.java:241com.marianhello.bgloc.BackgroundGeolocationFacade.stop
BackgroundGeolocationModule.java:131com.marianhello.bgloc.react.BackgroundGeolocationModule$2.run
Thread.java:818java.lang.Thread.run

It is quite hard to reproduce though. It happened when I launched the app after the first time fresh installation and I couldn't reproduce it anymore using the same way right after that.
I will post the adb logcat logs if I manage to reproduce it again.

By the way, I realise that the app sometimes resume rather than relaunch from the beginning, after I pressed home key and closed it. Is there anyway to prevent it from resuming? I have stopped the services and removed all the event handlers. Below is my configuration and log,

BackgroundGeolocation.configure({
distanceFilter: 50,
debug: false,
startOnBoot: false,
stationaryRadius: 50,
stopOnTerminate: true,
desiredAccuracy: 10,
interval: 15000
});

04-20 20:16:44.571 6100-6100/com.GoBunnydriver I/com.marianhello.bgloc.react.BackgroundGeolocationModule: Destroying plugin
04-20 20:16:44.720 6100-6100/com.GoBunnydriver I/com.marianhello.bgloc.BackgroundGeolocationFacade: Destroying plugin
04-20 20:16:44.728 6100-6591/com.GoBunnydriver D/com.marianhello.bgloc.BackgroundGeolocationFacade: Stopping service
04-20 20:16:44.827 6100-6100/com.GoBunnydriver D/com.marianhello.bgloc.BackgroundGeolocationFacade: Unbinding from service
04-20 20:16:44.862 6100-6591/com.GoBunnydriver I/com.marianhello.bgloc.BackgroundGeolocationFacade: Stopping bg service
04-20 20:16:44.899 6100-6100/com.GoBunnydriver I/com.marianhello.bgloc.BackgroundGeolocationFacade: Stopping bg service
04-20 20:16:45.179 6100-6100/com.GoBunnydriver D/com.marianhello.bgloc.LocationService: Task has been removed
04-20 20:16:45.212 6100-6100/com.GoBunnydriver I/com.marianhello.bgloc.LocationService: Stopping self
04-20 20:16:45.326 6100-6100/com.GoBunnydriver D/com.marianhello.bgloc.LocationService: Handler received message: { when=-428ms what=3 arg1=666 target=com.marianhello.bgloc.LocationService$IncomingHandler }
04-20 20:16:45.368 6100-6100/com.GoBunnydriver D/com.marianhello.bgloc.LocationService: All clients have unbound from service
04-20 20:16:45.406 6100-6100/com.GoBunnydriver I/com.marianhello.bgloc.LocationService: Destroying LocationService
04-20 20:16:45.426 6100-6100/com.GoBunnydriver I/com.tenforwardconsulting.bgloc.DistanceFilterLocationProvider: Destroying DistanceFilterLocationProvider
04-20 20:17:00.257 6100-6100/com.GoBunnydriver D/ReactNative: ReactInstanceManager.attachRootViewToInstance()
04-20 20:17:00.258 6100-6184/com.GoBunnydriver I/ReactNativeJS: Running application "Driver" with appParams: {"rootTag":11}. DEV === true, development-level warning are ON, performance optimizations are OFF
04-20 20:17:00.261 6100-6100/com.GoBunnydriver I/com.marianhello.bgloc.react.BackgroundGeolocationModule: App will be resumed

@Yusiro85
Copy link
Author

Just tried it again and hit the same error. App crashed immediately when I was trying to call stop() and removeEventListeners() in my ComponentWillUnmount method.

The following is the adb log:

04-20 21:02:35.738 8194-8194/com.GoBunnydriver D/com.marianhello.bgloc.BackgroundGeolocationFacade: Received MSG_ON_STATIONARY
04-20 21:02:41.402 8194-8215/com.GoBunnydriver W/EGL_emulation: eglSurfaceAttrib not implemented
04-20 21:02:41.402 8194-8215/com.GoBunnydriver W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xd69e9840, error=EGL_SUCCESS
04-20 21:02:42.151 8194-8215/com.GoBunnydriver E/Surface: getSlotFromBufferLocked: unknown buffer: 0xd402f440
04-20 21:02:43.841 8194-8194/com.GoBunnydriver I/com.marianhello.bgloc.react.BackgroundGeolocationModule: App will be paused
04-20 21:02:43.872 8194-8215/com.GoBunnydriver E/Surface: getSlotFromBufferLocked: unknown buffer: 0xda01e0f0
04-20 21:02:43.878 8194-8194/com.GoBunnydriver D/com.marianhello.bgloc.LocationService: Handler received message: { when=-19ms what=6 target=com.marianhello.bgloc.LocationService$IncomingHandler }
04-20 21:02:45.410 8194-8194/com.GoBunnydriver D/ReactNative: ReactInstanceManager.detachViewFromInstance()
04-20 21:02:45.411 8194-8194/com.GoBunnydriver I/com.marianhello.bgloc.react.BackgroundGeolocationModule: Destroying plugin
04-20 21:02:45.429 8194-8194/com.GoBunnydriver I/com.marianhello.bgloc.BackgroundGeolocationFacade: Destroying plugin
04-20 21:02:45.449 8194-8365/com.GoBunnydriver D/com.marianhello.bgloc.BackgroundGeolocationFacade: Stopping service
04-20 21:02:45.473 8194-8365/com.GoBunnydriver E/com.marianhello.logging.UncaughtExceptionLogger: FATAL EXCEPTION: Thread-735java.lang.IllegalArgumentException: Receiver not registered: com.marianhello.bgloc.BackgroundGeolocationFacade$2@6d67745
at android.app.LoadedApk.forgetReceiverDispatcher(LoadedApk.java:780)
at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:1195)
at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:576)
at com.marianhello.bgloc.BackgroundGeolocationFacade.unregisterLocationModeChangeReceiver(BackgroundGeolocationFacade.java:227)
at com.marianhello.bgloc.BackgroundGeolocationFacade.stop(BackgroundGeolocationFacade.java:241)
at com.marianhello.bgloc.react.BackgroundGeolocationModule$2.run(BackgroundGeolocationModule.java:131)
at java.lang.Thread.run(Thread.java:818)
04-20 21:02:45.476 8194-8194/com.GoBunnydriver D/com.marianhello.bgloc.BackgroundGeolocationFacade: Unbinding from service
04-20 21:02:45.539 8194-8194/com.GoBunnydriver I/com.marianhello.bgloc.BackgroundGeolocationFacade: Stopping bg service
04-20 21:02:45.640 8194-8194/com.GoBunnydriver D/com.marianhello.bgloc.LocationService: Task has been removed
04-20 21:02:45.680 8194-8194/com.GoBunnydriver I/com.marianhello.bgloc.LocationService: Stopping self
04-20 21:02:45.765 8194-8194/com.GoBunnydriver D/com.marianhello.bgloc.LocationService: Handler received message: { when=-226ms what=3 arg1=666 target=com.marianhello.bgloc.LocationService$IncomingHandler }
04-20 21:02:45.776 8194-8194/com.GoBunnydriver D/com.marianhello.bgloc.LocationService: All clients have unbound from service
04-20 21:02:45.798 8194-8194/com.GoBunnydriver I/com.marianhello.bgloc.LocationService: Destroying LocationService
04-20 21:02:45.822 8194-8194/com.GoBunnydriver I/com.tenforwardconsulting.bgloc.DistanceFilterLocationProvider: Destroying DistanceFilterLocationProvider

@mauron85
Copy link
Owner

Can you share your component source code, so I can try to reproduce

@mauron85
Copy link
Owner

mauron85 commented Apr 20, 2018

Also what is your android version? Device model and manufacturer? Or maybe even log from moment plugin is started (start method called).

@mauron85
Copy link
Owner

This looks like race condition. By any chance don't you call stop 2x in close to each other?

@Yusiro85
Copy link
Author

Yusiro85 commented Apr 20, 2018

The attached is my MainScreen Component Source Code. I can't share the whole project as it is too huge and due to some confidential issues.
MainScreen.js.zip

I'm using Geny Motion Google Nexus 5 , android 6.0 API 23.

I have set the stopOnTerminate to True while calling stop() in componentWillUnMount, could that be the issue which caused the race condition?

@Yusiro85
Copy link
Author

Why did the app resume and open the old page when I open it? It seems like doesn't get killed completely and start from splash screen when I close it from recent app list. It calls stop() and removes all listeners when I removed the app from recent app list.

If It calls stop(), removes all listeners on A screen, navigates to B screen and I close it from recent app list, it will show activity DEAD in my adb logcat and start from splash screen again next time when I launch the app.

If it starts the service, bind all event listeners on screen A, and then calls stop(), removes all listeners on same screen when I remove the app from recent app list. The next time when I launch the app again, it will show me the last screen I have viewed without starting from splash screen again.

How do I prevent it from opening the old screen? This only happens on some android devices like Samsung.

@mauron85
Copy link
Owner

mauron85 commented Apr 20, 2018

Why did the app resume and open the old page when I open it? ...

those question are not related to this plugin rather android, react-native... Please use stackoverflow for those.

@chuece
Copy link

chuece commented Apr 20, 2018

I can't reproduce crashes that are fixed in my PR. I`ve just found them in crashlytics of my release build and fixed it.

@mauron85
Copy link
Owner

@Yusiro85 I've tried to mimic your app, but cannot reproduce on Genymotion Custom Phone 6.0.0 API 23

Can you try this example (it's basically same what are you doing in your app):

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React, { Component } from 'react';
import {
  Platform,
  StyleSheet,
  Text,
  View,
  Button
} from 'react-native';
import BackgroundGeolocation from 'react-native-mauron85-background-geolocation';


const instructions = Platform.select({
  ios: 'Press Cmd+R to reload,\n' +
    'Cmd+D or shake for dev menu',
  android: 'Double tap R on your keyboard to reload,\n' +
    'Shake or press menu button for dev menu',
});

class Screen2 extends Component<{}> {
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
          Screen2
        </Text>
      </View>
    );
  }
}

class Screen1 extends Component<{}> {
  componentWillMount() {
    BackgroundGeolocation.configure({
      distanceFilter: 50,
      debug: false,
      startOnBoot: false,
      stationaryRadius: 50,
      stopOnTerminate: true,
      desiredAccuracy: 10,
      interval: 15000
    });

    BackgroundGeolocation.on('location', (location) => {
      //handle your locations here
    });

    BackgroundGeolocation.on('stationary', (stationaryLocation) => {
      //handle stationary locations here
    });

    BackgroundGeolocation.on('error', (error) => {
      console.log('[ERROR] BackgroundGeolocation error:', error);
    });

    BackgroundGeolocation.on('authorization', (status) => {
      console.log('on authorization', status);
      BackgroundGeolocation.checkStatus(status => {
        console.log('[INFO] BackgroundGeolocation service is running', status.isRunning);
        console.log('[INFO] BackgroundGeolocation services enabled', status.locationServicesEnabled);
        console.log('[INFO] BackgroundGeolocation auth status: ' + status.authorization); 
      });
    });

    BackgroundGeolocation.start(() => {
      console.log('[DEBUG] BackgroundGeolocation started successfully');    
    });
  }

  componentWillUnmount() {
    BackgroundGeolocation.stop();
    BackgroundGeolocation.events.forEach(event => BackgroundGeolocation.removeAllListeners(event));
  }

  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
          Welcome to React Native!
        </Text>
        <Text style={styles.instructions}>
          To get started, edit App.js
        </Text>
        <Text style={styles.instructions}>
          {instructions}
        </Text>
      </View>
    );
  }
}

export default class App extends Component<{}> {
  constructor(props) {
    super(props);
    this.state = {
      screen: 1
    };
  }

  onBtnPress = () => {
    if (this.state.screen === 1) {
      this.setState({ screen: 2});
    } else {
      this.setState({ screen: 1});
    }
  }

  render() {
    return (
      <View style={styles.container}>
        {this.state.screen === 1
          ? <Screen1 />
          : <Screen2 />
        }
        <Button
          onPress={this.onBtnPress}
          title="Next screen"
        />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },  
});

@Yusiro85
Copy link
Author

Sorry for the late reply. I was outstation and couldn't go online last few days

Yes, I have tried your sample code and hit the same error on GenyMotion Google Nexus 5 - 6.0 API 23. It happened when I press home button and removed the app from recent app list.

Below is the log:

04-23 11:45:31.344 2869-3761/com.GoBunnydriver I/com.marianhello.bgloc.react.BackgroundGeolocationModule: App will be resumed
04-23 11:45:31.357 2869-2869/com.GoBunnydriver D/com.marianhello.bgloc.BackgroundGeolocationFacade: Binding to service
04-23 11:45:31.361 2869-3761/com.GoBunnydriver D/ReactNative: ReactInstanceManager.attachRootViewToInstance()
04-23 11:45:31.374 2869-2869/com.GoBunnydriver D/com.marianhello.bgloc.LocationService: Handler received message: { when=-1ms what=2 arg1=666 target=com.marianhello.bgloc.LocationService$IncomingHandler }
04-23 11:45:31.385 2869-2869/com.GoBunnydriver D/com.marianhello.bgloc.LocationService: Handler received message: { when=-12ms what=6 arg1=1 target=com.marianhello.bgloc.LocationService$IncomingHandler }
04-23 11:45:31.474 2869-2929/com.GoBunnydriver D/ReactNative: CatalystInstanceImpl.destroy() end
04-23 11:45:32.408 2869-3760/com.GoBunnydriver W/ReactNativeJS: '[...effects] has been deprecated in favor of all([...effects]), please update your code', ''
04-23 11:45:32.417 2869-3760/com.GoBunnydriver I/ReactNativeJS: Running application "Driver" with appParams: {"rootTag":11}. DEV === true, development-level warning are ON, performance optimizations are OFF
04-23 11:45:35.657 2869-3771/com.GoBunnydriver D/com.marianhello.bgloc.BackgroundGeolocationFacade: Starting service
04-23 11:45:35.658 2869-3770/com.GoBunnydriver D/com.marianhello.bgloc.data.sqlite.SQLiteConfigurationDAO: Configuration persisted with rowId = 1
04-23 11:45:35.658 2869-3770/com.GoBunnydriver D/com.marianhello.bgloc.BackgroundGeolocationFacade: Service configured with: Config[distanceFilter=50 stationaryRadius=50.0 desiredAccuracy=10 interval=15000 fastestInterval=120000 activitiesInterval=10000 isDebugging=false stopOnTerminate=true stopOnStillActivity=true startOnBoot=false startForeground=true locationProvider=0 nTitle=Background tracking nText=ENABLED nIconLarge= nIconSmall= nIconColor= url= syncUrl= syncThreshold=100 httpHeaders={} maxLocations=10000 postTemplate=null]
04-23 11:45:35.698 2869-2887/com.GoBunnydriver W/EGL_emulation: eglSurfaceAttrib not implemented
04-23 11:45:35.698 2869-2887/com.GoBunnydriver W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xd5314500, error=EGL_SUCCESS
04-23 11:45:35.802 2869-2869/com.GoBunnydriver D/com.marianhello.bgloc.LocationService: Handler received message: { when=-98ms what=7 target=com.marianhello.bgloc.LocationService$IncomingHandler }
04-23 11:45:35.825 2869-2869/com.GoBunnydriver I/com.tenforwardconsulting.bgloc.DistanceFilterLocationProvider: Start recording
04-23 11:45:35.856 2869-2869/com.GoBunnydriver I/com.tenforwardconsulting.bgloc.DistanceFilterLocationProvider: Setting pace: false
04-23 11:45:35.912 2869-2887/com.GoBunnydriver E/Surface: getSlotFromBufferLocked: unknown buffer: 0xdfe3ea20
04-23 11:45:35.928 2869-2869/com.GoBunnydriver D/com.tenforwardconsulting.bgloc.DistanceFilterLocationProvider: Location change: Location[gps 3.047862,101.625000 acc=1 et=+16m0s206ms alt=15.0444 vel=0.0 bear=0.0 {Bundle[mParcelledData.dataSize=40]}] isMoving=false
04-23 11:45:35.949 2869-2869/com.GoBunnydriver D/com.tenforwardconsulting.bgloc.DistanceFilterLocationProvider: Location change: Location[gps 3.047862,101.625000 acc=1 et=+16m0s206ms alt=15.0444 vel=0.0 bear=0.0 {Bundle[mParcelledData.dataSize=40]}] isMoving=false
04-23 11:45:36.478 2869-2869/com.GoBunnydriver D/com.tenforwardconsulting.bgloc.DistanceFilterLocationProvider: Location change: Location[gps 3.047862,101.625000 acc=1 et=+16m0s793ms alt=15.0444 vel=0.0 bear=0.0 {Bundle[mParcelledData.dataSize=40]}] isMoving=false
04-23 11:45:36.489 2869-2869/com.GoBunnydriver D/com.tenforwardconsulting.bgloc.DistanceFilterLocationProvider: Location change: Location[gps 3.047862,101.625000 acc=1 et=+16m0s793ms alt=15.0444 vel=0.0 bear=0.0 {Bundle[mParcelledData.dataSize=40]}] isMoving=false
04-23 11:45:37.480 2869-2869/com.GoBunnydriver D/com.tenforwardconsulting.bgloc.DistanceFilterLocationProvider: Location change: Location[gps 3.047862,101.625000 acc=1 et=+16m1s794ms alt=15.0444 vel=0.0 bear=0.0 {Bundle[mParcelledData.dataSize=40]}] isMoving=false
04-23 11:45:37.491 2869-2869/com.GoBunnydriver I/com.tenforwardconsulting.bgloc.DistanceFilterLocationProvider: startMonitoringStationaryRegion: lat=3.0478616666666665 lon=101.625 acy=50.0
04-23 11:45:37.500 2869-2869/com.GoBunnydriver D/com.marianhello.bgloc.LocationService: New stationary BGLocation[gps 3.047862,101.625000 id=null acc=1 t=1524397535000 et=+16m0s206ms alt=15.0444 vel=0.0 bear=0.0 radius=50.0 {Bundle[mParcelledData.dataSize=40]} locprov=0]
04-23 11:45:37.502 2869-3363/com.GoBunnydriver D/com.tenforwardconsulting.bgloc.DistanceFilterLocationProvider: Entering stationary region
04-23 11:45:37.523 2869-2869/com.GoBunnydriver D/com.marianhello.bgloc.LocationService: Persisted location: BGLocation[gps 3.047862,101.625000 id=2 acc=1 t=1524397535000 et=+16m0s206ms alt=15.0444 vel=0.0 bear=0.0 radius=50.0 {Bundle[mParcelledData.dataSize=40]} locprov=0]
04-23 11:45:37.543 2869-2869/com.GoBunnydriver D/com.tenforwardconsulting.bgloc.DistanceFilterLocationProvider: Location change: Location[gps 3.047862,101.625000 acc=1 et=+16m1s794ms alt=15.0444 vel=0.0 bear=0.0 {Bundle[mParcelledData.dataSize=40]}] isMoving=false
04-23 11:45:37.553 2869-2869/com.GoBunnydriver D/com.marianhello.bgloc.BackgroundGeolocationFacade: Received MSG_ON_STATIONARY
04-23 11:45:56.620 2869-2869/com.GoBunnydriver I/com.marianhello.bgloc.react.BackgroundGeolocationModule: App will be paused
04-23 11:45:56.644 2869-2869/com.GoBunnydriver D/com.marianhello.bgloc.LocationService: Handler received message: { when=-12ms what=6 target=com.marianhello.bgloc.LocationService$IncomingHandler }
04-23 11:45:56.684 2869-2887/com.GoBunnydriver E/Surface: getSlotFromBufferLocked: unknown buffer: 0xdfe39460
04-23 11:46:00.037 2869-2869/com.GoBunnydriver D/ReactNative: ReactInstanceManager.detachViewFromInstance()
04-23 11:46:00.037 2869-2869/com.GoBunnydriver I/com.marianhello.bgloc.react.BackgroundGeolocationModule: Destroying plugin
04-23 11:46:00.052 2869-3797/com.GoBunnydriver D/com.marianhello.bgloc.BackgroundGeolocationFacade: Stopping service
04-23 11:46:00.056 2869-2869/com.GoBunnydriver I/com.marianhello.bgloc.BackgroundGeolocationFacade: Destroying plugin
04-23 11:46:00.086 2869-2869/com.GoBunnydriver D/AndroidRuntime: Shutting down VM
04-23 11:46:00.087 2869-2869/com.GoBunnydriver E/com.marianhello.logging.UncaughtExceptionLogger: FATAL EXCEPTION: mainjava.lang.RuntimeException: Unable to destroy activity {com.GoBunnydriver/com.GoBunnydriver.MainActivity}: java.lang.IllegalArgumentException: Receiver not registered: com.marianhello.bgloc.BackgroundGeolocationFacade$2@987be64
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3831)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3849)
at android.app.ActivityThread.-wrap5(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1398)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.IllegalArgumentException: Receiver not registered: com.marianhello.bgloc.BackgroundGeolocationFacade$2@987be64
at android.app.LoadedApk.forgetReceiverDispatcher(LoadedApk.java:780)
at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:1195)
at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:576)
at com.marianhello.bgloc.BackgroundGeolocationFacade.unregisterLocationModeChangeReceiver(BackgroundGeolocationFacade.java:227)
at com.marianhello.bgloc.BackgroundGeolocationFacade.onAppDestroy(BackgroundGeolocationFacade.java:100)
at com.marianhello.bgloc.react.BackgroundGeolocationModule.onHostDestroy(BackgroundGeolocationModule.java:98)
at com.facebook.react.bridge.ReactContext.onHostDestroy(ReactContext.java:228)
at com.facebook.react.ReactInstanceManager.moveToBeforeCreateLifecycleState(ReactInstanceManager.java:705)
at com.facebook.react.ReactInstanceManager.onHostDestroy(ReactInstanceManager.java:614)
at com.facebook.react.ReactInstanceManager.onHostDestroy(ReactInstanceManager.java:628)
at com.facebook.react.ReactActivityDelegate.onDestroy(ReactActivityDelegate.java:142)
at com.facebook.react.ReactActivity.onDestroy(ReactActivity.java:72)
at android.app.Activity.performDestroy(Activity.java:6407)
at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1142)
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3818)
... 9 common frames omitted
04-23 11:46:00.119 2869-3797/com.GoBunnydriver I/com.marianhello.bgloc.BackgroundGeolocationFacade: Stopping bg service
04-23 11:46:00.353 2869-2869/com.GoBunnydriver I/Bugsnag: Saved unsent payload to disk (/data/user/0/com.GoBunnydriver/cache/bugsnag-errors/1524455160115_01783fc6-76c0-4ba8-b93e-214e44eb8947.json)
04-23 11:46:00.353 2869-2885/com.GoBunnydriver I/Bugsnag: Sending 1 saved error(s) to Bugsnag

@Yusiro85
Copy link
Author

those question are not related to this plugin rather android, react-native... Please use stackoverflow for those.

Regarding this issue, I have removed all my codes and applied only the sample code but still getting the same behaviour. Can you help me to look into it?
The app get killed perfectly after I remove the package.

@mauron85
Copy link
Owner

@Yusiro85 ok. i'll added some more guards to prevent race conditions. I'll publish updated plugin later today, so you can test it.

@mauron85
Copy link
Owner

mauron85 commented May 2, 2018

@Yusiro85 can you try latest alpha.24?

@mauron85
Copy link
Owner

fixed in 0.5.0-alpha.36

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants