Background geolocation suscriber not working

Hello everyone,
I am trying to make a routes creator with ionic, but i get stock with this. I am using ionic 5 with capacitor on android 10.
This is my code:

import { Component } from '@angular/core';
import {
} from '@ionic-native/background-geolocation/ngx';

  selector: 'app-home',
  templateUrl: '',
  styleUrls: [''],
export class HomePage {

  location: BackgroundGeolocationResponse;

  config: BackgroundGeolocationConfig = {
    locationProvider: BackgroundGeolocationLocationProvider.DISTANCE_FILTER_PROVIDER,
    desiredAccuracy: 10,
    stationaryRadius: 20,
    distanceFilter: 0.1,
    interval: 1000,
    debug: false, //  enable this hear sounds for background-geolocation life-cycle.
    stopOnTerminate: true, // enable this to clear background location settings when the app terminates

  constructor(private backgroundGeolocation: BackgroundGeolocation) {
      .then(() => {
          .subscribe((location: BackgroundGeolocationResponse) => {
            this.location = location;
      }).catch((error) => {


  ngOnDestroy() {


The thing is actually workin or its looks like because y the android studio terminal i am getting this :

D/com.tenforwardconsulting.bgloc.DistanceFilterLocationProvider: Location change: Location[gps 37,267922,-4,412952 hAcc=20 et=+12d18h59m5s236ms alt=498.593017578125 vel=0.0 vAcc=24 sAcc=1 bAcc=??? {Bundle[mParcelledData.dataSize=96]}] isMoving=true
D/com.marianhello.bgloc.service.LocationServiceImpl: New location BGLocation[gps 37,267922,-4,412952 id=null acc=20 t=1602590769000 et=+12d18h59m5s236ms alt=498.593017578125 vel=0.0 {Bundle[mParcelledData.dataSize=96]} locprov=0]
D/com.marianhello.bgloc.BackgroundGeolocationFacade: Received MSG_ON_LOCATION

Until I get this error:

E/Perf: Fail to get file list io.ionic.starter
E/Perf: getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
    Fail to get file list io.ionic.starter
    getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array

The this is the suscription it’s not working so I cant get the data, and I really want to get a background geolocation to make routes. There is another way to do this?. I am making a mistake?.


check if this could help you out…

If I were you, I would look at using the original plugin, which is available at Also, if you use startOnBoot, you will need to reconfigure your logic such that you start tracking in your app.module file.

I am not using startOnBoot but I may need it, how ever I change the login to app.component.ts, and I am using the home to start with a button passing throught a windows var declaracion. Actually I probably try 10 things more, and now I am usign cordova insted of capacitor. I think one of the faliurs may be with permits because i see in the application that have permits for use location while the app is on top, but i don’t know how to grant permits for use it always. And the getFolderSize error has to be something wiht the plugin because i don’t user this fuction for nothing. I forgot to metion that now I am using the url that send to an API for avoid the suscription, and the same, sends a couple, and then stop.
Daniel I can’t use a pay pluggin and is not my choice.