Camera not working on Android after upgrade

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?

1 Like

Are there any errors on the remote console?

Use Remote Debugging to check.

For Android, use Chrome Remote Debugging.

For iOS, use Safari Remote Debugging (MacOS only) or (Windows or MacOS).

I tried on Android (my goal is to publish this update only on Google Play).
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”

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

My settings are

 <preference name="phonegap-version" value="cli-11.1.0" />
  <preference name="android-minSdkVersion" value="22" />
  <preference name="android-compileSdkVersion" value="32"/>
  <preference name="android-targetSdkVersion" value="32" />
  <engine name="android" spec="11.0.0" />

Further, here Troubleshooting | VoltBuilder you say

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” ?

1 Like

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):

  1. You can ignore this message:
    GET https://localhost/favicon.ico net::ERR_CONNECTION_REFUSED

  2. 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.

  3. We hear that phonegap-plugin-barcodescanner-android12 is working well for most people.

The function cordova.plugins.barcodeScanner.scan() the one I use to try to read a barcode. It always worked until this update attempt.

I didn’t change a singole row of my working code, I just edited the config.xml file. Maybe can I send it to you for a quick check?
Can it be a permission issue? See my comment Camera not working on Android after upgrade - #5 by piero.alberto

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.

Ok ghenne, but can you at least answer to my question about permission?

In the official documentation, here Troubleshooting | VoltBuilder I read:

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.

Thanks, @HankLloydRight - good ideas!

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 " />

Give that a try and let us know what happens.

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?

<widget id="xxx" version="1.0.x" versionCode="x" xmlns="" xmlns:cdv="">
  <author email="" href="">xxx</author>
  <preference name="permissions" value="none" />
  <preference name="prerendered-icon" value="true" />
  <preference name="phonegap-version" value="cli-11.1.0" />
  <preference name="android-windowSoftInputMode" value="adjustPan" />
  <preference name="AutoHideSplashScreen" value="true" />
  <plugin name="cordova-plugin-splashscreen" />
  <preference name="SplashScreenDelay" value="3000" />
  <!--<preference name="SplashShowOnlyFirstTime" value="false" />-->
   <feature name="LaunchScreen">
      <param name="ios-package" value="LaunchScreenStoryboard" onload="true" />
      <preference name="StoryboardName" value="LaunchScreen" />
      <preference name="FadeOut" value="true" />
      <preference name="FadeOutDuration" value="1" />
  <preference name="DisallowOverscroll" value="true" />
  <preference name="StatusBarOverlaysWebView" value="false" />
  <preference name="StatusBarStyle" value="default" />
  <!-- Android only preferences -->
  <preference name="KeepRunning" value="true"/>
  <feature name="StatusBar">
    <param name="ios-package" value="CDVStatusBar" onload="true" />
  <preference name="StatusBarBackgroundColor" value="#000000" />
  <preference name="android-minSdkVersion" value="22" />
  <preference name="android-compileSdkVersion" value="32"/>
  <preference name="android-targetSdkVersion" value="32" />
  <plugin name="cordova-plugin-inappbrowser" />
  <!--<plugin name="cordova-plugin-whitelist" />-->
  <access origin="*" />
  <allow-intent href="*" />
  <plugin name="cordova-plugin-ios-longpress-fix" />
  <engine name="android" spec="11.0.0" />
   <plugin name="cordova-plugin-androidx-adapter" />
  <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application/activity">
   <application android:exported="true" />
  <!--<plugin name="cordova-android-support-gradle-release">
    <variable name="ANDROID_SUPPORT_VERSION" value="28.0.0"/>
  <preference name="scheme" value="app" />
  <preference name="hostname" value="localhost"  /> 
  <plugin name="cordova-custom-config" version="*" />
  <plugin name="phonegap-plugin-barcodescanner-android12">
    <param name="CAMERA_USAGE_DESCRIPTION" value="xxx" />
    <!--To scan barcodes.-->
  <plugin name="cordova-plugin-camera" source="npm" spec="6.0.0">
    <variable name="CAMERA_USAGE_DESCRIPTION" value="xxx" />
    <variable name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="xxx" />
  <plugin name="cordova-plugin-app-version" />
  <plugin name="cordova-plugin-exit" />
   <platform name="ios">
  <edit-config target="NSCameraUsageDescription" file="*-Info.plist" mode="overwrite">
  <edit-config target="NSPhotoLibraryUsageDescription" file="*-Info.plist" mode="overwrite">

<platform name="android">
  <config-file parent="/*" target="AndroidManifest.xml">
    <uses-permission android:name="android.permission.CAMERA" />
	<uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-feature android:name="" />
	<uses-feature android:name="android.hardware.flash" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <platform name="ios">
    <preference name="WKWebViewOnly" value="true" />
    <feature name="CDVWKWebViewEngine">
        <param name="ios-package" value="CDVWKWebViewEngine" />
    <preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />
  <edit-config target="CFBundleShortVersionString" file="*-Info.plist" mode="merge">
  <icon   src="res/screen/ios/PackageIcons.iOS.iTunesArtwork.png"/>
  <preference name="AndroidWindowSplashScreenAnimatedIcon" value="res/screen/ios/Default@2x~universal~anyany.png" />
  <preference name="AndroidWindowSplashScreenBackground" value="#000000" />
  <splash src="res/screen/ios/Default@2x~universal~anyany.png" />
  <platform name="android">
	  <icon src="res/screen/android/PackageIcons.Android.ic_launcher_36_36.png" density="ldpi" />
	  <icon src="res/screen/android/PackageIcons.Android.ic_launcher_48_48.png" density="mdpi" />
	  <icon src="res/screen/android/PackageIcons.Android.ic_launcher_72_72.png"  density="hdpi" />
	  <icon src="res/screen/android/PackageIcons.Android.ic_launcher_96_96.png"  density="xhdpi" />
	  <splash src="res/screen/android/PackageIcons.Android.splash_200_320.png"  density="port-ldpi" />
	  <splash src="res/screen/android/PackageIcons.Android.splash_320_480.png"  density="port-mdpi" />
	  <splash src="res/screen/android/PackageIcons.Android.splash_480_800.png"  density="port-hdpi" />
	  <splash src="res/screen/android/PackageIcons.Android.splash_720_1280.png"  density="port-xhdpi" />
	  <splash src="res/screen/android/PackageIcons.Android.splash_320_200.png"  density="land-ldpi" />
	  <splash src="res/screen/android/PackageIcons.Android.splash_480_320.png"  density="land-mdpi" />
	  <splash src="res/screen/android/PackageIcons.Android.splash_800_480.png"  density="land-hdpi" />
	  <splash src="res/screen/android/PackageIcons.Android.splash_1280_720.png"  density="land-xhdpi" />
  <platform name="ios">
	  <icon src="res/screen/ios/PackageIcons.iOS.icon.png" width="57" height="57" />
	  <icon src="res/screen/ios/PackageIcons.iOS.icon-60.png" width="60" height="60" />
	  <icon src="res/screen/ios/PackageIcons.iOS.icon-72.png" width="72" height="72" />
	  <icon src="res/screen/ios/PackageIcons.iOS.icon-76.png" width="76" height="76" />
	  <icon src="res/screen/ios/PackageIcons.iOS.icon@2x.png" width="114" height="114" />
	  <icon src="res/screen/ios/PackageIcons.iOS.icon-60@2x.png" width="120" height="120" />
	  <icon src="res/screen/ios/PackageIcons.iOS.icon-88@2x.png" width="167" height="167" />
	  <icon src="res/screen/ios/PackageIcons.iOS.icon-72@2x.png" width="144" height="144" />
	  <icon src="res/screen/ios/PackageIcons.iOS.icon-76@2x.png" width="152" height="152" />
	  <icon src="res/screen/ios/PackageIcons.iOS.icon-60@3x.png" width="180" height="180" />
	  <icon src="res/screen/ios/PackageIcons.iOS.AppIcon40x40~ipad.png" width="40" height="40" />
	  <icon src="res/screen/ios/PackageIcons.iOS.AppIcon40x40@2x.png" width="80" height="80" />
	  <icon src="res/screen/ios/PackageIcons.iOS.AppIcon40x40@3x.png" width="120" height="120" />
	  <icon src="res/screen/ios/PackageIcons.iOS.AppIcon50x50~ipad.png" width="50" height="50" />
	  <icon src="res/screen/ios/PackageIcons.iOS.AppIcon50x50@2x~ipad.png" width="100" height="100" />
	  <icon src="res/screen/ios/PackageIcons.iOS.AppIcon29x29.png" width="29" height="29" />
	  <icon src="res/screen/ios/PackageIcons.iOS.AppIcon29x29@2x.png" width="58" height="58" />
	  <icon src="res/screen/ios/PackageIcons.iOS.AppIcon29x29@3x.png" width="87" height="78" />
	  <icon src="res/screen/ios/PackageIcons.iOS.iTunesArtwork.png" width="1024" height="1024" />

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 …

Was already present in my config.xml.

Thanks in advance.

If you can make a minimal project which shows the problem, I’ll give it a try here.

Hi @ghenne ,
here a very simple example.

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 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?

Thanks in advance

You should be able to email it to

@ghenne I just sent it

I sent it again, less heavy file now

Thank you - I’ll have a look.