Fail to connect to camera service Android java RuntimeException


Fail to connect to camera service Android java RuntimeException
Fail to connect to camera service Android java RuntimeException
Stack-trace:
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo {com.code2care.tools
.app/com.code2care.tools.app.MainActivity}: 
java.lang.RuntimeException: Fail to connect to camera service
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2836)
at android.app.ActivityThread.access$1600(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Fail to connect to camera service
at android.hardware.Camera.native_setup(Native Method)
at android.hardware.Camera.<init>(Camera.java:291)
at android.hardware.Camera.open(Camera.java:266)
at com.code2care.tools.app.MainActivity.onCreate(MainActivity.java:59)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
... 12 more

You have used the Camara hardware java code in your Android application everything seems fine with no errors in eclipse project files, but it fails on runtime ?

Reason: Any hardware you use like Bluetooth, Camara, Wifi, or other sensors you need to get the Permissions from the user that your app wants them. To do so you need to add this code in the AndroidManifest.xml file.

For Camara App add the following lines :

<uses-permission android:name = "android.permission.CAMERA"/>

Try running the App now you will not the Camara RuntimeException exception.




Recent Posts:




Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.