Android Question Problems with Camera2 on older devices

Cadenzo

Active Member
Licensed User
Longtime User
I am using Camera2 (Version1.11) and CamEx2 (Version: 1.30, also tried 1.20) in a small project and it works fine for my new devices. But in the test with many older devices it crashes here in line 6, also in this example-code:
Main in Camera2 example:
Sub Activity_Create(FirstTime As Boolean)
    VideoFileDir = rp.GetSafeDirDefaultExternal("")
    VideoFileName = "1.mp4"
    Activity.LoadLayout("1")
    Activity.LoadLayout("StillPicture")
    cam.Initialize(pnlCamera)
    Log(cam.SupportedHardwareLevel)
    buttons = Array(btnScene, btnAutoExposure, btnEffects, btnFocus, btnMode)
    SetState(False, False, VideoMode)
End Sub
Even, if I remove all lines in CamEx2: Public Sub Initialize (CameraPanel As Panel) it gives the same error:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 3 (CamEx2)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at b4a.example3.camex2.innerInitialize(camex2.java:21)
at b4a.example3.camex2._initialize(camex2.java:67)
at b4a.example3.main._activity_create(main.java:416)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at b4a.example3.main.afterFirstLayout(main.java:104)
at b4a.example3.main.access$000(main.java:17)
at b4a.example3.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:800)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5371)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.VerifyError: anywheresoftware/b4a/objects/Camera2
at b4a.example3.camex2._class_globals(camex2.java:1289)
... 25 more
** Activity (main) Resume **

Another thing: The original example ended on this old devices with this compiler error:
Installing file to device. Error
Performing Push Install
Camera2_RAPID_DEBUG.apk: 1 file pushed. 7.7 MB/s (1137893 bytes in 0.141s)
pkg: /data/local/tmp/Camera2_RAPID_DEBUG.apk
Failure [INSTALL_FAILED_OLDER_SDK]

Only, when I set in Manifest Editor to android:minSdkVersion="5", what is default in new projects, it gives this first error.
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Cadenzo

Active Member
Licensed User
Longtime User
OK, thanks for the info and this quick response. So I have to find another solution for older devices.
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
Maybe this one:

CameraEx class requires Android 2.3+ and depends on Camera library v2.20+
 
Upvote 0

Cadenzo

Active Member
Licensed User
Longtime User
Super hint, thanks, I hope, that it will be possible, to integrate it in the app and to use instead, if it is an older OS version.
 
Last edited:
Upvote 0
Top