react-native-background-geolocation: Cannot read property 'addEventListener' of undefined (with proper setup)

Your Environment

  • Plugin version: 3.2.0
  • Platform: Android
  • OS version: 9
  • Device manufacturer / model: Simulator (Pixel 2 API 28)
  • React Native version (react-native -v): 0.60.5
  • Plugin config
  reset: true,

  // Geolocation Config
  desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
  distanceFilter: 10,

  // Activity Recognition
  stopTimeout: 1,

  // Application config
  debug: true,
  logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
  stopOnTerminate: false,
  startOnBoot: true,

  // HTTP
  url: Config.TRACKING_URL(Firebase.uid()),
  batchSync: false,
  autoSync: true,
  headers: {
    Authorization: 'Bearer ' + Firebase.authToken(),
  },

Expected Behavior

Tracking and everything working fine on iOS and should build on Android the same (with proper package setup)

Actual Behavior

Similar to #777

We have triple checked the setup process and confirmed each step is correct however we are still receiving the error: Cannot read property 'addEventListener' of undefined on Android - almost certainly a setup issue error.

The last time we set this package up was almost 2 years ago and the setup process was much different then, it looks like the “auto linking” process may be at fault here?

What other areas should I be checking to ensure a proper setup (MainApplication.java for instance). I’m almost certain something in the auto-linking process was unsuccessful.

Steps to Reproduce

  1. Follow setup steps
  2. Run android app on API 28, Android v.9
  3. Error received

Context

Compile App

Debug logs

Logs
LOGCAT:
2019-09-12 17:33:45.415 30054-30054/com.bolt.carrier.staging E/TSLocationManager: 
    ╔═════════════════════════════════════════════
    ║ LICENSE VALIDATION FAILURE: com.XXXXXXXXXX
    ╠═════════════════════════════════════════════
    ╟─ Invalid license key: XXXXXXXXXXXXXXXXXXXXXXXXXX
    ╟─ BackgroundGeolocation is fully functional in DEBUG builds without a license.
    ╚═════════════════════════════════════════════
Screen Shot 2019-09-12 at 5 39 31 PM Screen Shot 2019-09-12 at 5 39 44 PM

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 19 (12 by maintainers)

Most upvoted comments

@christocracy you are completely right, this actually works just fine. Thanks as always!

  protected List<ReactPackage> getPackages() {
    @SuppressWarnings("UnnecessaryLocalVariable")
    List<ReactPackage> packages = new PackageList(this).getPackages();  // <-- this
    // Packages that cannot be autolinked yet can be added manually here, for example:
    // packages.add(new MyReactNativePackage());
    return packages;
  }

Why are you scared to try this, and fixing RN auto-linking?

protected List<ReactPackage> getPackages() {
  	@SuppressWarnings("UnnecessaryLocalVariable")
  	List<ReactPackage> packages = new PackageList(this).getPackages();  // <-- this
  	// Packages that cannot be autolinked yet can be added manually here, for example:
  	// packages.add(new MyReactNativePackage());

  	packages.add(new ReactNativeFirebaseAppPackage());
  	packages.add(new ReactNativeFirebaseAuthPackage());
  	packages.add(new ReactNativeFirebaseDatabasePackage());

  	return packages;
}