My app looks like it’s working, but when I try to open the camera to scan a barcode, the camera doesn’t open. The app didn’t asked for any permissions and event if I grant them, it doesn’t open the camera.
I had the phonegap-plugin-barcodescanner and I replaced with phonegap-plugin-barcodescanner-android12
Further, even when I have to open the camera to take a picture with cordova-plugin-camera, the camera doesn’t open.
Do you know why?
I tried on Android (my goal is to publish this update only on Google Play). BARCODE SCANNER
I have NO messages in console when I try to open the camera, the only one I see (but it is printed a lot of time in every screen) is GET https://localhost/favicon.ico net::ERR_CONNECTION_REFUSED
Further, if I try to open again the camera, I get the messare “Scan is already in progress”
TAKE A PICTURE
Nothing happens, nothing in the console, nothing in the app.
As I wrote in the post, I just updated the plugin, since the one I used to include in the project is now obsolete. What can I try now? Thanks in advance
If you are using the location, camera or photo album, Android and iOS now require you to ask the user for permission first.
Since the app is not asking for any permissions, can be this the clue? If yes, how can specify this for Android, since your example in the link is only for Android?
I have the same problem. When I run my application on my device, it doesn’t ask me the permission as usual. But also if I add manually them to the application, it is not able to open the camera anyway.
Is possible to have an example “how to configure correctly cordova-plugin-camera for android 12 xml file” ?
A few notes (I’ll give what help I can, but remember that the Camera and Barcode plugins are not developed or maintained by VoltBuilder):
You can ignore this message: GET https://localhost/favicon.ico net::ERR_CONNECTION_REFUSED
From looking at the docs, it seems the cordova.plugins.barcodeScanner.scan() function handles the camera - you do not need to open the Camera app to read the bar code.
We hear that phonegap-plugin-barcodescanner-android12 is working well for most people.
Thank you for your confidence in me - but we really do not know every plugin works (there are over 1200 of them on our list). We do not develop or support them.
Something I try when I’m unable to proceed on a problem is to make the smallest possible project with reproduces the problem. I often find the issue as part of the process of so doing, but if not - it’s easier for the maintainer to debug.
If you are using the location, camera or photo album, Android and iOS now require you to ask the user for permission first.
Since the app is not asking for any permissions, can be this the clue? If yes, how can specify this for Android, since your example in the link is only for iOS?
Something I found when the app permissions aren’t working is to totally delete the app and data from the Settings…Apps page. Then re-install the app. That should reset any granted permissions and it should ask again when using the app.
Also make sure to delete any other ‘test’ versions of your app that might have been installed as separate apps.
If it still doesn’t ask for camera permissions, then there’s an issue with the config file or the plugin or code. Then I would do what ghenne said and start with a minimal app to test the plugins.
The docs are indeed incorrect. Anything which refers to Info.plist is for iOS, so the code there won’t help with Android. We will correct them.
Looking at the docs from Google and Cordova, I can’t find anything which clearly states what is necessary. I did find this which may help:
<plugin name="cordova-plugin-camera">
<variable name="CAMERA_USAGE_DESCRIPTION" value="Camera used for MyProject" />
<variable name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="Photo Library used for MyProject " />
</plugin>
I already have that part in my config.xml file
I try both to install the app in a new device and clean cache and permission but the problem is still the same… the camera doesn’t open.
This is my config… do you see any issues? Did you miss something?
I’m pretty sure the issue is related to the permissions. I tried to enable them also manually, but still the camera is not opened and no errors appears.
In the previous versions of android (<12) there were no problem to open the camera and assign the permissions. Please, could you share a correct way to enable the permissions for android, as you indicated here?
The docs are indeed incorrect. Anything which refers to Info.plist is for iOS, so the code there won’t help with Android. We will correct them.
What you indicated here:
Looking at the docs from Google and Cordova, I can’t find anything which clearly states what is necessary. I did find this which may help …
There are 3 buttons.
The 2 at the bottom should open the camera to take a picture and to scan a QR code.
The first button (“Start camera”) uses html5 tag to open the camera and it works (only if I add manually the permissions). This is just a test, we don’t need this.
The “Capture Photo” button should open the camera to take a picture. It uses navigator.camera.getPicture but it doens’t open the camera and nothing appears in the console if we debug it
The “Scan QR” tries to scan a QR code with cordova.plugins.barcodeScanner but it doens’t open the camera and nothing appears in the console if we debug it
We need to restore the correct behavior of “Capture Photo” and “Scan QR” buttons, this is now very important for us.
I tried to attach the zip file here, but I can’t, how can I share it with you?