New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with Android 6.0.1 #139

Closed
debugerr opened this Issue Jan 4, 2016 · 27 comments

Comments

Projects
None yet
@debugerr

debugerr commented Jan 4, 2016

I get an error on Android 6.0.1 saying that there was an error with the "Android Camera", (the message is in German, but it may translate to:

Unfortunately there was an error with the Android-Camera. It could be that you need to restart your device.

Does anyone see this?

@vrushankshukla

This comment has been minimized.

Show comment
Hide comment
@vrushankshukla

vrushankshukla Jan 6, 2016

I created an app using this same plugin but it's only works in android 4, I tested my app on android 5.1.1 and android 6.0.1, but it's not doing anything on a scan button click. Not opening the camera. Even I found none of my functions are working on those platform.

Also I found following link, which may be help you:
https://cordova.apache.org/announcements/2015/11/09/cordova-android-5.0.0.html

vrushankshukla commented Jan 6, 2016

I created an app using this same plugin but it's only works in android 4, I tested my app on android 5.1.1 and android 6.0.1, but it's not doing anything on a scan button click. Not opening the camera. Even I found none of my functions are working on those platform.

Also I found following link, which may be help you:
https://cordova.apache.org/announcements/2015/11/09/cordova-android-5.0.0.html

@vrushankshukla

This comment has been minimized.

Show comment
Hide comment
@vrushankshukla

vrushankshukla Jan 11, 2016

I have the same error in Android 6.x.x. Unfortunately there was an error with the Android-Camera. It could be that you need to restart your device. Till Android 5.x.x, it's working but not for the Android 6.

So how can I test with this Android zxing integration? I am totally new to this. What steps I need to follow?

Sicerely

vrushankshukla commented Jan 11, 2016

I have the same error in Android 6.x.x. Unfortunately there was an error with the Android-Camera. It could be that you need to restart your device. Till Android 5.x.x, it's working but not for the Android 6.

So how can I test with this Android zxing integration? I am totally new to this. What steps I need to follow?

Sicerely

@debugerr

This comment has been minimized.

Show comment
Hide comment
@debugerr

debugerr Jan 11, 2016

For me, this problem only shows when I add the facebook4 plugin (https://www.npmjs.com/package/cordova-plugin-facebook4).

If I remove this from my package, the camera starts working again. I'm not sure if that's a compatibility problem on the fb plugin side, or on this plugins side...

debugerr commented Jan 11, 2016

For me, this problem only shows when I add the facebook4 plugin (https://www.npmjs.com/package/cordova-plugin-facebook4).

If I remove this from my package, the camera starts working again. I'm not sure if that's a compatibility problem on the fb plugin side, or on this plugins side...

@VicM

This comment has been minimized.

Show comment
Hide comment
@VicM

VicM Jan 15, 2016

I am also facing this problem. I was developing an app with an Android Lollipop phone as test device and the scanner was working, after the update to marshmallow it throws the noted error. Also updated to the latest cordova, android platform with no success. Any temporal fixes or work arounds?

VicM commented Jan 15, 2016

I am also facing this problem. I was developing an app with an Android Lollipop phone as test device and the scanner was working, after the update to marshmallow it throws the noted error. Also updated to the latest cordova, android platform with no success. Any temporal fixes or work arounds?

@vdamyanov

This comment has been minimized.

Show comment
Hide comment
@vdamyanov

vdamyanov Feb 4, 2016

A potential workaround is to change your target sdk version to 22 (Lollipop) instead of 23 (Marshmallow).
In platforms/android/AndroidManifest.xml change to:

<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22" />

In platforms/android/prodject.properties change to:

target=android-22

I had the same problems as above. Updated cordova to 6, Cordova Android to 5.1 and nothing worked. Then I dowgraded my sdk and that fixed it. Building to Android 5 and Android 6 devices with the old sdk works fine.

vdamyanov commented Feb 4, 2016

A potential workaround is to change your target sdk version to 22 (Lollipop) instead of 23 (Marshmallow).
In platforms/android/AndroidManifest.xml change to:

<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22" />

In platforms/android/prodject.properties change to:

target=android-22

I had the same problems as above. Updated cordova to 6, Cordova Android to 5.1 and nothing worked. Then I dowgraded my sdk and that fixed it. Building to Android 5 and Android 6 devices with the old sdk works fine.

@poshaughnessy

This comment has been minimized.

Show comment
Hide comment
@poshaughnessy

poshaughnessy Feb 9, 2016

Thanks for the suggestion @vdamyanov!

I'm regenerating the platform directories as part of our build process, so I added the config to our config.xml:

<platform name="android">
        <preference name="android-targetSdkVersion" value="22"/>
</platform>

Seems to have done the trick for now!

poshaughnessy commented Feb 9, 2016

Thanks for the suggestion @vdamyanov!

I'm regenerating the platform directories as part of our build process, so I added the config to our config.xml:

<platform name="android">
        <preference name="android-targetSdkVersion" value="22"/>
</platform>

Seems to have done the trick for now!

@waelkdouh

This comment has been minimized.

Show comment
Hide comment
@waelkdouh

waelkdouh Mar 3, 2016

Same here. Cannot get it to work when installing with VS 2015 with TACO update 7. I am deploying it on a nexus 6p. Used to work before getting the latest TACO update.

waelkdouh commented Mar 3, 2016

Same here. Cannot get it to work when installing with VS 2015 with TACO update 7. I am deploying it on a nexus 6p. Used to work before getting the latest TACO update.

@lholznagel

This comment has been minimized.

Show comment
Hide comment
@lholznagel

lholznagel Mar 15, 2016

I had the same Problem. I looked in the link from @vrushankshukla and like it says I updated my Android version with cordova platform update android@5.0.0.
That fixed the problem on my Nexus 7 with Android 6.

lholznagel commented Mar 15, 2016

I had the same Problem. I looked in the link from @vrushankshukla and like it says I updated my Android version with cordova platform update android@5.0.0.
That fixed the problem on my Nexus 7 with Android 6.

@loyalpocket

This comment has been minimized.

Show comment
Hide comment
@loyalpocket

loyalpocket Mar 18, 2016

For Android 6+, because of the "permission" issue, If you got the message "Sorry, the camera encountered a problem. You may need to restart the device.", go to Settings - Apps - find "your app name" - select Permissions and switch on "Camera".

loyalpocket commented Mar 18, 2016

For Android 6+, because of the "permission" issue, If you got the message "Sorry, the camera encountered a problem. You may need to restart the device.", go to Settings - Apps - find "your app name" - select Permissions and switch on "Camera".

@cuiti

This comment has been minimized.

Show comment
Hide comment
@cuiti

cuiti Mar 28, 2016

I have the same problem here. It's related to the new Android 6 (API 23) permissions. Setting the targetSdkVersion to "22" solves the problem for now, but this should be fixed.

This is the exception in logcat:
W/ServiceManager: Permission failure: android.permission.CAMERA from uid=10293 pid=1417
E/CameraService: Permission Denial: can't use the camera pid=1417, uid=10293
com.ionicframework.fm176018 W/CameraBase: An error occurred while connecting to camera: 0
com.ionicframework.fm176018 W/CaptureActivity: Unexpected error initializing camera java.lang.RuntimeException: Fail to connect to camera service

cuiti commented Mar 28, 2016

I have the same problem here. It's related to the new Android 6 (API 23) permissions. Setting the targetSdkVersion to "22" solves the problem for now, but this should be fixed.

This is the exception in logcat:
W/ServiceManager: Permission failure: android.permission.CAMERA from uid=10293 pid=1417
E/CameraService: Permission Denial: can't use the camera pid=1417, uid=10293
com.ionicframework.fm176018 W/CameraBase: An error occurred while connecting to camera: 0
com.ionicframework.fm176018 W/CaptureActivity: Unexpected error initializing camera java.lang.RuntimeException: Fail to connect to camera service

@rudza

This comment has been minimized.

Show comment
Hide comment
@rudza

rudza Apr 8, 2016

Any progress on this?

rudza commented Apr 8, 2016

Any progress on this?

EddyVerbruggen added a commit to Telerik-Verified-Plugins/BarcodeScanner that referenced this issue Apr 16, 2016

This fixes a few issues in our fork:
Image upside down on tablet #20
Android UI doesn't support Portrait and is small #4
Prebuilt Zebra Crossing (xzing) Library #3
Forcing landscape on camera android #17

And also fixes these issues found here (possibly others as well):
Android Nexus 5x upside down images phonegap/phonegap-plugin-barcodescanner#175
Support Aztec for Android and Ios phonegap/phonegap-plugin-barcodescanner#195
Android: Force landscape orientation? phonegap/phonegap-plugin-barcodescanner#177
Android M issues. Due to new intent/permissions phonegap/phonegap-plugin-barcodescanner#167
Problem with Android 6.0.1 phonegap/phonegap-plugin-barcodescanner#139
Is the zxing version used years away from the original zxing lib? phonegap/phonegap-plugin-barcodescanner#124
Updating ZXing Library phonegap/phonegap-plugin-barcodescanner#59
@M-k-03

This comment has been minimized.

Show comment
Hide comment
@M-k-03

M-k-03 Apr 25, 2016

@loyalpocket : I need to set that exact permission u specified Programatically.. is it possible?????

M-k-03 commented Apr 25, 2016

@loyalpocket : I need to set that exact permission u specified Programatically.. is it possible?????

@azn1viet

This comment has been minimized.

Show comment
Hide comment
@azn1viet

azn1viet Apr 26, 2016

I got the same issue. This permission in Android 6 needs to be set programmatically before compiling the app. Any one knows where it could be set for this matter?

azn1viet commented Apr 26, 2016

I got the same issue. This permission in Android 6 needs to be set programmatically before compiling the app. Any one knows where it could be set for this matter?

@lx4r

This comment has been minimized.

Show comment
Hide comment
@lx4r

lx4r Apr 27, 2016

Is there any official fix for this yet?

lx4r commented Apr 27, 2016

Is there any official fix for this yet?

@azn1viet

This comment has been minimized.

Show comment
Hide comment
@azn1viet

azn1viet Apr 27, 2016

I got a fix by installing a plugin:

https://github.com/dpa99c/cordova-diagnostic-plugin#requestcameraauthorization

with requestCameraAuthorization() function

You gotta detect the user Android OS version then call this plugin when it's greater than 6.0 to pop up system native permission so that the user can interact with your app to allow or deny. This action can't be overridden programatically.

For more info. regarding to this matter, follow the link from Google:

http://developer.android.com/training/permissions/requesting.html

Hope this help.

azn1viet commented Apr 27, 2016

I got a fix by installing a plugin:

https://github.com/dpa99c/cordova-diagnostic-plugin#requestcameraauthorization

with requestCameraAuthorization() function

You gotta detect the user Android OS version then call this plugin when it's greater than 6.0 to pop up system native permission so that the user can interact with your app to allow or deny. This action can't be overridden programatically.

For more info. regarding to this matter, follow the link from Google:

http://developer.android.com/training/permissions/requesting.html

Hope this help.

@Smohanapriya

This comment has been minimized.

Show comment
Hide comment
@Smohanapriya

Smohanapriya Jul 15, 2016

<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22" />

Is helped me to solve my issue. Thank You :)

Smohanapriya commented Jul 15, 2016

<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22" />

Is helped me to solve my issue. Thank You :)

@poychang

This comment has been minimized.

Show comment
Hide comment
@poychang

poychang Aug 11, 2016

This plugin work with me.
https://github.com/dpa99c/cordova-diagnostic-plugin#requestcameraauthorization
It's android device permissions problem.

poychang commented Aug 11, 2016

This plugin work with me.
https://github.com/dpa99c/cordova-diagnostic-plugin#requestcameraauthorization
It's android device permissions problem.

@robertklein

This comment has been minimized.

Show comment
Hide comment
@robertklein

robertklein Oct 7, 2016

I solved this with https://github.com/NeoLSN/cordova-plugin-android-permission by checking (and requesting /if needed/) permissions in my onDeviceReady callback. It's all about android 6 requests permissions at runtime not during the installation.

robertklein commented Oct 7, 2016

I solved this with https://github.com/NeoLSN/cordova-plugin-android-permission by checking (and requesting /if needed/) permissions in my onDeviceReady callback. It's all about android 6 requests permissions at runtime not during the installation.

@Smohanapriya

This comment has been minimized.

Show comment
Hide comment
@Smohanapriya

Smohanapriya Oct 11, 2016

Is there any new plugin available?

Smohanapriya commented Oct 11, 2016

Is there any new plugin available?

@pke

This comment has been minimized.

Show comment
Hide comment
@pke

pke Oct 13, 2016

edit: Just saw, @robertklein already suggested that already.

Another proper fix to this problem, without changing the plugin at all, is to use another, more general Android permissions plugin and request the CAMERA permission from your javascript like this:

var permissions = cordova.plugins.permissions;
permissions.hasPermission(permissions.CAMERA, checkPermissionCallback, null);

function checkPermissionCallback(status) {
  if(!status.hasPermission) {
    var errorCallback = function() {
      console.warn('Camera permission is not turned on');
    }

    permissions.requestPermission(
      permissions.CAMERA,
      function(status) {
        if(!status.hasPermission) errorCallback();
      },
      errorCallback);
  }
}

That works good for me, as I have to stay on 3.1.0 of this scanner plugin because all the newer versions have awful QR detection rates/speeds.

pke commented Oct 13, 2016

edit: Just saw, @robertklein already suggested that already.

Another proper fix to this problem, without changing the plugin at all, is to use another, more general Android permissions plugin and request the CAMERA permission from your javascript like this:

var permissions = cordova.plugins.permissions;
permissions.hasPermission(permissions.CAMERA, checkPermissionCallback, null);

function checkPermissionCallback(status) {
  if(!status.hasPermission) {
    var errorCallback = function() {
      console.warn('Camera permission is not turned on');
    }

    permissions.requestPermission(
      permissions.CAMERA,
      function(status) {
        if(!status.hasPermission) errorCallback();
      },
      errorCallback);
  }
}

That works good for me, as I have to stay on 3.1.0 of this scanner plugin because all the newer versions have awful QR detection rates/speeds.

@Smohanapriya

This comment has been minimized.

Show comment
Hide comment
@Smohanapriya

Smohanapriya Oct 24, 2016

After lower the SDK version to 22,

<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22" />

also not working for me? Any other solution is there?

Smohanapriya commented Oct 24, 2016

After lower the SDK version to 22,

<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22" />

also not working for me? Any other solution is there?

@pke

This comment has been minimized.

Show comment
Hide comment
@pke

pke Oct 24, 2016

I commented the solution just above ur post

pke commented Oct 24, 2016

I commented the solution just above ur post

@yokeshvaradhan

This comment has been minimized.

Show comment
Hide comment
@yokeshvaradhan

yokeshvaradhan Mar 22, 2017

I am getting the same issue, i designed a audio recorder app it works good in lolli-pop, kit-kat and in naugat but that same is not working in marshmallow, i use cordova media plugin

cordova-plugin-compat 1.1.0 cordova-plugin-console 1.0.5 cordova-plugin-device 1.1.4 cordova-plugin-file 4.3.2 cordova-plugin-file-transfer 1.6.2 cordova-plugin-media 3.0.0 cordova-plugin-splashscreen 4.0.2 cordova-plugin-statusbar 2.2.1 cordova-plugin-whitelist 1.3.1 cordova-sqlite-storage 2.0.2 ionic-plugin-keyboard 2.2.1

<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="25" />

could someone help me.

yokeshvaradhan commented Mar 22, 2017

I am getting the same issue, i designed a audio recorder app it works good in lolli-pop, kit-kat and in naugat but that same is not working in marshmallow, i use cordova media plugin

cordova-plugin-compat 1.1.0 cordova-plugin-console 1.0.5 cordova-plugin-device 1.1.4 cordova-plugin-file 4.3.2 cordova-plugin-file-transfer 1.6.2 cordova-plugin-media 3.0.0 cordova-plugin-splashscreen 4.0.2 cordova-plugin-statusbar 2.2.1 cordova-plugin-whitelist 1.3.1 cordova-sqlite-storage 2.0.2 ionic-plugin-keyboard 2.2.1

<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="25" />

could someone help me.

@alherrera42

This comment has been minimized.

Show comment
Hide comment
@alherrera42

alherrera42 Apr 1, 2017

I confirm the issue and being solved by downgrading/changing the SDK version. In my case, from 23 to 22.

In my case, I require to use cordova-plugin-barcodescanner and camera. The first one just throws an alert, the second one asks for screen overlap permission (which is granted, but Android doesnt care anyways).

config.xml

<platform name="android">
        <preference name="android-targetSdkVersion" value="22"/>
</platform>

alherrera42 commented Apr 1, 2017

I confirm the issue and being solved by downgrading/changing the SDK version. In my case, from 23 to 22.

In my case, I require to use cordova-plugin-barcodescanner and camera. The first one just throws an alert, the second one asks for screen overlap permission (which is granted, but Android doesnt care anyways).

config.xml

<platform name="android">
        <preference name="android-targetSdkVersion" value="22"/>
</platform>
@koshypcherian

This comment has been minimized.

Show comment
Hide comment
@koshypcherian

koshypcherian Apr 24, 2017

Guess it's the camera permission setting for the application(allowing to use the camera). it worked for Samsung edge(Android 7)

koshypcherian commented Apr 24, 2017

Guess it's the camera permission setting for the application(allowing to use the camera). it worked for Samsung edge(Android 7)

@hoachan

This comment has been minimized.

Show comment
Hide comment
@hoachan

hoachan Jul 11, 2017

I met same the problem in cordova, and I think phonepgap also run same cordova,
I fix in cordova by install plugin cordova-plugin-android-permissions, then request
permission accessing camera to device with :
var permissions = cordova.plugins.permissions;
permissions.requestPermission(permissions.CAMERA, success, error);

after request permisson , u can check permission access camera and if it has no problem.
device would be scan with :
function success( status ) {
if( !status.hasPermission ) error();
cordova.plugins.barcodeScanner.scan(......)
}

hoachan commented Jul 11, 2017

I met same the problem in cordova, and I think phonepgap also run same cordova,
I fix in cordova by install plugin cordova-plugin-android-permissions, then request
permission accessing camera to device with :
var permissions = cordova.plugins.permissions;
permissions.requestPermission(permissions.CAMERA, success, error);

after request permisson , u can check permission access camera and if it has no problem.
device would be scan with :
function success( status ) {
if( !status.hasPermission ) error();
cordova.plugins.barcodeScanner.scan(......)
}

@lock

This comment has been minimized.

Show comment
Hide comment
@lock

lock bot Jun 8, 2018

This thread has been automatically locked.

lock bot commented Jun 8, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 8, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.