Android Question NOT SOLVED Issue in Camera Preview

tigrot

Well-Known Member
Licensed User
Longtime User
Hi to Everybody,
does anybody have my same problem?
I need to take pictures. This works ok, but if I start the APP and start the pictures' capture i this error stack:
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
at dalvik.system.NativeStart.main(Native Method)
java.lang.NoSuchMethodException: getPreviewSize
java.lang.NoSuchMethodException: getPreviewSize
at java.lang.ClassCache.findMethodByName(ClassCache.java:247)
at java.lang.Class.getDeclaredMethod(Class.java:731)
at anywheresoftware.b4a.agraham.reflection.Reflection.runmethod(Reflection.java:214)
at anywheresoftware.b4a.agraham.reflection.Reflection.RunMethod(Reflection.java:802)
at com.YourPersonalAssistantTest.app.cameraexclass._vvvvvvvvvvvvvvvvvvvv4(cameraexclass.java:416)
at com.YourPersonalAssistantTest.app.camera._camera1_preview(camera.java:382)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:174)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:858)
at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:815)
at com.YourPersonalAssistantTest.app.cameraexclass._camera_preview(cameraexclass.java:93)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:174)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:158)
at anywheresoftware.b4a.objects.CameraW$2$1$1.onPreviewFrame(CameraW.java:147)
at android.hardware.Camera$EventHandler.handleMessage(Camera.java:589)
at android.os.Handler.dispatchMessage(Handler.java:99)
at anywheresoftware.b4a.Msgbox.waitForMessage(Msgbox.java:197)
at anywheresoftware.b4a.Msgbox.msgbox(Msgbox.java:136)
at anywheresoftware.b4a.BA.ShowErrorMsgbox(BA.java:221)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:201)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:858)
at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:815)
at com.YourPersonalAssistantTest.app.cameraexclass._camera_preview(cameraexclass.java:93)



The logic to get preview and the picture is on a second activity. I issue activity.finish to terminate the second activity. Then I start again main. It connects for many times, does the work and then disconnects. I can quickly repeat the process and it seems to work very well. Then comes the issue. The stack dumps continuosly without interruption the text in red above and on phone's screen a question is shown:
Error occurred:
An Error has occurred in sub:
java.lang.NoSuchMethodException:
getPreviewSize
Continue?


If I click NO the program resets and everything starts again! The issue solves itself...

Have someone an hint for me?

Thank you!

Mauro

Mauro
 

tigrot

Well-Known Member
Licensed User
Longtime User
Hi everybody. I probably solved the issue.
My App is two Activity: one is a menu, the other shows a picture preview and sends the photos. When I FINISH the second activity I use method CloseNow of cameraEx class, so the camera is reset. Probably exiting the activity, camera was left in a not reusable status, till the code was in memory... I used StopPreview and Release, but it was not enough!
It was my feeling from the beginning...


Ciao and Excuse me for boring you!

Mauro
 
Upvote 0

tigrot

Well-Known Member
Licensed User
Longtime User
Upvote 0

tigrot

Well-Known Member
Licensed User
Longtime User
I was not able to reproduce the issue with the example. CloseNow seemed to fix the issue, like a reset, you must learn to swimm if you drop in the river!
Could it be an issue about a double instancing of the camera driver?
An Error has occurred in sub:
java.lang.NoSuchMethodException:
getPreviewSize
Continue?

I have seen that the error happens when I call PreviewImageToJpeg from the event preview

Ciao
Mauro
 
Upvote 0

tigrot

Well-Known Member
Licensed User
Longtime User
After tests I have seen that the failing call was CameraEx PreviewImageToJpeg . It fails at first reflection call.
I call it to convert the preview to Jpeg. I recreate the CameraEx at every preview start. Sometimes it's able to convert, sometimes it isn't.
I sorrounded the call in a try so I can ignore the error. The APP is never terminated,
 
Upvote 0
Top