Git Product home page Git Product logo

Comments (10)

yuriy-budiyev avatar yuriy-budiyev commented on May 28, 2024 4

You should request camera permission on API >= 23
https://github.com/yuriy-budiyev/lib-demo-app/blob/master/app/src/main/java/com/budiyev/android/libdemoapp/codescanner/CodeScannerActivity.java

from code-scanner.

rajeshdroid374 avatar rajeshdroid374 commented on May 28, 2024 2

ask for runtime camera permission and you are good to go.

from code-scanner.

krupalbhardiya avatar krupalbhardiya commented on May 28, 2024

@yuriy-budiyev

Facing the same issue on some devices.

Android manifest has permission for Camera and there is run-time permission modal implemented in the Activity as well. Library works flawlessly in devices API >23.

Still found the same error.

Fatal Exception: java.lang.RuntimeException: Fail to connect to camera service at android.hardware.Camera.(Camera.java:653) at android.hardware.Camera.open(Camera.java:494) at com.budiyev.android.codescanner.CodeScanner$InitializationThread.initialize(CodeScanner.java) at com.budiyev.android.codescanner.CodeScanner$InitializationThread.run(CodeScanner.java)

Device info:

Device
Brand: OPPO
Model: X9009
Orientation: Portrait
RAM free: 1.73 GB
Disk free: 29.26 GB
Operating System
Version: 5.1
Orientation: Portrait
Rooted: No

from code-scanner.

yuriy-budiyev avatar yuriy-budiyev commented on May 28, 2024

Have you added camera permission to manifest?

from code-scanner.

krupalbhardiya avatar krupalbhardiya commented on May 28, 2024

@yuriy-budiyev yes. Permission is added in manifest as well as runtime permission is also asked. Therefor Library is working in majority of devices in the developed App. I have found some devices mentioned earlier which don't support this library (Original Comment).
I would recommend implementation of Camera2 API compatibility. My project is set to minSdkVersion = 19.
Although CameraX is introduced in Android Jetpack, it requires minSdkVersion = 23, which will not benefit to this library.

from code-scanner.

yuriy-budiyev avatar yuriy-budiyev commented on May 28, 2024

I will update to Camera2 API when devices lower than 21 SDK become irrelevant

from code-scanner.

satyamgupta0202 avatar satyamgupta0202 commented on May 28, 2024

It is showing the issues with the camera permission

from code-scanner.

SiddheshShetye avatar SiddheshShetye commented on May 28, 2024

facing this issue. is there any update?

below Is the stack trace
Fatal Exception: java.lang.RuntimeException: Fail to connect to camera service
at android.hardware.Camera.(Camera.java:633)
at android.hardware.Camera.open(Camera.java:431)
at com.budiyev.android.codescanner.CodeScanner$InitializationThread.initialize(CodeScanner.java:835)
at com.budiyev.android.codescanner.CodeScanner$InitializationThread.run(CodeScanner.java:812)

from code-scanner.

yuriy-budiyev avatar yuriy-budiyev commented on May 28, 2024

Check camera permissions and update to 2.1.2 for better error handling.

from code-scanner.

joel-personal avatar joel-personal commented on May 28, 2024

E/AndroidRuntime: FATAL EXCEPTION: cs-init
Process: com.lightlogistics.vaast, PID: 5369
java.lang.RuntimeException: Fail to connect to camera service
at android.hardware.Camera.(Camera.java:637)
at android.hardware.Camera.open(Camera.java:458)
at com.budiyev.android.codescanner.CodeScanner$InitializationThread.initialize(CodeScanner.java:835)
at com.budiyev.android.codescanner.CodeScanner$InitializationThread.run(CodeScanner.java:812)
E/CustomActivityOnCrash: App has crashed, executing CustomActivityOnCrash's UncaughtExceptionHandler
java.lang.RuntimeException: Fail to connect to camera service
at android.hardware.Camera.(Camera.java:637)
at android.hardware.Camera.open(Camera.java:458)
at com.budiyev.android.codescanner.CodeScanner$InitializationThread.initialize(CodeScanner.java:835)
at com.budiyev.android.codescanner.CodeScanner$InitializationThread.run(CodeScanner.java:812)

i have asked permission and it works but some times app crashes
i am using 'com.budiyev.android:code-scanner:2.1.0' version

from code-scanner.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.