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

Android App CRASH when BackgroundGeolocation.start() or BackgroundGeolocation.stop() #1985

Closed
russmenum opened this issue Apr 2, 2024 · 1 comment

Comments

@russmenum
Copy link

russmenum commented Apr 2, 2024

Your Environment

  • Plugin version: 4.12.1
  • Platform: Android
  • OS version: Simulator API 34 and phone Android 13 API 33
  • Device manufacturer / model: Simulator and Pixel
  • React Native version (react-native -v): 0.71.14
  • Plugin config
const trackingSessionCnfig = {
      // Geolocation Config
      desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
      distanceFilter: isAvailableTracking ? 250 : meterFromBackEndContext,
      stopTimeout: secFromBackEndContext,
      // heartbeatInterval: 60,//30-min moved to the hearbeet counter above //60 * 30,//android can not be less that 60, ?? iOS ignoring under 60 sec
      // preventSuspend: aggressiveTrackingContext,//iOS needs this to run the BackgroundGeolocation.onHeartbeat above
      // //[Geolocation] iOS Options
     
      // Application config
      debug: false, // <-- enable this hear sounds for background-geolocation life-cycle.
      logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
      stopOnTerminate: false,
      startOnBoot: true,

      // HTTP / SQLite config
      url: ${URL},
      batchSync: false,       // <-- [Default: false] Set true to sync locations to server in a single HTTP request.
      autoSync: true,         // <-- [Default: true] Set true to sync each location to server as it arrives.
      headers: {              // <-- Optional HTTP headers
        "Accept": "application/json",
        "Content-Type": "application/json",
        "Authorization": `Bearer ${userToken}`,
      },
      locationTemplate: '{"lat":<%= latitude %>, "lng":<%= longitude %>, "timestamp": "<%= timestamp %>", "heading": <%= heading %>, "heading_accuracy": <%= heading_accuracy %>, "speed": <%= speed %>, "speed_accuracy": <%= speed_accuracy %>, "is_moving": <%= is_moving %>, "odometer": <%= odometer %>, "altitude": <%= altitude %>, "altitude_accuracy": <%= altitude_accuracy %>, "type_confidence": <%= activity.confidence %>, "type": "<%= activity.type %>", "is_charging": "<%= battery.is_charging %>", "battery_level": <%= battery.level %> }',
      extras: {
        "driver": `${userNameContext.toLowerCase().trim()} ${phoneOS}, ${deliveryMM_order_id}`,
        "title": isAvailableTracking ? "isAvailable ping" : "ping",
        "appver": `${appVersion}`,
        "users_id": `${userIDContext}`,
        "establishment_user_id": `${establishmentIDContext}`,
        "layer": `background`,
        //need to make OS it own pram in BE
        "isAvailableTracking": isAvailableTracking//for scope to the background tasks
      }
}
BackgroundGeolocation.ready(trackingSessionCnfig).then((state) => {
      // YES -- .ready() has now resolved.
      console.log("- barebone is configured and ready: ", state);

      // BackgroundGeolocation.getCurrentPosition(options);
      BackgroundGeolocation.start(function() {
        console.log("- barebone Start success");
        setActiveTrack(true);
      });  
    });

Expected Behavior

I should run .start() and have tracking running in the background, and be able to run .stop()

Actual Behavior

On the Simulator App crashes, on the actual phone just completely locks up

Steps to Reproduce

  1. Have a working app
  2. Upgrade to RN 0.71 from an older ver
  3. Start tracking
  4. Android App CRASH

Context

Updating to the latest RN incrementally.  And preparing for API 34 compliance on Android. Everything is still working as always on XCODE with some weeks for updates, Android side CRASH. 

To work down I already updated the use of which is removed in RN 0.71

// import { AsyncStorage } from "react-native"; // as of RN 0.71 REMOVED
import AsyncStorage from '@react-native-async-storage/async-storage';

and made as as indicated here a bare min start to see if it was react-native-background-geolocation or other code. Some permission or order or something has changed from RN 0.63.4 bump. 

I put logs: RIGHT BEFORE BackgroundGeolocation.start() that runs, NESTED IN which depending runs, and RIGHT AFTER which never runs... it is the BackgroundGeolocation.start() where it crashed.

Debug logs

Logs


@russmenum
Copy link
Author

You can close this one, USER ERROR/RTFM. I missed the changes in FETCH ver and extra bits in the build.gradle as a result. Fixing that per doc resolved the so it no longer crashes

For what ever reason prominate display takes FAR LONGER now, but it works, so that can be addressed with an ALERT

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

No branches or pull requests

1 participant