I started cordova Android programming 2 month back. Everything was fine mainly camera that is not working now. But last week some how my project directory got deleted and I reinstall all plugin of cordova and complied project but now its showing error 'illegal argument exception' on camera click surprising thing is i didn't change single line of code and it's also working properly on other developer machine.
我在2个月前开始使用cordova Android编程。一切都很好,主要是现在没有工作的相机。但上周一些我的项目目录如何删除,我重新安装所有插件的cordova和编译项目,但现在它显示错误'非法参数异常'在相机上点击令人惊讶的事情是我没有更改单行代码,它也正常工作在其他开发者机器上。
cordova plugin add cordova-plugin-camera command used from camera plugin installation.
cordova插件添加了使用相机插件安装的cordova-plugin-camera命令。
camera_app.js file
camera_app.js文件
var pictureSource; // picture source
var destinationType; // sets the format of returned value
// Wait for device API libraries to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// device APIs are available
//
function onDeviceReady() {
pictureSource = navigator.camera.PictureSourceType;
destinationType = navigator.camera.DestinationType;
}
// Called when a photo is successfully retrieved
//
function onPhotoURISuccess(imageURI) {
// largeImage.src = imageURI;
console.log(imageURI);
console.log(document_type);
}
function getPhoto(docType) {
// Retrieve image file location from specified source
document_type = docType
$('.docError').hide();
navigator.camera.getPicture(onPhotoURISuccess, onFail, {
quality: 50,
destinationType: destinationType.FILE_URI
});
}
$('#file1').click(function() {
console.log('On camera click');
getPhoto("addressProof");
});
I tried to debug code finally found it's due to provider path- java.lang.IllegalArgumentException: Missing android.support.FILE_PROVIDER_PATHS meta-data
我试图调试代码终于发现它是由于提供者路径 - java.lang.IllegalArgumentException:缺少android.support.FILE_PROVIDER_PATHS元数据
but I have already added provider path meta data in Android xml file, as its automatically gets added when you add cordova plugin.
但是我已经在Android xml文件中添加了提供者路径元数据,因为当你添加cordova插件时会自动添加它。
<provider android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true" android:name="android.support.v4.content.FileProvider">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths" />
</provider>
cordova plugin -
cordova插件 -
cordova-plugin-app-version 0.1.9 "AppVersion" cordova-plugin-camera 2.4.1 "Camera" cordova-plugin-compat 1.1.0 "Compat" cordova-plugin-whitelist 1.3.2 "Whitelist" cordova-sqlite-storage 1.4.9 "Cordova sqlite storage plugin" ionic-plugin-keyboard 2.2.1 "Keyboard"
cordova-plugin-app-version 0.1.9“AppVersion”cordova-plugin-camera 2.4.1“Camera”cordova-plugin-compat 1.1.0“Compat”cordova-plugin-whitelist 1.3.2“Whitelist”cordova-sqlite-存储1.4.9“Cordova sqlite存储插件”ionic-plugin-keyboard 2.2.1“键盘”
cordova platform-
科尔多瓦平台 -
Installed platforms: android 6.2.3 Available platforms: blackberry10 ~3.8.0 (deprecated) browser ~4.1.0 webos ~3.7.0 windows ~5.0.0
安装平台:android 6.2.3可用平台:blackberry10~3.8.0(已弃用)浏览器~4.1.0 webos~3.7.0 windows~5.0.0
NPM version- { npm: '3.10.3', ares: '1.10.1-DEV', http_parser: '2.7.0', icu: '57.1', modules: '48', node: '6.4.0', openssl: '1.0.2h', uv: '1.9.1', v8: '5.0.71.60', zlib: '1.2.8' }
NPM版本 - {npm:'3.10.3',ares:'1.10.1-DEV',http_parser:'2.7.0',icu:'57 .1',模块:'48',节点:'6.4.0', openssl:'1.0.2h',uv:'1.9.1',v8:'5.0.71.60',zlib:'1.2.8'}
2 个解决方案
#1
8
It was very simple and basic. Just add your file provider below to your cordova launcher activity. In my case I was having some custom activity and by mistake provider was added at bottom of all activity and my guess is cordova not able to read that provider that's why it was giving java.lang.IllegalArgumentException: Missing android.support.FILE_PROVIDER_PATHS meta-data
这非常简单和基本。只需将您的文件提供商添加到您的cordova启动器活动中。在我的情况下,我有一些自定义活动,并错误提供者被添加到所有活动的底部,我的猜测是cordova无法读取该提供程序,这就是为什么它给java.lang.IllegalArgumentException:缺少android.support.FILE_PROVIDER_PATHS元 - 数据
#2
0
I had a similar problem today. Tried everything (reinstall plugin, reinstall plugin from source, reinstall older version of plugin) but nothing seemed to help. Don't know why but after - killing the emulator - > cordova clean android - > cordova platform remove android - > cordova platform add android - > cordova build android - connecting my device - > cordova run android it works again as before :-) I still don't know why. Try it on your own risk. Maybe it helps.
我今天遇到了类似的问题。尝试了一切(重新安装插件,从源重新安装插件,重新安装旧版本的插件)但似乎没有任何帮助。不知道为什么但是之后 - 杀死模拟器 - > cordova清除android - > cordova平台删除android - > cordova平台添加android - > cordova构建android - 连接我的设备 - > cordova运行android它再次像以前一样工作:-)我还是不知道为什么。尝试自己承担风险。也许有帮助。
#1
8
It was very simple and basic. Just add your file provider below to your cordova launcher activity. In my case I was having some custom activity and by mistake provider was added at bottom of all activity and my guess is cordova not able to read that provider that's why it was giving java.lang.IllegalArgumentException: Missing android.support.FILE_PROVIDER_PATHS meta-data
这非常简单和基本。只需将您的文件提供商添加到您的cordova启动器活动中。在我的情况下,我有一些自定义活动,并错误提供者被添加到所有活动的底部,我的猜测是cordova无法读取该提供程序,这就是为什么它给java.lang.IllegalArgumentException:缺少android.support.FILE_PROVIDER_PATHS元 - 数据
#2
0
I had a similar problem today. Tried everything (reinstall plugin, reinstall plugin from source, reinstall older version of plugin) but nothing seemed to help. Don't know why but after - killing the emulator - > cordova clean android - > cordova platform remove android - > cordova platform add android - > cordova build android - connecting my device - > cordova run android it works again as before :-) I still don't know why. Try it on your own risk. Maybe it helps.
我今天遇到了类似的问题。尝试了一切(重新安装插件,从源重新安装插件,重新安装旧版本的插件)但似乎没有任何帮助。不知道为什么但是之后 - 杀死模拟器 - > cordova清除android - > cordova平台删除android - > cordova平台添加android - > cordova构建android - 连接我的设备 - > cordova运行android它再次像以前一样工作:-)我还是不知道为什么。尝试自己承担风险。也许有帮助。