我有一个Cordova应用程序(在Android上运行)我已经实现了Cordova Camera插件,我有一个简单的点击'调用以下代码然后弹出消息的事件:
"允许MyHQAPP访问您设备上的照片,媒体和文件?"
我点击“允许'并立即关闭应用程序?我检查了ADB错误日志,可以看到以下错误
任何人都可以提出问题所在 - 请注意我正在使用相机功能的ngCordova插件 http://ngcordova.com/docs/plugins/camera/
08-07 11:33:19.712 14954 15032 E PluginManager: Uncaught exception from plugin
08-07 11:33:19.712 14954 15032 E PluginManager: android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/com.mytechnologies.myapp_2017/cache/.Pic.jpg exposed beyond app through ClipData.Item.getUri()
08-07 11:33:19.712 14954 15032 E PluginManager: at android.os.StrictMode.onFileUriExposed(StrictMode.java:1799)
08-07 11:33:19.712 14954 15032 E PluginManager: at android.net.Uri.checkFileUriExposed(Uri.java:2346)
08-07 11:33:19.712 14954 15032 E PluginManager: at android.content.ClipData.prepareToLeaveProcess(ClipData.java:845)
08-07 11:33:19.712 14954 15032 E PluginManager: at android.content.Intent.prepareToLeaveProcess(Intent.java:8941)
08-07 11:33:19.712 14954 15032 E PluginManager: at android.content.Intent.prepareToLeaveProcess(Intent.java:8926)
08-07 11:33:19.712 14954 15032 E PluginManager: at android.app.Instrumentation.execStartActivity(Instrumentation.java:1690)
08-07 11:33:19.712 14954 15032 E PluginManager: at android.app.Activity.startActivityForResult(Activity.java:4291)
08-07 11:33:19.712 14954 15032 E PluginManager: at org.apache.cordova.CordovaActivity.startActivityForResult(CordovaActivity.java:342)
08-07 11:33:19.712 14954 15032 E PluginManager: at android.app.Activity.startActivityForResult(Activity.java:4249)
08-07 11:33:19.712 14954 15032 E PluginManager: at org.apache.cordova.CordovaInterfaceImpl.startActivityForResult(CordovaInterfaceImpl.java:66)
08-07 11:33:19.712 14954 15032 E PluginManager: at org.apache.cordova.camera.CameraLauncher.takePicture(CameraLauncher.java:259)
08-07 11:33:19.712 14954 15032 E PluginManager: at org.apache.cordova.camera.CameraLauncher.callTakePicture(CameraLauncher.java:233)
08-07 11:33:19.712 14954 15032 E PluginManager: at org.apache.cordova.camera.CameraLauncher.execute(CameraLauncher.java:168)
08-07 11:33:19.712 14954 15032 E PluginManager: at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:98)
08-07 11:33:19.712 14954 15032 E PluginManager: at org.apache.cordova.PluginManager.exec(PluginManager.java:132)
08-07 11:33:19.712 14954 15032 E PluginManager: at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:57)
08-07 11:33:19.712 14954 15032 E PluginManager: at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41)
08-07 11:33:19.712 14954 15032 E PluginManager: at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
08-07 11:33:19.712 14954 15032 E PluginManager: at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:7)
08-07 11:33:19.712 14954 15032 E PluginManager: at android.os.Handler.dispatchMessage(Handler.java:102)
08-07 11:33:19.712 14954 15032 E PluginManager: at android.os.Looper.loop(Looper.java:154)
08-07 11:33:19.712 14954 15032 E PluginManager: at android.os.HandlerThread.run(HandlerThread.java:61)
08-07 11:33:21.836 13427 13427 E SimcardDataModel: provide unsupported slot id 0
在我的js控制器中
$scope.uploadFromCamera = function () {
console.log('Upload from Camera');
var options = {
quality: 75,
destinationType: Camera.DestinationType.DATA_URL,
sourceType: Camera.PictureSourceType.CAMERA,
allowEdit: true,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 300,
targetHeight: 300,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false
};
$cordovaCamera.getPicture(options).then(function (imageData) {
$scope.imgURI = "data:image/jpeg;base64," + imageData;
console.log($scope.imgURI);
console.log($scope);
}, function (err) {
// An error occured. Show a message to the user
});
}
// Cordova信息 节点版本:v6.10.3 Cordova版本:6.0.0
Config.xml文件:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.mytechnologies.fakename_2017" versionCode='20002' version="2.0.2" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>MyAPP</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev@cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<engine name="android" spec="~5.2.2" />
<icon src="res/icon.png" />
</widget>
插件:
科尔多瓦-插件相机,科尔多瓦-插件-COMPAT,科尔多瓦-插件白名单
cordova-plugin-camera 2.1.1&#34;相机&#34; cordova-plugin-whitelist 1.3.0&#34; Whitelist&#34;
答案 0 :(得分:4)
尝试将cordova-plugin-camera的版本更改为2.4.1