[Resolved] Camera won't start on standalone android app

#1

Hi guys.

For last few months I’ve been working on my second expo app, and after some minor problems I’ve came to a moment when I’ve published app for closed test, and everything works quite fine - exept for camera and camera roll. It works perfectly inside expo, but when I’ve published standalone apps it did not work at any of android devices I’ve tested it on.

Inside app.json I have:

{
    ...,
    "expo": {
        ...,
        "permissions": [ "CAMERA", "VIBRATE" ]
    }
}

and my picking image code:


_pickImage = async ( type ) => {
	
	let isCamAvaliable = await Permissions.getAsync( Permissions.CAMERA );

	if ( isCamAvaliable.status !== 'granted' ) {
		
		let askCamAvability = await Permissions.askAsync( Permissions.CAMERA );
		
		if ( askCamAvability.status !== 'granted' )
			return false;

	}

	let isRollAvaliable = await Permissions.getAsync( Permissions.CAMERA_ROLL );

	if ( isRollAvaliable.status !== 'granted' ) {
	
		let askRollAvability = await Permissions.askAsync( Permissions.CAMERA_ROLL );
		
		if ( askRollAvability.status !== 'granted' )
			return false;

	}

	
	this.setState({ 
		...this.state,
		selecting: true
    });
    
    let result;

    const captureOptions = {
		allowsEditing: false,
		mediaTypes: ImagePicker.MediaTypeOptions.Images,
        base64: false
	};

    if ( type == 'gallery' )
        result = await ImagePicker.launchImageLibraryAsync( captureOptions );
    else
        result = await ImagePicker.launchCameraAsync( captureOptions );

	let newState = { 
		...this.state,
		selecting: false
	};

	if ( !result.cancelled )
		newState = { 
			...newState,
			image: result.uri,
			width: result.width, 
			height: result.height, 
		};
    
    this.setState( newState );
	
};

any ideas why it is nor working in standalone app? or maybe hints how to debug it there?

#2

ok, thanks to @aalices I’ve managed to solve this, it was enough to add two additional permissions in app.json: READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE.

1 Like
closed #3

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