Android Question Cannot open camera using cameraex error

tejmccindia

Member
Licensed User
cannot open camera message error java.lang.reflect.InvocationTargetException occures when i save project with build configurations if i delete build configurations setting its working fine and this happens only in android version 7 and above
 

tejmccindia

Member
Licensed User
Logger connected to: samsung SM-J730GM
--------- beginning of main
--------- beginning of system
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
java.lang.reflect.InvocationTargetException
** Activity (main) Pause, UserClosed = false **
 
Upvote 0

tejmccindia

Member
Licensed User
Logger connected to: samsung SM-J730GM
--------- beginning of main
SS_ART_lib : permission is absent: /data/app/camera.example-2/base.apk
SS_ART_lib : access to SS denied
SELinux: seapp_context_lookup: seinfo=untrusted, level=s0:c512,c768, pkgname=camera.example
TimaKeyStore is not enabled: cannot add TimaSignature Service and generateKeyPair Service
ClassLoader referenced unknown path: /data/app/camera.example-2/lib/arm
Class anywheresoftware.b4a.BA failed lock verification and will run slower.
Common causes for lock verification issues are non-optimized dex code
and incorrect proguard optimizations.
Starting remote logger. Port: 44352
init sf_choreo_doframe debug_Level : 0x4f4cdebug_game_running : false
ThreadedRenderer.create() translucent=false
Input channel constructed: fd=55
setView = DecorView@c193c36[main] touchMode=true
--------- beginning of system
AppLock checkAppLockState locked:false verifying:false pkgName = camera.example isInMultiWindowMode:false
dispatchAttachedToWindow
Relayout returned: oldFrame=[0,0][0,0] newFrame=[0,0][1080,1920] result=0x27 surface={isValid=true -405837824} surfaceGenerationChanged=true
mHardwareRenderer.initialize() mSurface={isValid=true -405837824} hwInitialized=true
*** Debugger waiting for connection (0) ***
Initialized EGL, version 1.4
Swap behavior 1
After accept
EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000, [1080x1920]-format:1
ThreadedRenderer.create() translucent=true
Input channel constructed: fd=66
setView = DecorView@94ceaed[main] touchMode=true
MSG_RESIZED_REPORT: frame=Rect(0, 0 - 1080, 1920) ci=Rect(0, 72 - 0, 0) vi=Rect(0, 72 - 0, 0) or=1
MSG_WINDOW_FOCUS_CHANGED 1
mHardwareRenderer.initializeIfNeeded()#2 mSurface={isValid=true -405837824}
Starting input: tba=android.view.inputmethod.EditorInfo@5a26d22 nm : camera.example ic=null
[IMM] startInputInner - mService.startInputOrWindowGainedFocus
Input channel constructed: fd=70
dispatchAttachedToWindow
Relayout returned: oldFrame=[0,0][0,0] newFrame=[27,822][1053,1170] result=0x27 surface={isValid=true -739135488} surfaceGenerationChanged=true
mHardwareRenderer.initialize() mSurface={isValid=true -739135488} hwInitialized=true
EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000, [1218x540]-format:1
MSG_WINDOW_FOCUS_CHANGED 1
mHardwareRenderer.initializeIfNeeded()#2 mSurface={isValid=true -739135488}
Starting input: tba=android.view.inputmethod.EditorInfo@db503b3 nm : camera.example ic=null
MSG_RESIZED_REPORT: frame=Rect(27, 822 - 1053, 1170) ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
MSG_WINDOW_FOCUS_CHANGED 0
*** Debugger waiting for connection (1) ***
Copying updated assets files (2)
** Activity (main) Create, isFirst = true **
setTypeface with style : 0
setTypeface with style : 0
setTypeface with style : 0
setTypeface with style : 0
setTypeface with style : 0
setTypeface with style : 0
** Activity (main) Resume **
mHardwareRenderer.destroy()#1
Relayout returned: oldFrame=[27,822][1053,1170] newFrame=[27,822][1053,1170] result=0x5 surface={isValid=false 0} surfaceGenerationChanged=true
Relayout returned: oldFrame=[0,0][1080,1920] newFrame=[0,0][1080,1920] result=0x1 surface={isValid=true -405837824} surfaceGenerationChanged=false
MSG_WINDOW_FOCUS_CHANGED 0
MSG_WINDOW_FOCUS_CHANGED 1
mHardwareRenderer.initializeIfNeeded()#2 mSurface={isValid=true -405837824}
ViewPostImeInputStage processPointer 0
ClassLoader referenced unknown path: /system/framework/QPerformance.jar
BoostFramework() : Exception_1 = java.lang.ClassNotFoundException: Didn't find class "com.qualcomm.qti.Performance" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib, /vendor/lib]]
BoostFramework() : mPerf = null
ViewPostImeInputStage processPointer 1
Class anywheresoftware.b4a.objects.CameraW failed lock verification and will run slower.
Class anywheresoftware.b4a.objects.CameraW$2 failed lock verification and will run slower.
Class anywheresoftware.b4a.B4AThreadPool failed lock verification and will run slower.
Class anywheresoftware.b4a.objects.CameraW$CloseCamera failed lock verification and will run slower.
An error occurred while connecting to camera 0: Service not available
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.objects.CameraW$2.run(CameraW.java:114)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:762)
Caused by: java.lang.RuntimeException: Fail to connect to camera service
at android.hardware.Camera.<init>(Camera.java:519)
at android.hardware.Camera.open(Camera.java:364)
... 7 more
java.lang.reflect.InvocationTargetException
Relayout returned: oldFrame=[0,0][1080,1920] newFrame=[0,0][1080,1920] result=0x7 surface={isValid=true -739135488} surfaceGenerationChanged=true
EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000, [1080x1920]-format:1
mHardwareRenderer.updateSurface() mSurface={isValid=true -739135488}
onsize change changed
Relayout returned: oldFrame=[0,0][0,0] newFrame=[0,240][1080,1740] result=0x7 surface={Surface(name=null)/@0xbf28f9e isValid=true -739006464}
Relayout returned: oldFrame=[0,240][1080,1740] newFrame=[0,240][1080,1740] result=0x1 surface={Surface(name=null)/@0xbf28f9e isValid=true -741220352}
ThreadedRenderer.create() translucent=true
Input channel constructed: fd=78
setView = android.widget.LinearLayout{b21ba95 V.E...... ......I. 0,0-0,0} touchMode=true
dispatchAttachedToWindow
Relayout returned: oldFrame=[0,0][0,0] newFrame=[263,1595][817,1728] result=0x27 surface={isValid=true -739006464} surfaceGenerationChanged=true
mHardwareRenderer.initialize() mSurface={isValid=true -739006464} hwInitialized=true
EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000, [554x133]-format:1
MSG_RESIZED_REPORT: frame=Rect(263, 1595 - 817, 1728) ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
mHardwareRenderer.destroy()#4
dispatchDetachedFromWindow
Input channel destroyed: fd=78
Starting input: tba=android.view.inputmethod.EditorInfo@87407aa nm : camera.example ic=null
[IMM] startInputInner - mService.startInputOrWindowGainedFocus
Input channel constructed: fd=77
Input channel destroyed: fd=70
mHardwareRenderer.destroy()#4
dispatchDetachedFromWindow
Input channel destroyed: fd=66
** Activity (main) Pause, UserClosed = false **
Starting input: tba=android.view.inputmethod.EditorInfo@b393f9b nm : camera.example ic=null
[IMM] startInputInner - mService.startInputOrWindowGainedFocus
Input channel destroyed: fd=77
MSG_RESIZED_REPORT: frame=Rect(0, 0 - 1080, 1920) ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
Relayout returned: oldFrame=[0,0][1080,1920] newFrame=[0,0][1080,1920] result=0x1 surface={isValid=true -739135488} surfaceGenerationChanged=false
MSG_WINDOW_FOCUS_CHANGED 0
performDraw() was skipped by aod_show_state... DisplayState=3
performDraw() was skipped by aod_show_state... DisplayState=3
performDraw() was skipped by aod_show_state... DisplayState=3
MSG_RESIZED_REPORT: frame=Rect(0, 0 - 1080, 1920) ci=Rect(0, 72 - 0, 0) vi=Rect(0, 72 - 0, 0) or=1
Relayout returned: oldFrame=[0,0][1080,1920] newFrame=[0,0][1080,1920] result=0x1 surface={isValid=true -739135488} surfaceGenerationChanged=false
performDraw() was skipped by aod_show_state... DisplayState=3
performDraw() was skipped by aod_show_state... DisplayState=3
performDraw() was skipped by aod_show_state... DisplayState=3
performDraw() was skipped by aod_show_state... DisplayState=3
performDraw() was skipped by aod_show_state... DisplayState=3
performDraw() was skipped by aod_show_state... DisplayState=3
performDraw() was skipped by aod_show_state... DisplayState=3
performDraw() was skipped by aod_show_state... DisplayState=3
performDraw() was skipped by aod_show_state... DisplayState=3
performDraw() was skipped by aod_show_state... DisplayState=4
performDraw() was skipped by aod_show_state... DisplayState=4
performDraw() was skipped by aod_show_state... DisplayState=4
performDraw() was skipped by aod_show_state... DisplayState=4
performDraw() was skipped by aod_show_state... DisplayState=4
performDraw() was skipped by aod_show_state... DisplayState=4
performDraw() was skipped by aod_show_state... DisplayState=4
performDraw() was skipped by aod_show_state... DisplayState=4
performDraw() was skipped by aod_show_state... DisplayState=4
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
This is the relevant error: Caused by: java.lang.RuntimeException: Fail to connect to camera service

The latest version of CameraEx properly requests permission and it works with all Android versions. The error is not related to the Android version. It is possible that another app has locked the camera.

Worth testing with Camera2 which is a newer API.
 
Upvote 0
Top