Java Question Error on Android 4.0.3 (ICS)

Johan Schoeman

Licensed User
Longtime User
I have a project posted somewhere on the forum called AndroidVideoCapture. It is working on KitKat as far as up to Oreo but does not work on Android 4.0.3 (ICS)

Have added some logs to the wrapper code to see where it goes and does no go and the below is the error message in the B4A log:
Installing file.
** Activity (main) Pause, UserClosed = false **
PackageAdded: package:JHS.AndroidVideoCapture
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
in _initialize
in getAudioManagerStreams
in hasCamera
in DesignerCreateView
in AddToParent
Error occurred on line: 38 (Main)
java.lang.RuntimeException: java.lang.NullPointerException
   at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(
   at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(
   at anywheresoftware.b4a.ShellBA.raiseEvent2(
   at JHS.AndroidVideoCapture.main.afterFirstLayout(
   at JHS.AndroidVideoCapture.main.access$000(
   at JHS.AndroidVideoCapture.main$
   at android.os.Handler.handleCallback(
   at android.os.Handler.dispatchMessage(
   at android.os.Looper.loop(
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(
   at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
   at android.view.ViewGroup.addViewInner(
   at android.view.ViewGroup.addView(
   at android.view.ViewGroup.addView(
   at videowrapper.videoWrapper.AddToParent(
   at videowrapper.videoWrapper.DesignerCreateView(
   at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(
   at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(
   ... 21 more

As said, I have added numerous logs and it seems to be crashing in AddToParent:
    //programmatically add view
    public void AddToParent(ViewGroup Parent, @Pixel int left, @Pixel int top, @Pixel int width, @Pixel int height) {
        BA.Log("in AddToParent");
        Parent.addView(cv, new BALayout.LayoutParams(left, top, width, height));
        BA.Log("out AddToParent");
    //this method cannot be hidden.
    public void DesignerCreateView(PanelWrapper base, LabelWrapper lw, anywheresoftware.b4a.objects.collections.Map props) {
        BA.Log("in DesignerCreateView");
        ViewGroup vg = (ViewGroup) base.getObject().getParent();
        AddToParent(vg, base.getLeft(), base.getTop(), base.getWidth(), base.getHeight());
        BA.Log("out DesignerCreateView");
        //set text properties

It logs the in DesignerCreateView and then also the in AddToParent but it does not log out AddToParent. Any idea what could cause this not to be working on ICS?