After sdk33 update Location.startLocationUpdatesAsync crash every second open application on standalone

If a close application then try to reopen without no error it crashes and closes immediately .

But only android devices error. On standalone version after crash it says.

java.lang.NullPointerException: Attempt to invoke interface method ‘java.util.Map org.unimodules.b.j.d.getOptions()’ on a null object reference
at expo.modules.location.taskConsumers.LocationTaskConsumer.shouldReportDeferredLocations(LocationTaskConsumer.java:316)
at expo.modules.location.taskConsumers.LocationTaskConsumer.maybeReportDeferredLocations(LocationTaskConsumer.java:273)
at expo.modules.location.taskConsumers.LocationTaskConsumer.access$100(LocationTaskConsumer.java:44)
at expo.modules.location.taskConsumers.LocationTaskConsumer$1.onComplete(LocationTaskConsumer.java:123)
at com.google.android.gms.e.s.run(Unknown Source:4)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6810)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)

Hey @mitu,

Can you provide a reproducible case of this? Ideally, create a fresh app and just implement the Location logic with no additional, unneeded code. That way we can debug it on our end.

Cheers,
Adam

Hi Adam
Yes ofcourse after sdk update we saw this on production. I just tried to remove unused.

import React from ‘react’;
import * as Location from ‘expo-location’;
import {
Text,
View,
Image,
TouchableOpacity,
Alert,
AsyncStorage,
Platform,
ActivityIndicator,
FlatList, TextInput, ScrollView, KeyboardAvoidingView, NetInfo, AppState, Keyboard, Dimensions, TouchableHighlight
} from ‘react-native’;

TaskManager.defineTask(‘LOCATION_WATCH’, ({data, error}) => {
if (error) {
console.log(error);
return;
}
if (data) {
const {locations} = data;
//console.log(locations);
//console.log(new Date().toGMTString())
}
});

export default class Home extends React.Component {

checkGPSStatus = async () => {

    // console.log('status kontrol');
    try {
        const gpsStatus = await Location.getProviderStatusAsync();
        if (typeof gpsStatus !== 'undefined' && gpsStatus.gpsAvailable !== 'undefined' && gpsStatus.gpsAvailable === false) {
            Toast.show(I18n.t('gps_is_off'), customConstants.TOAST_CONFIG);
            return false;
        } else {
            return true;
        }
    } catch (e) {
        console.log(e);
    }

}

watchBackgroundLocation = async () => {
    try {
        let {status} = await Permissions.askAsync(Permissions.LOCATION);
        if (status === 'granted') {
            this.startBackgroundWatch();
        } else {
            if (typeof global.services !== 'undefined' && global.services.length > 0 && global.inWizard === false && profile._lng == 0 && profile._lat == 0) {
                this.showLocationAlert();
            }
        }
    } catch (e) {
        Toast.show(I18n.t('location_access_not_permitted'), customConstants.TOAST_CONFIG);
    }
}

startBackgroundWatch = async () => {

// customConstants.GEOLOCATION_BG_OPTIONS: {accuracy: Location.Accuracy.Balanced, timeInterval: 600000, distanceInterval: 200},

    try {
        if (Platform.OS === 'ios') { // we put after many tries our production to watch only on ios then problem solved
            Location.startLocationUpdatesAsync('LOCATION_WATCH', customConstants.GEOLOCATION_BG_OPTIONS, this.locationChanged);
        }
    } catch (e) {
        console.log(e);
    }

}

componentDidMount() {

    this.checkGPSStatus();
    this.watchBackgroundLocation();

}

By the way it starts once nothing happens but when i close then i tried to re open application it crash in miliseconds. I mean application cant load even expo sdk.

So i couldn’t get any debug outputs.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.