Opening camera in kotlin activity issue

Try to open camera in Kotlin android app:
But throws exception could not connect to camera service

Exactly the same code open camera in android (Java) but not in android(Kotlin)

  • Is there something different for camera handling in kotlin
  • I have already added permission to android manifest for camera, also runtime permission.
  •          **try {**
                 **mCamera = Camera.open(camIdx)**
               **} catch (e2: RuntimeException) {**
                 **return**
             }