NativeScript / NativeScript/plugins

Android 11, image picker doesn't have a selection after picking an image (from external storage)

未关闭
#551 6 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
TypeScript
星标
206
派生
123
平均合并
2 天 1 小时
30 天内合并 PR
1

描述

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.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 pickImage 入口点及其对 imagePicker.present() 的调用开始,在 Android 11 上从外部存储选择图像时复现空选择。将其与内部存储以及 image picker 2.0.2 和 3.0.0 中列出的权限配置进行比较。当选择外部图像能够产生与其他设备和存储位置上一样的非空选择时,即可视为完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
android, typescript
领域
mobile
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。