Reputation: 514
So I am trying to lauch the image library with a package called react-native-image-picker:
function launchLibrary(fun) {
let options = {
storageOptions: {
skipBackup: true,
path: 'images',
},
};
ImagePicker.launchImageLibrary(options, (response) => {
console.log('Response = ', response);
if (response.didCancel) {
console.log('User cancelled image picker');
} else if (response.error) {
console.log('ImagePicker Error: ', response.error);
} else if (response.customButton) {
console.log('User tapped custom button: ', response.customButton);
alert(response.customButton);
} else {
const source = { uri: response.uri };
console.log(source);
console.log('response', JSON.stringify(response));
fun(response);
}
});
};
Then when the function gets executed, I get the following response:
response {"errorMessage":"Activity error","errorCode":"others"}
What went wrong here?
Upvotes: 2
Views: 1229
Reputation: 31
The Google Play store no longer accepts builds targeting SDK < 30 so I managed to get it working with a different work around.
I updated react-native-image-picker
to version "^4.7.0" and the error went away, but note that launchImageLibrary
response may now contain an array of "assets" with image data, rather than including the image data right within the response object.
After updating, replacing response.uri
with response.assets[0].uri
did the trick for me.
Upvotes: 2
Reputation: 1317
I changed compileSdkVersion and targetSdkVersion from 30 to the 29 in
build.gradle
, depending on that answer:
https://github.com/react-native-image-picker/react-native-image-picker/issues/1600
compileSdkVersion = 29
targetSdkVersion = 29
and it worked normally after that.
Upvotes: 1