Image picker causes app crash

App crashes after opening the image library and after the camera also.

I tried to use imagepicker like this:

let result = await ImagePicker.launchCameraAsync({
  allowsEditing: true,
  aspect: [4, 3],
  quality: 0.4,
  base64: false,
  exif: false,
})

if (!result.cancelled) {
  this.props.navigation.navigate("UploadImage", { image: result })
}

it works perfectly in android. But in IOS it opens the image library and close the library and crash. whats wrong with this?

Hello! Can you send us the logs for the crash? https://docs.expo.io/versions/v18.0.0/guides/logging.html#view-logs-for-an-ios-simulator

My application crashes in the same way, on Android it works perfect, but on iOS, it opens the gallery and closes immediately, then the application is frozen.

“dependencies”: {
“@expo/vector-icons”: “^10.0.3”,
“expo”: “^33.0.0”,
“expo-asset”: “^6.0.0”,
“expo-barcode-scanner”: “~5.0.1”,
“expo-blur”: “~5.0.1”,
“expo-constants”: “~5.0.1”,
“expo-font”: “~5.0.1”,
“expo-image-picker”: “~5.0.2”,
“expo-linear-gradient”: “^5.0.1”,
“expo-mail-composer”: “~5.0.1”,
“expo-permissions”: “~5.0.1”,
“expo-secure-store”: “~5.0.1”,
“firebase”: “^7.2.1”,
“prop-types”: “^15.7.2”,
“react”: “16.8.3”,
“react-dom”: “^16.8.6”,
“react-native”: “https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz”,
“react-native-animated-hide-view”: “^1.0.0”,
“react-native-banner-carousel”: “^1.0.3”,
“react-native-elements”: “^1.2.6”,
“react-native-flip-card”: “^3.5.5”,
“react-native-gesture-handler”: “~1.2.1”,
“react-native-maps”: “~0.24.0”,
“react-native-modal”: “^11.1.0”,
“react-native-render-html”: “^4.1.2”,
“react-native-smtp-mailer”: “^1.2.1”,
“react-native-table-component”: “^1.2.0”,
“react-native-web”: “^0.11.4”,
“react-navigation”: “^3.11.0”,
“sharp”: “^0.22.1”
},
“devDependencies”: {
“babel-preset-expo”: “^5.1.1”
},

getPermissionAsync = async () => {
if (Constants.platform.ios) {
const { status } = await Permissions.askAsync(Permissions.CAMERA, Permissions.CAMERA_ROLL);
if (status !== “granted”) {
alert(
“Lo sentimos, necesitamos permisos de cámara para hacer que esto funcione!”
);
}
}
};

_pickImage = async type => {
let result = null;
if (type == “galeria”) {
result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.Images,
quality: 0.5,
base64: true
});
} else {
result = await ImagePicker.launchCameraAsync({
mediaTypes: ImagePicker.MediaTypeOptions.Images,
quality: 0.5,
base64: true
});
}

if (result != null && !result.cancelled) {
  let arr = this.state.imagenesAdjuntas;
  arr.push(result);
  this.setState({ imagenesAdjuntas: arr });
}

};

this is my code

Hi @eseg

As @jesse said, can you post the crash logs?
The link above no longer exists, but here is the equivalent link in the current website:

https://docs.expo.io/versions/latest/workflow/logging/#optional-manually-access-device-logs

Post the log output like this:

```
output
here
```

1 Like