NativeScript / NativeScript/plugins
Android 11, image picker doesn't have a selection after picking an image (from external storage)
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 206
- Forks
- 123
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 1
Description
The following error only seems to happen on Android 11. After imagepicker.present() and selecting an image from external storage the selection is empty. When picking an image from internal storage everything works as expected.
Setup and code:
I have tried with the following confuriations:
Image picker 2.0.2, and 3.0.0
/// 1
android.permission.READ_EXTERNAL_STORAGE
android.permission.MANAGE_EXTERNAL_STORAGE (and manually giving the app /// full permission) "
requestLegacyExternalStorage="true"
///
//// 2
android.permission.READ_EXTERNAL_STORAGE
requestLegacyExternalStorage="true"
////
/// 3
android.permission.READ_MEDIA_IMAGES
android.permission.READ_MEDIA_VIDEO
///
And
public pickImage(options?: OptionsCommon, hostView?: View): Promise {
// Create image picker
const p = imagePicker.create({
mode: 'single',
maximumNumberOfSelection: 1,
mediaType: ImagePickerMediaType.Image,
}, hostView); // Hostview is important to render on top of a modal
// Authorization is required (allow app to ...)
return p.authorize()
.then(() => p.present()) // Present the imagepicker
.then((selection) => {
console.log(selection);
const imagePickerSelection = selection[0];
return Promise.all([Promise.resolve(imagePickerSelection.asset), isIOS ?
ImageSource.fromAsset(imagePickerSelection.asset) : null]);
})
.then((f: [ImageAsset, ImageSource]) => this.processPickedImage(f, options))
.catch(reason => Promise.reject(this.processPickingFailure(reason)));
}
on any other device then android 11, or when selecting from internal storage the console.log() prints the selection as expected.
When picking from external storage, and only on android 11 there is no selection.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the pickImage entry point and its imagePicker.present() call, reproducing the empty selection on Android 11 when choosing an image from external storage. Compare this with internal storage and the listed permission configurations on image picker 2.0.2 and 3.0.0. Done means selecting an external image produces a populated selection like other devices and storage locations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, typescript
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100