expo: [ expo-image-picker ] error (ERR_INVALID_MEDIA_TYPE) when 'allowsMultipleSelection' is set to true in Expo SDK 46, React 18
Summary
Expected Behavior:
I should be able to select multiple images with allowsMultipleSelection: true just fine ( no problem selecting one image at a time with allowsMultipleSelection: false )
Note: I do have allowsEditing: false.
What is actually happening:
I get this error: "code":"ERR_INVALID_MEDIA_TYPE","message":"Cannot handle 'public.jpeg' media type"
Not sure where ‘public.jpeg’ comes from as I am selecting, from my IPhone simulator (iOS 15.5), different types of pictures from different albums, and the error is the same for any picture I select.
I do not have this error when allowsMultipleSelection: false.
Context: React 18 Expo SDK 46 Expo-image-picker": “~13.3.1”, iOS 15.5 Iphone Simulator
Error Screenshot

Things I’ve tried
- I ran
expo doctorto check if dependencies problems but there are none. - Tried adding other options such as
base64: true, different qualities, etc - Note: when I opened the
node_modulesfolder, atexpo-image-picker/plugin/tsconfig.json, this line was erroring:"extends": "expo-module-scripts/tsconfig.base"as the file was not found. So I manually installedexpo-module-scriptsand now the error is gone, with the line"extends": "expo-module-scripts/tsconfig.plugin"generated instead. The above did not change anything though - I get the same error on selecting multiple images (ERR_INVALID_MEDIA_TYPE).
Packages: React 18 Expo SDK 46 Expo-image-picker": “~13.3.1”, Typescript: 4.8.2
"dependencies": {
"@apollo/client": "^3.6.9",
"@expo-google-fonts/lato": "^0.2.2",
"@expo/config-plugins": "^5.0.0",
"@expo/vector-icons": "13.0.0",
"@react-native-async-storage/async-storage": "~1.17.3",
"@react-native-community/datetimepicker": "6.2.0",
"@react-navigation/bottom-tabs": "6.0.5",
"@react-navigation/drawer": "6.4.3",
"@react-navigation/material-top-tabs": "6.2.2",
"@react-navigation/native": "6.0.2",
"@react-navigation/native-stack": "6.1.0",
"@reduxjs/toolkit": "1.8.5",
"apollo-link-prismic": "^1.1.1",
"array-move": "^4.0.0",
"axios": "^0.27.2",
"expo": "~46.0.13",
"expo-asset": "~8.6.1",
"expo-constants": "~13.2.3",
"expo-font": "~10.2.0",
"expo-image-loader": "^3.2.0",
"expo-image-manipulator": "~10.4.0",
"expo-image-picker": "~13.3.1",
"expo-linear-gradient": "~11.4.0",
"expo-linking": "~3.2.2",
"expo-media-library": "~14.2.0",
"expo-module-scripts": "^2.1.1",
"expo-splash-screen": "~0.16.1",
"expo-status-bar": "~1.4.0",
"expo-system-ui": "~1.3.0",
"expo-web-browser": "~11.0.0",
"formik": "^2.2.9",
"fuse.js": "^6.6.2",
"lodash.debounce": "^4.0.8",
"moment": "^2.29.4",
"native-base": "^3.4.16",
"react": "18.0.0",
"react-devtools": "4.25.0",
"react-devtools-core": "4.25.0",
"react-dom": "18.0.0",
"react-native": "0.69.6",
"react-native-collapsible": "^1.6.0",
"react-native-image-zoom-viewer": "^3.0.1",
"react-native-pager-view": "5.4.24",
"react-native-reanimated": "~2.9.1",
"react-native-render-html": "^6.3.4",
"react-native-safe-area-context": "4.3.1",
"react-native-screens": "~3.15.0",
"react-native-svg": "12.3.0",
"react-native-tab-view": "3.1.1",
"react-native-webview": "11.23.0",
"react-redux": "8.0.2",
"redux-devtools-extension": "2.13.9",
"redux-saga": "1.1.3",
"remote-redux-devtools": "0.5.16",
"typesafe-actions": "5.1.0"
},
"devDependencies": {
"@babel/core": "7.19.3",
"@types/react": "~18.0.21",
"@types/react-native": "^0.70.4",
"react-test-renderer": "18.0.0",
"typescript": "4.8.2"
},
What platform(s) does this occur on?
iOS
Environment
expo-env-info 1.0.5 environment info:
System:
OS: macOS 12.6
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 18.7.0 - ~/.nvm/versions/node/v18.7.0/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v18.7.0/bin/yarn
npm: 8.15.0 - ~/.nvm/versions/node/v18.7.0/bin/npm
Watchman: 2022.07.04.00 - /opt/homebrew/bin/watchman
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
IDEs:
Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
npmPackages:
expo: ~46.0.13 => 46.0.13
react: 18.0.0 => 18.0.0
react-dom: 18.0.0 => 18.0.0
react-native: 0.69.6 => 0.69.6
npmGlobalPackages:
expo-cli: 6.0.6
Expo Workflow: managed
Minimal reproducible example
import React from 'react'
import { launchImageLibraryAsync, MediaTypeOptions } from 'expo-image-picker'
import { View, Button } from 'react-native'
export function GalleryImagesForm(props) {
const pickImages = async () => {
// No permissions request is necessary for launching the image library
try {
let result = await launchImageLibraryAsync({
mediaTypes: MediaTypeOptions.All,
allowsMultipleSelection: true,
})
console.log(result)
} catch (error) {
console.log(error)
}
}
return (
<View>
<Button title="Pick an image from camera roll" onPress={pickImages} />
</View>
)
}
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 16
- Comments: 18 (3 by maintainers)
I found a post somewhere today saying that there’s a known issue with the “red flowers” stock image on the iOS simulator, and that does seem to be the case for me. In a custom dev client on the sim, I get an error when picking the red flowers image in a multi select picker, but any of the other images work fine.
If possible, can you highlight this comment?
To save anyone else facing this issue some time, based on the feedback I’ve read this looks like it is an m1-specific issue. Here’s a few solutions that will probably work for you too.
(All of these config options are set when calling the
launchImageLibraryAsyncfunction in its arguments)allowsEditingto true - Fixed the issue for meallowsMultipleSelectionto truemediaTypestomediaTypes: ImagePicker.MediaTypeOptions.ImagesI’d recommend trying this then removing the props to see when it breaks again:
this is an m1 simulator specific issue: https://github.com/expo/expo/issues/19990#issuecomment-1315087158
currently we need to run expo go with rosetta (due to a number of libraries in sdk 46, still supported in expo go, which don’t support m1 natively), and that may be the cause of this. in sdk 48 we will likely be able to run it natively on m1.
4 users are experiencing this error on our production build, running iOS 17.3.1 on various iPhone models. One user reported they took the images using the device camera.
expo-image-picker@npm:14.7.1 [502b1] (via npm:~14.7.1 [502b1])Don’t know if that helps, but for me it looked like the problem is specific to the default images that are saved on the simulator, I was having the same problem and then downloaded a few more pictures from google and those new ones worked.
Same issue on iOS simulator.
I am experiencing this error on v14.7.1 on a physical device (iOS) running Expo dev client.
[Error: Failed to read picked image → Caused by: Cannot load representation of type public.jpeg]Running into the same issue on simulator, with any image
Thanks for opening this issue @nathalia-rus.
I tried reproducing it, and it seems the error only occurs when running the app using Expo Go in development mode. Running the app using Expo go and production mode, that is using
npx expo start --no-dev --minify, seems to work as expected. Also, testing on a real iOS device,allowsMultipleSelection: true,works as expected.So I’m currently unsure if this is an iOS simulator + dev mode related. I’ll get back to you after investigating this further.