plus.io.resolveLocalFileSystemURL(p, function(entry) {
//获取拍照后图片本地路径
var path = entry.toLocalURL();
//单位名称图片选择拍照时
if (selectNum == 0) {
//将单位名称图片DIV样式修改为拍照后的样式
var unit = document.getElementById("unit");
unit.setAttribute("class", "add-btn");
//创建包裹image以及a标签的Div
var addImgDiv = document.createElement("div");
//创建IMage标签
var unitImage = document.createElement("img");
//压缩文件
compress(unitImage, path);
//将图片路径放在隐藏的Input内
document.getElementById("unitImageUrl").value = p + ";";
document.getElementById("unit").insertBefore(addImgDiv, document
.getElementById("addUnitImage"));
addImgDiv.appendChild(unitImage);
imageCss(unitImage, selectNum);
//选择两张照片后将添加按钮隐藏
if (unitImageNum == 1) {
document.getElementById("addUnitImage").setAttribute("style",
"display: none;")
}
} else {
//检查过程选择拍照时
//将检查过程图片DIV样式修改为拍照后的样式
var check = document.getElementById("check");
check.setAttribute("class", "add-btn");
//创建包裹image以及a标签的Div
var addImgDiv = document.createElement("div");
var checkImage = document.createElement("img");
//压缩文件
compress(checkImage, path);
//将图片路径放在隐藏的Input内
document.getElementById("checkImageUrl").value += p + ";";
document.getElementById("check").insertBefore(addImgDiv, document
.getElementById("addCheckImage"));
addImgDiv.appendChild(checkImage);
imageCss(checkImage, selectNum);
//4张照片时隐藏添加按钮
if (checkImageNum == 3) {
document.getElementById("addCheckImage").setAttribute("style",
"display: none;")
}
}
})
}, function(error) {
var code = error.code; // 错误编码
var message = error.message; // 错误描述信息
alert(message);
}, {
index: 1
});```

- 发布:2021-03-20 13:47
- 更新:2021-04-01 06:58
- 阅读:7027
产品分类: HTML5+
HBuilderX版本号: 3.1.6
手机系统: Android
手机系统版本号: Android 10
手机厂商: 华为
手机机型: MRX-AN9
打包方式: 离线
示例代码:
操作步骤:
在小米、华为 安卓10 调用拍照提示授权出现此错误,授权后再次调用无反应,无报错,在安卓5.1的华为平板上则无此问题
在小米、华为 安卓10 调用拍照提示授权出现此错误,授权后再次调用无反应,无报错,在安卓5.1的华为平板上则无此问题
预期结果:
调用相机拍照
调用相机拍照
实际结果:
相机调用不成功
相机调用不成功
bug描述:
2021-03-20 13:35:04.851 19692-20121/c.a.p.b.d.d E/libc: Access denied finding property "vendor.camera.hal1.packagelist"
2021-03-20 13:35:04.862 19692-20121/c.a.p.b.d.d W/CameraBase: An error occurred while connecting to camera 0: Status(-8, EX_SERVICE_SPECIFIC): '1: validateClientPermissionsLocked:1026: Caller "c.a.p.b.d.d" (PID 10242, UID 19692) cannot open camera "0" without camera permission'
2021-03-20 13:35:04.863 19692-20121/c.a.p.b.d.d W/System.err: java.lang.RuntimeException: Fail to connect to camera service
2021-03-20 13:35:04.863 19692-20121/c.a.p.b.d.d W/System.err: at android.hardware.Camera.<init>(Camera.java:637)
2021-03-20 13:35:04.863 19692-20121/c.a.p.b.d.d W/System.err: at android.hardware.Camera.open(Camera.java:476)
2021-03-20 13:35:04.864 19692-20121/c.a.p.b.d.d W/System.err: at io.dcloud.js.camera.a.<init>(SourceFile:28)
2021-03-20 13:35:04.864 19692-20121/c.a.p.b.d.d W/System.err: at io.dcloud.js.camera.CameraFeatureImpl.execute(SourceFile:165)
2021-03-20 13:35:04.864 19692-20121/c.a.p.b.d.d W/System.err: at io.dcloud.h.b.a(SourceFile:137)
2021-03-20 13:35:04.864 19692-20121/c.a.p.b.d.d W/System.err: at io.dcloud.h.b.b(SourceFile:3)
2021-03-20 13:35:04.865 19692-20121/c.a.p.b.d.d W/System.err: at io.dcloud.h.b.processEvent(SourceFile:144)
2021-03-20 13:35:04.865 19692-20121/c.a.p.b.d.d W/System.err: at io.dcloud.f.b.c.dispatchEvent(SourceFile:22)
2021-03-20 13:35:04.865 19692-20121/c.a.p.b.d.d W/System.err: at io.dcloud.common.core.ui.l.processEvent(SourceFile:2)
2021-03-20 13:35:04.866 19692-20121/c.a.p.b.d.d W/System.err: at io.dcloud.common.core.ui.h.exec(SourceFile:10)
2021-03-20 13:35:04.866 19692-20121/c.a.p.b.d.d W/System.err: at io.dcloud.common.core.ui.h.prompt(SourceFile:18)
2021-03-20 13:35:04.866 19692-20121/c.a.p.b.d.d W/System.err: at io.dcloud.common.util.Birdge.prompt(SourceFile:1)
2021-03-20 13:35:04.867 19692-20121/c.a.p.b.d.d W/System.err: at android.os.MessageQueue.nativePollOnce(Native Method)
2021-03-20 13:35:04.867 19692-20121/c.a.p.b.d.d W/System.err: at android.os.MessageQueue.next(MessageQueue.java:336)
2021-03-20 13:35:04.867 19692-20121/c.a.p.b.d.d W/System.err: at android.os.Looper.loop(Looper.java:181)
2021-03-20 13:35:04.867 19692-20121/c.a.p.b.d.d W/System.err: at android.os.HandlerThread.run(HandlerThread.java:67)
2021-03-20 13:35:06.900 19692-19692/c.a.p.b.d.d E/Html5Plus-onResume: 1616218506900
3 个回复
2***@qq.com (作者)
W/CameraBase: An error occurred while connecting to camera 0: Status(-8, EX_SERVICE_SPECIFIC): '1: validateClientPermissionsLocked:1073: Caller "com.hola.cc" (PID 10171, UID 6939) cannot open camera "0" without camera permission'
W/System.err: java.lang.RuntimeException: Fail to connect to camera service
W/System.err: at android.hardware.Camera.<init>(Camera.java:573)
W/System.err: at android.hardware.Camera.open(Camera.java:418)
at io.dcloud.js.camera.a.<init>(SourceFile:28)
at io.dcloud.js.camera.CameraFeatureImpl.execute(SourceFile:165)
W/System.err: at io.dcloud.h.b.a(SourceFile:137)
at io.dcloud.h.b.b(SourceFile:3)
at io.dcloud.h.b.processEvent(SourceFile:144)
W/System.err: at io.dcloud.f.b.c.dispatchEvent(SourceFile:22)
at io.dcloud.common.core.ui.l.processEvent(SourceFile:2)
W/System.err: at io.dcloud.common.core.ui.h.exec(SourceFile:10)
at io.dcloud.common.core.ui.h.prompt(SourceFile:18)
at io.dcloud.common.util.Birdge.prompt(SourceFile:1)
W/System.err: at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:363)
at android.os.Looper.loop(Looper.java:176)
W/System.err: at android.os.HandlerThread.run(HandlerThread.java:67)
8***@qq.com
同问,小米8 安卓10
Access denied finding property "vendor.camera.hal1.packagelist"
cannot open camera "0" without camera permission'
W/System.err: java.lang.RuntimeException: Fail to connect to camera service
at android.hardware.Camera.<init>(Camera.java:637)
W/System.err: at android.hardware.Camera.open(Camera.java:476)
at io.dcloud.js.camera.g.<init>(:11)
at io.dcloud.js.camera.CameraFeatureImpl.execute(:17)
at io.dcloud.c.b.a(:90)
at io.dcloud.c.b.b(:3)
W/System.err: at io.dcloud.c.b.processEvent(:36)
at io.dcloud.a.b.j.dispatchEvent(:7)
at io.dcloud.common.core.ui.na.processEvent(:2)
at io.dcloud.common.core.ui.I.exec(:6)
W/System.err: at io.dcloud.common.core.ui.I.prompt(:11)
at io.dcloud.common.util.Birdge.prompt(:1)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:336)
W/System.err: at android.os.Looper.loop(Looper.java:181)
at android.os.HandlerThread.run(HandlerThread.java:67)
2***@qq.com (作者)
https://nativesupport.dcloud.net.cn/AppDocs/FAQ/android
离线打包Android 10上无法启动相机
在application节点下添加provider节点
${apk.applicationId}须替换成应用的包名。
小米8手机 安卓10 已解决问题,其他机型测试中....
w***@qq.com
谢谢您
2021-12-27 11:28