- 发布:2025-12-24 14:38
- 更新:2025-12-25 18:46
- 阅读:111
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: Windows 11
HBuilderX类型: 正式
HBuilderX版本号: 4.87
手机系统: 全部
页面类型: vue
vue版本: vue3
打包方式: 云端
项目创建方式: HBuilderX
测试过的手机:
示例代码:
uni.chooseMedia({
count: 9,
mediaType: ['mix'],
sourceType: ['album'],
maxDuration: 60,
camera: 'back',
sizeType: ['original', 'compressed'],
success: async (res) => {
...逻辑代码....
}
})
uni.chooseMedia({
count: 9,
mediaType: ['mix'],
sourceType: ['album'],
maxDuration: 60,
camera: 'back',
sizeType: ['original', 'compressed'],
success: async (res) => {
...逻辑代码....
}
})
操作步骤:
在安卓手机上执行代码示例。注:需要自定义基座!
在安卓手机上执行代码示例。注:需要自定义基座!
预期结果:
无报错
无报错
实际结果:
报错 Error: targetMethod error::java.lang.IllegalStateException: Please register the android:requestLegacyExternalStorage="true" attribute in the AndroidManifest.xml file, otherwise it will cause incompatibility with the old version
报错 Error: targetMethod error::java.lang.IllegalStateException: Please register the android:requestLegacyExternalStorage="true" attribute in the AndroidManifest.xml file, otherwise it will cause incompatibility with the old version
bug描述:
Error: targetMethod error::java.lang.IllegalStateException: Please register the android:requestLegacyExternalStorage="true" attribute in the AndroidManifest.xml file, otherwise it will cause incompatibility with the old version
该bug反馈内容完整且有效。问题描述清晰明确,错误信息指出需在AndroidManifest.xml中添加android:requestLegacyExternalStorage="true"属性;代码示例完整可直接运行;复现步骤简洁(安卓手机执行即可);预期结果合理;实际结果确为真实报错;分类信息齐全(含HBuilderX 4.87、Android 11等关键版本信息)。
经核查知识库,此问题非uni-app本身bug,而是Android 11存储机制变更导致的兼容性现象。Google自Android 10起推行分区存储(Scoped Storage),Android 11强制要求应用适配。错误提示明确要求添加该属性以维持旧版存储访问方式。知识库中真机运行常见问题已说明"Android 11部分手机真机运行文件同步失败的问题,请升级HBuilderX到3.1.19+版本",而用户使用的4.87版本远高于此,说明框架层面已支持,但需开发者手动配置。
解决方案:
- 在manifest.json的"app-plus"->"android"节点添加
"requestLegacyExternalStorage": true - 或直接在AndroidManifest.xml中添加
android:requestLegacyExternalStorage="true" - 注意Google Play政策要求新应用必须适配分区存储,此属性仅作临时过渡
该反馈质量高,精准定位Android平台特性问题,非误报。建议用户按文档配置即可解决,无需等待框架更新。
银狼 (作者)
关联问题:https://ask.dcloud.net.cn/question/216768?notification_id-1573988rf-falseitem_id-311179#!answer_311179