Reputation: 248
I have used react-native-image-picker in my project. It is working fine in android phones that are less than Android 11 but App crashes in android 11 without showing logcat. launchImageLibrary is working as expected but launchCamera is crashing app. I have added the permissions also in android manifest file i.e
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
but still no luck.
Upvotes: 1
Views: 2698
Reputation: 248
I fixed it by adding await in launchImageLibrary/launchCamera I have added the code for your reference
const openCamera = async () => {
let options = { quality: 5, maxWidth: 500, maxHeight: 500, includeBase64: true, mediaType: 'photo', noData: true, };
await launchCamera(options, response => {
if (response.didCancel) {
console.log('Cancelled');
} else if (response.error) {
console.log('Error', response.errorMessage);
} else {
console.log(response);
setFilePath(response.uri);
setBase64('data:image/png;base64,' + response.base64); } });
};
Upvotes: 1
Reputation: 1
try to remove
<uses-permission android:name="android.permission.CAMERA" />
Image-picker don't need permission
Upvotes: 0