To make changing UI colors easier, I've set tags on some (not all) views on a screen, and using those to set the colors in code.
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
But *sometimes* (though not always), the app crashes when it gets to the first test (I've identified line 643 above, which is where the crash occurs). The java log dump from the crash seemed to indicate a null pointer issue, so I put the check for null, but it doesn't change...
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
I said "sometimes", because occasionally it won't crash. It seems like the crash occurs after if finds a BALayout view, but I'm not sure how to show more specifics of that view to better identify what and why it's doing this? Not sure if I'm missing something here, or if it's a bug.
Either way, is there a workaround to this?
Thanks.
			
			
			
				B4X:
			
		
		
		Private Sub SetupUIColors_MainPage
    For Each v As B4XView In Root.GetAllViewsRecursive
           Log(v)
        If v <> Null Then
            If v.Tag = "BG0" Then                             ' THIS IS LINE 643 IN THE CRASH DUMP
                v.Color = Colors.ARGB(0xFF, 14, 10, 8)
            Else if v.Tag = "BG1" Then
                v.Color = Colors.ARGB(0xFF, 35, 28, 25)
            Else if v.Tag = "BG2" Then
                v.Color = Colors.ARGB(0xFF, 44, 40, 38)
            Else if v.Tag = "T0" Then
                v.TextColor = Colors.ARGB(0xFF, 0xFF, 0xFF, 0xFF)
            Else if v.Tag = "T1" Then
    '            v.TextColor = Colors.ARGB(0xFF, 96, 255, 187)
                v.TextColor = Colors.ARGB(0xFF, 255, 255, 255)
            End If
        End If
    Next
End SubBut *sometimes* (though not always), the app crashes when it gets to the first test (I've identified line 643 above, which is where the crash occurs). The java log dump from the crash seemed to indicate a null pointer issue, so I put the check for null, but it doesn't change...
			
				Crash dump:
			
		
		
		** Service (starter) Start **
** Activity (main) Create, isFirst = true **
(TextView) android.widget.TextView{f4e8450 V.ED..... ......ID 0,0-0,0 #3}
(MyScrollView) anywheresoftware.b4a.objects.ScrollViewWrapper$MyScrollView{4abe88b VFED.V... ......I. 0,0-0,0 #4}
(BALayout) anywheresoftware.b4a.BALayout{920d8c9 V.E...... ......ID 0,0-0,0}
Error occurred on line: 643 (B4XMainPage)
java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:1055)
    at PiPi.eta.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:1064)
    at PiPi.eta.b4xpagesmanager._showpage(b4xpagesmanager.java:421)
    at PiPi.eta.b4xpagesmanager._addpage(b4xpagesmanager.java:249)
    at PiPi.eta.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:263)
    at PiPi.eta.b4xpagesmanager._initialize(b4xpagesmanager.java:169)
    at PiPi.eta.main._activity_create(main.java:589)
    at java.lang.reflect.Method.invoke(Native Method)
    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.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at PiPi.eta.main.afterFirstLayout(main.java:105)
    at PiPi.eta.main.access$000(main.java:17)
    at PiPi.eta.main$WaitForLayout.run(main.java:83)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:215)
    at android.app.ActivityThread.main(ActivityThread.java:6939)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:336)
    at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:285)
    ... 24 more
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:318)
    ... 25 more
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Object.equals(java.lang.Object)' on a null object reference
    at PiPi.eta.b4xmainpage._setupuicolors_mainpage(b4xmainpage.java:765)
    at PiPi.eta.b4xmainpage._b4xpage_created(b4xmainpage.java:656)
    ... 27 more
** Activity (main) Resume **I said "sometimes", because occasionally it won't crash. It seems like the crash occurs after if finds a BALayout view, but I'm not sure how to show more specifics of that view to better identify what and why it's doing this? Not sure if I'm missing something here, or if it's a bug.
Either way, is there a workaround to this?
Thanks.
 
				 
 
		 
 
		 
 
		