uni-app uni.chooseMedia
uni-app uni.chooseMedia
示例代码:
uni.chooseMedia({
count :1,
mediaType: ['image'],
sizeType: ['compressed'],
success: function(res) {
for (let file of res.tempFiles) {
fileList.push({
local: true,
url: file.tempFilePath,
thumbTempFilePath: file.thumbTempFilePath ?? file.tempFilePath,
type: file.fileType,
fileType: file.fileType.includes('image') ? 0 : 1
});
}
resolve(fileList);
},
fail: function(e) {
reject(e);
}
});
操作步骤:
未授权的情况下, uni.chooseMedia 调用
预期结果:
不能崩溃
实际结果:
崩溃
bug描述:
java.lang.IllegalArgumentException: The storage permission application is abnormal. If you have adapted the scope storage, please register the <meta-data android:name="ScopedStorage" android:value="true" /> attribute in the AndroidManifest.xml file. If there is no adaptation scope storage, please use android.permission.MANAGE_EXTERNAL_STORAGE to apply for permission
at com.hjq.permissions.PermissionChecker.checkStoragePermission(PermissionChecker.java:250)
at com.hjq.permissions.XXPermissions.request(XXPermissions.java:184)
at io.dcloud.uts.UTSAndroid.requestSystemPermission(UTSAndroid.kt:543)
at io.dcloud.uts.UTSAndroid.requestSystemPermission$default(UTSAndroid.kt:504)
at uts.sdk.modules.DCloudUniChooseMedia.IndexKt$chooseMediaAll$1.invoke(index.kt:118)
at uts.sdk.modules.DCloudUniChooseMedia.IndexKt$chooseMediaAll$1.invoke(index.kt:113)
at uts.sdk.modules.DCloudUniChooseMedia.IndexKt.onMediaTypeSelect(index.kt:231)
at uts.sdk.modules.DCloudUniChooseMedia.IndexKt$uniChooseMedia$1.invoke(index.kt:216)
at uts.sdk.modules.DCloudUniChooseMedia.IndexKt$uniChooseMedia$1.invoke(index.kt:215)
at uts.sdk.modules.DCloudUniPrompt.ItemClickListener.onClick(index.kt:805)
at android.view.View.performClick(View.java:6675)
at android.view.View.performClickInternal(View.java:6647)
at android.view.View.access$3100(View.java:791)
at android.view.View$PerformClick.run(View.java:26339)
at android.os.Handler.handleCallback(Handler.java:907)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7779)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:990)
| 信息类型 | 信息 |
|---|---|
| 产品分类 | uniapp/App |
| PC开发环境 | Windows |
| PC开发环境版本号 | 10.0.26100 版本 26100 |
| HBuilderX类型 | 正式 |
| HBuilderX版本号 | 4.66 |
| 手机系统 | Android |
| 手机系统版本号 | Android 8.0 |
| 手机厂商 | 华为 |
| 手机机型 | MHA-AL00 |
| 页面类型 | vue |
| vue版本 | vue3 |
| 打包方式 | 云端 |
| 项目创建方式 | HBuilderX |
更多关于uni-app uni.chooseMedia的实战教程也可以访问 https://www.itying.com/category-93-b0.html
1 回复
更多关于uni-app uni.chooseMedia的实战教程也可以访问 https://www.itying.com/category-93-b0.html
根据错误日志,这是Android权限配置问题导致的崩溃。需要在AndroidManifest.xml中添加ScopedStorage配置:
<application>
<meta-data
android:name="ScopedStorage"
android:value="true" />
</application>

