Android Question Can not run Camera Application

junaidahmed

Well-Known Member
Licensed User
Longtime User
I am going to create Camera application from "https://www.b4x.com/android/forum/t...e-camera-library-functionality.23801/#content". but when I run this application it shows an error message as

Logger connected to: LENOVO Lenovo A2010-a
--------- beginning of main
--------- beginning of system
Copying updated assets files (1)
** Activity (main) Create, isFirst = true **
autoversion: 117.0
compilation time: 02/19/2018 18:55:24
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (entry) Create, isFirst = true **
** Activity (entry) Resume **
** Activity (entry) Pause, UserClosed = false **
** Activity (entry) Create, isFirst = false **
** Activity (entry) Resume **
** Activity (entry) Pause, UserClosed = false **
** Activity (entry) Create, isFirst = false **
** Activity (entry) Resume **
Error occurred on line: 27 (CameraExClass)
java.lang.ClassCastException: android.widget.TextView cannot be cast to android.view.SurfaceView
at anywheresoftware.b4a.objects.CameraW.shared(CameraW.java:97)
at anywheresoftware.b4a.objects.CameraW.Initialize(CameraW.java:52)
at com.cabinet.cameraexclass._initialize(cameraexclass.java:255)
at com.cabinet.entry._initializecamera(entry.java:845)
at com.cabinet.entry._imgcamera_click(entry.java:829)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:4848)
at android.view.View$PerformClick.run(View.java:20260)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5624)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
 

DonManfred

Expert
Licensed User
Longtime User
Error occurred on line: 27 (CameraExClass)
java.lang.ClassCastException: android.widget.TextView cannot be cast to android.view.SurfaceView
you should use a PANEL instead of a LABEL for the preview surface.

Check the example!

PD: Hiding your code DOES NOT HELP us to help you! Export your project as zip and upload the project.
 
Last edited:
Upvote 0
Top