Expo android standalone app crashes when ask location permissions

i have problem with expo standalone app. the problem is with the ask permissions for locations. in the development mode, app asks for location permissions and works well. there is no bugs. after build the app using

expo build:android

it creates a android standalone app. and after installing that APK and try to access the same page that asks for location permissions, the app is crashed and restarted.

i added the permissions to app.json, but it not works. development mode, everything works fine.

(this is not the first time i build this application. Every time that i build this app it works. Suddenly the last time i built app has a crashing when ask permissions.but before it works.)

my app.json

"expo": {
    "name": "AS APP",
    "slug": "as_app",
    "privacy": "public",
    "sdkVersion": "32.0.0",
    "android": {
      "package": "com.xxx.asapp",
      "icon": "./assets/icon.png",
      "permissions": [
        "ACCESS_COARSE_LOCATION",
        "ACCESS_FINE_LOCATION",
        "CAMERA",
        "READ_EXTERNAL_STORAGE",
        "WRITE_EXTERNAL_STORAGE"
      ]
    },
    "platforms": [
      "ios",
      "android"
    ],
    "version": "1.10",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "cover",
      "backgroundColor": "#781D7D"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "supportsTablet": true,
      "bundleIdentifier": "com.xxx.asapp"
    },
    "description": "",
  }

ask for location permissions

let { status } = await Permissions.askAsync(Permissions.LOCATION);

        if(this.state.isMounted){

            if (status !== 'granted') {
                Alert.alert(
                    'Permissions',
                    'please grant your permissions to access your location!',
                    [
                      {text: 'Ok', onPress: () => {
                        const popAction = StackActions.pop({n: 1});
                        this.props.navigation.dispatch(popAction);
                      }}
                    ],
                    {cancelable: false},
                  );
            }else{
                let myLocation = await Location.getCurrentPositionAsync({
                    enableHighAccuracy: true,
                  });
                let direction = await Location.geocodeAsync(this.props.navigation.getParam('address',null));
                let myLocationAddress = await Location.reverseGeocodeAsync({
                    latitude: myLocation.coords.latitude,
                    longitude: myLocation.coords.longitude,
                });

                this.setState({
                    coordinates: [
                        {
                            latitude: myLocation.coords.latitude,
                            longitude: myLocation.coords.longitude
                        },
                        {
                            latitude: direction[0].latitude,
                            longitude: direction[0].longitude
                        },
                    ],
                    myAddress: myLocationAddress
                })
            }
        }

anyone can resolve this, please help me!

1 Like

Hey @vidu996,

I would open up the apk via Android Studio and then connect a device and leverage USB debugging. You can use adb logcat to access the device logs which usually contain more information than standard logs that will hopefully provide some insight into what may be causing the crash.

Cheers,
Adam

1 Like

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