React-native-background-geolocation: Application keeps stopping after deploying android app in Closed Test environment

Created on 17 Nov 2020  路  13Comments  路  Source: transistorsoft/react-native-background-geolocation

Your Environment

  • Plugin Version: "react-native-background-fetch": "^3.1.0", "react-native-background-geolocation": "^3.9.0"
  • Platform: Android
  • OS version: Android 10, Oxygen OS (sdk29)
  • Device manufacturer / model: OnePlus Nord
  • React Native version (react-native -v): 0.62.2
  • Plugin config
    ```javascript
    UNSAFE_componentWillMount() {
    // 1. Wire up event-listeners
    // This handler fires whenever bgGeo receives a location update.
    BackgroundGeolocation.onLocation(this.onLocation, this.onError);
    // This event fires when the user toggles location-services authorization
    BackgroundGeolocation.onProviderChange(this.onProviderChange);

    }

    componentDidMount() {

    // 2.  Execute #ready method (required)
    BackgroundGeolocation.ready({
        // Geolocation Config
        desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
        distanceFilter: 1609, //minimum distance in meters (1 mile)
        stopTimeout: 5, //time in minutes
        useSignificantChangesOnly: true,
        //debug: true, // <-- enable this hear sounds for background-geolocation life-cycle.
        logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
        stopOnTerminate: true,   // <-- Allow the background-service to continue tracking when user closes the app.
        //startOnBoot: true,        // <-- Auto start tracking when device is powered-up.
        notification: false,
        extras: {
            "isGasStationNearMe": false
        },
    
        locationAuthorizationRequest: 'Always',
        backgroundPermissionRationale: {
            title: "Allow HPC Fuel Rite to access this device's location in the background",
            message: "In order to track your activity in the background, please enable background location permission",
            positiveAction: "Allow",
            negativeAction: "Cancel"
        }
    
    }, (state) => {
        this.setState({ locationState: state })
    }, (error) => {
        console.log('Error while bg.ready()', error)
    });
    

    }

    // You must remove listeners when your component unmounts
    componentWillUnmount() {

    BackgroundGeolocation.stop();
    
    if (!this.state.notificationIsEnabled) {
        BackgroundGeolocation.removeListeners();
    }
    //this.setLocationUpdates("off")
    //this.toggleSwitch()
    

    }

## Expected Behavior
<!--- Tell us what should happen -->
Application should open and function as intended.

## Actual Behavior
<!--- Tell us what happens instead -->
Application crashes when opened.

## Steps to Reproduce
<!--- reproduce this issue; include code to reproduce, if relevant -->
1. Deploy app in Google Play Store Closed Testing track
2. Open app after installing.

## Context
<!--- -->
 I am trying to deploy and soon move into production
## Debug logs
<!-- include iOS / Android logs
- ios XCode logs,
- use #getLog #emailLog methods (@see docs)
- Android: $ adb logcat -s TSLocationManager
-->
<details><summary>Logs</summary>

``` <!-- Syntax highlighting:  DO NOT REMOVE -->
java.lang.ExceptionInInitializerError

java.lang.ExceptionInInitializerError: 
  at com.transistorsoft.locationmanager.adapter.TSConfig.getInstance (TSConfig.java)
  at com.transistorsoft.rnbackgroundgeolocation.RNBackgroundGeolocationModule.<init> (RNBackgroundGeolocationModule.java:26)
  at com.transistorsoft.rnbackgroundgeolocation.RNBackgroundGeolocation.createNativeModules (RNBackgroundGeolocation.java:7)
  at com.facebook.react.ReactPackageHelper.getNativeModuleIterator (ReactPackageHelper.java:41)
  at com.facebook.react.NativeModuleRegistryBuilder.processPackage (NativeModuleRegistryBuilder.java:30)
  at com.facebook.react.ReactInstanceManager.processPackage (ReactInstanceManager.java:34)
  at com.facebook.react.ReactInstanceManager.processPackages (ReactInstanceManager.java:54)
  at com.facebook.react.ReactInstanceManager.createReactContext (ReactInstanceManager.java:36)
  at com.facebook.react.ReactInstanceManager.access$1000 (ReactInstanceManager.java)
  at com.facebook.react.ReactInstanceManager$5.run (ReactInstanceManager.java:68)
  at java.lang.Thread.run (Thread.java:919)
Caused by: java.lang.NullPointerException: 
  at com.transistorsoft.tslocationmanager.Application.FIIdnABGd (Application.java:27)
  at com.transistorsoft.locationmanager.adapter.TSConfig.<clinit> (TSConfig.java:2)
  at com.transistorsoft.locationmanager.adapter.TSConfig.getInstance (TSConfig.java)
  at com.transistorsoft.rnbackgroundgeolocation.RNBackgroundGeolocationModule.<init> (RNBackgroundGeolocationModule.java:26)
  at com.transistorsoft.rnbackgroundgeolocation.RNBackgroundGeolocation.createNativeModules (RNBackgroundGeolocation.java:7)
  at com.facebook.react.ReactPackageHelper.getNativeModuleIterator (ReactPackageHelper.java:41)
  at com.facebook.react.NativeModuleRegistryBuilder.processPackage (NativeModuleRegistryBuilder.java:30)
  at com.facebook.react.ReactInstanceManager.processPackage (ReactInstanceManager.java:34)
  at com.facebook.react.ReactInstanceManager.processPackages (ReactInstanceManager.java:54)
  at com.facebook.react.ReactInstanceManager.createReactContext (ReactInstanceManager.java:36)
  at com.facebook.react.ReactInstanceManager.access$1000 (ReactInstanceManager.java)
  at com.facebook.react.ReactInstanceManager$5.run (ReactInstanceManager.java:68)
  at java.lang.Thread.run (Thread.java:919)

Most helpful comment

For what it's worth, I find ssh config tedious in the context of CI pipelines and other developer's machines etc.
I found it easier to do a "Personal Access Token" in github: https://github.com/settings/tokens

Then in package.json my dependency looks like this:

   \\ ...
"react-native-background-geolocation-android": "git+https://<the token here>:[email protected]/transistorsoft/react-native-background-geolocation-android.git#3.9.3",
  \\ ...

And then it is functional everywhere. As with all things security, your security requirements may differ and make this style unacceptable, but if it is acceptable it is quite easy.

All 13 comments

Have you purchased a license?

Yes I have.
The purchase was made in August 2020, My order number is #6078.

Customers should post issues to (and install the plugin from) the private repo.

You deleted Plugin Version from the Issue template. Edit your issue and provide this information.

Your Environment

  • Plugin version:

Done

You know that the npm version react-native-background-geolocation gets mirrored from the private repo only about every 3 months?

Also, the latest npm version is 3.9.3

okay, I will update the npm version and upload a build.
Will keep you updated with the result after deploying app

Why are you not installing from the private repo? Latest fixes / new features arrive first in the private repo. The npm version can lag behind by up to 3 months.

I think I missed that step.
Can you please redirect me to the guide for it?

Can you please redirect me to the guide for it?

I posted the link right up there.

While trying to install the plugin from the private repo I'm getting an error:

Host key verification failed. 
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I checked the members as well and I have added myself

Check your Github ssh config.

For what it's worth, I find ssh config tedious in the context of CI pipelines and other developer's machines etc.
I found it easier to do a "Personal Access Token" in github: https://github.com/settings/tokens

Then in package.json my dependency looks like this:

   \\ ...
"react-native-background-geolocation-android": "git+https://<the token here>:[email protected]/transistorsoft/react-native-background-geolocation-android.git#3.9.3",
  \\ ...

And then it is functional everywhere. As with all things security, your security requirements may differ and make this style unacceptable, but if it is acceptable it is quite easy.

issue was fixed after installing from the correct repo, and renaming the package name.

Thank you for the guidance @christocracy

Was this page helpful?
0 / 5 - 0 ratings