natario1/CameraView

java.lang.RuntimeException: Fail to connect to camera service

jjhappyforever opened this issue · 0 comments

Describe the bug

Please add a clear description of what the bug is, and fill the list below.

  • CameraView version: 2.7.2
  • Camera engine used: camera2
  • Reproducible in official demo app: yes/no
  • Device / Android version: Pixel, API 28
  • I have read the FAQ page: yes

To Reproduce

Steps to reproduce the behavior, possibly in the demo app:

  1. Start a service and start the floating window function in the service.
  2. When using cameraview in the floating window, it is in a black screen state and reports: Fail to connect to camera service.
    You need to click Add, and the camera may work at this time, but when you remove and perform the add operation again, the screen will be black.
  3. Executing through the adb command will definitely produce this error:
    (adb shell am startservice -n com.camera.example/com.demo.example.TestService)

I have tried it for a long time, but I can't use it normally. I hope you can help me. I will thank you very much。💗

Expected behavior

A clear and concise description of what you expected to happen.

XML layout

Part of the XML layout with the CameraView declaration, so we can read its attributes.

<?xml version="1.0" encoding="utf-8"?>
<com.otaliastudios.cameraview.CameraView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/camera_view"
    android:layout_width="200.0dip"
    android:layout_height="200.0dip"
    android:adjustViewBounds="true"
    app:cameraAudio="off"
    app:cameraEngine="camera2"
    app:cameraFacing="front"
    app:cameraFlash="off"
    app:cameraMode="picture"
    app:cameraPictureFormat="jpeg"
    app:cameraPictureSizeMaxHeight="1920"
    app:cameraPictureSizeMaxWidth="1080"
    app:cameraPictureSizeMinHeight="1080"
    app:cameraPictureSizeMinWidth="960"
    app:cameraPlaySounds="false"
    app:cameraRequestPermissions="false" />

Screenshots

image

Logs

Use CameraLogger.setLogLevel(LEVEL_INFO) to see all logs into LogCat.

Use CameraLogger.registerLogger() to export to file or crash reporting service.

APK

Link to a Github repo where the bug is reproducible.

https://github.com/jjhappyforever/CameraDemo