question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fail to connect to camera service

See original GitHub issue

Using Android SDK v.24

W/CameraBase: An error occurred while connecting to camera 0: Service not available W/art: Before Android 4.1, method int android.support.v7.widget.DropDownListView.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView E/AndroidRuntime: FATAL EXCEPTION: cs-init Process: com.fuib.bridgest, PID: 19022 java.lang.RuntimeException: Fail to connect to camera service at android.hardware.Camera.<init>(Camera.java:556) at android.hardware.Camera.open(Camera.java:372) at com.budiyev.android.codescanner.CodeScanner$InitializationThread.initialize(CodeScanner.java:764) at com.budiyev.android.codescanner.CodeScanner$InitializationThread.run(CodeScanner.java:741)

Code:

public class LoginActivity extends AppCompatActivity {
    private CodeScanner mCodeScanner;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);


        CodeScannerView scannerView = findViewById(R.id.scanner_view);
        mCodeScanner = new CodeScanner(this, scannerView);
        mCodeScanner.setCamera(CodeScanner.CAMERA_BACK);
        mCodeScanner.setDecodeCallback(new DecodeCallback() {
            @Override
            public void onDecoded(@NonNull final Result result) {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(getApplicationContext(), result.getText(), Toast.LENGTH_SHORT).show();
                    }
                });
            }
        });
        scannerView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mCodeScanner.startPreview();
            }
        });
    }

    @Override
    protected void onResume() {
        super.onResume();
        mCodeScanner.startPreview();
    }

    @Override
    protected void onPause() {
        mCodeScanner.releaseResources();
        super.onPause();
    }
}

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

0reactions
joel-personalcommented, Jun 22, 2022

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.<init>(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.<init>(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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to connect to camera service - Stack Overflow
The problem is related to permission. Copy following code into onCreate() method. The issue will get solved.
Read more >
Fail to connect to camera service Android java ... - Code2care
Reason: Any hardware you use like Bluetooth, Camara, Wifi, or other sensors you need to get the Permissions from the user that your...
Read more >
Camera.open: Fail to connect to camera service · Issue #189
This issue occurs when the camera is in a state that is not ready for use, the cause may be that some other...
Read more >
Fail to connect to camera service - Wikitude
Hi, my first guess is that the camera is already in use, and the ArchitectView cannot open it. But we also have other...
Read more >
android java lang runtimeexception fail to connect to camera ...
Android : android java lang runtimeexception fail to connect to camera service [ Beautify Your Computer ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found