Closed cfjedimaster closed 6 years ago
Same error after update to latest version 4.1.0 of camera plugin, NS 5.
same issue with angular6, ns5 and tns-android 5
Same issue with angular 7 ns 5 and version 4.1.0
Same here angular 7 ns 5 version 4.1, although on the emulator the gallery opens as expected.
Same issue
The issue is fixed in 4.1.1 of nativescript-camera. Please update to 4.1.1 of the plugin.
I'm still getting an error even though I have upgraded the plugin to 4.1.1
JS: Error -> Error: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)' on a null object reference
JS: android.support.v4.content.FileProvider.parsePathStrategy(FileProvider.java:605)
JS: android.support.v4.content.FileProvider.getPathStrategy(FileProvider.java:579)
JS: android.support.v4.content.FileProvider.getUriForFile(FileProvider.java:417)
JS: com.tns.Runtime.callJSMethodNative(Native Method)
JS: com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1116)
JS: com.tns.Runtime.callJSMethodImpl(Runtime.java:996)
JS: com.tns.Runtime.callJSMethod(Runtime.java:983)
JS: com.tns.Runtime.callJSMethod(Runtime.java:967)
JS: com.tns.Runtime.callJSMethod(Runtime.java:959)
JS: com.tns.gen.android.content.DialogInterface_OnClickListener.onClick(DialogInterface_OnClickListener.java:17)
JS: com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertControlle...
Which platform(s) does your issue occur on? Android 8.1.0. Plum Compass 2 Z518
Please, provide the following version numbers that your issue occurs with:
✔ Getting NativeScript components versions information...
⚠ Update available for component nativescript. Your current version is 5.0.0 and the latest available version is 5.1.1.
⚠ Update available for component tns-core-modules. Your current version is 5.0.2 and the latest available version is 5.1.2.
⚠ Update available for component tns-android. Your current version is 5.0.0 and the latest available version is 5.1.0.
⚠ Update available for component tns-ios. Your current version is 5.0.0 and the latest available version is 5.1.1.
Code used:
function onAddItem() {
binder = database.session.currentBinder;
console.log("ADDING AN ITEM")
try {
if (canUpload(binder)) {
console.log(camera.isAvailable());
camera.requestPermissions().then(
function success() {
// permission request accepted or already granted
// ... call camera.takePicture here ...
console.log("DOING THE THING")
dialogs.action({
cancelButtonText: "Cancel",
actions: ["Take a photo", "Choose from camera roll"]
}).then(function(result) {
if (result == "Take a photo") {
takePicture();
} else if (result == "Choose from camera roll") {
pickFiles();
}
});
},
function failure() {
console.log("NOT TAKING PICTURE")
// permission request rejected
// ... tell the user ...
}
);
}
} catch (e) {
console.log(e.toString());
}
}
function takePicture() {
console.log("TAKING A PICTURE");
try {
camera.takePicture()
.then(function(imageAsset) {
var image = new imageModule.Image();
//image.src = imageAsset;
var imageSource = new imageModule.ImageSource();
// convert ImageAsset to ImageSource
imageSource.fromAsset(imageAsset).then(res => {
myImageSource = res;
var base64 = myImageSource.toBase64String("jpeg", 100);
image.name = "image" + new Date().getTime() + ".jpeg"
image.src = "data:image/png;base64," + base64;
upload(image, image.src);
})
}).catch(function(e) {
console.log("Error -> " + e.toString());
});
} catch(e){
console.log(e.toString())
}
}
package.json:
"dependencies": { "base-64": "^0.1.0", "nativescript-background-http": "^3.3.1", "nativescript-bottom-navigation": "^1.3.0", "nativescript-camera": "4.1.1", "nativescript-carousel": "^3.1.1", "nativescript-cfalert-dialog": "^1.0.13", "nativescript-couchbase": "^1.0.18", "nativescript-fancyalert": "^3.0.6", "nativescript-feedback": "^1.3.3", "nativescript-iqkeyboardmanager": "^1.3.0", "nativescript-loading-indicator": "^2.4.0", "nativescript-masked-text-field": "^3.0.2", "nativescript-mediafilepicker": "^2.0.15", "nativescript-purchase": "^2.0.5", "nativescript-sentry": "^1.5.2", "nativescript-theme-core": "~1.0.4", "nativescript-ui-autocomplete": "^3.9.0", "nativescript-ui-dataform": "^3.6.1", "nativescript-ui-listview": "^3.5.8", "nativescript-unit-test-runner": "^0.3.4", "tns-core-modules": "5.0.2" }, "devDependencies": { "babel-traverse": "6.26.0", "babel-types": "6.26.0", "babylon": "6.18.0", "copy": "^0.3.2", "jasmine-core": "3.2.1", "karma": "3.0.0", "karma-jasmine": "1.1.2", "karma-nativescript-launcher": "0.4.0", "lazy": "1.0.11", "rimraf": "^2.6.2", "util": "^0.11.0" }
same error for android 8.
I get the same issues, although I don't when I try the demo app even though I can't see any difference in the two. For me the problem seems to be around the permission. If I grant permission on the first attempt then everything is fine. If I don't, if I deny permissions on the first attempt then give permissions subsequently I get this error. There is also another plugin in my app (ML Kit) that uses the camera and this still works.
This is exactly what happens on NS7 with V5: https://github.com/NativeScript/nativescript-camera/issues/248#issuecomment-696364300
I'm attempting a simple camera demo app. When I run
takePicture
, I'm getting the error below:Which platform(s) does your issue occur on?
Please, provide the following version numbers that your issue occurs with:
This is the code I've used: