Java Question Error on Android 4.0.3 (ICS)

Johan Schoeman

Expert
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:
B4X:
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(LayoutBuilder.java:170)
   at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:735)
   at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:360)
   at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:260)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
   at JHS.AndroidVideoCapture.main.afterFirstLayout(main.java:104)
   at JHS.AndroidVideoCapture.main.access$000(main.java:17)
   at JHS.AndroidVideoCapture.main$WaitForLayout.run(main.java:82)
   at android.os.Handler.handleCallback(Handler.java:605)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:137)
   at android.app.ActivityThread.main(ActivityThread.java:4424)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
   at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
   at android.view.ViewGroup.addViewInner(ViewGroup.java:3336)
   at android.view.ViewGroup.addView(ViewGroup.java:3208)
   at android.view.ViewGroup.addView(ViewGroup.java:3188)
   at videowrapper.videoWrapper.AddToParent(videoWrapper.java:212)
   at videowrapper.videoWrapper.DesignerCreateView(videoWrapper.java:222)
   at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:70)
   at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
   ... 21 more

As said, I have added numerous logs and it seems to be crashing in AddToParent:
B4X:
    //programmatically add view
        @Hide
    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());
        base.RemoveView();
        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?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…