Android Question SOLVED java.lang.NullPointerException: null receiver

gregorio_adrian_gimenez

Active Member
Licensed User
Longtime User
java.lang.NullPointerException: null receiver
hello I'm going crazy to find what is the error that generates this problem.
Does anyone know a trick to identify exactly which record generates the error? because I can not locate it

the error is generated in line 337 but the problem is not really there

This error is being generated when inserting a record in customlistview.


Error occurred on line: 337 (chat_com)
java.lang.NullPointerException: null receiver
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:348)
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 anywheresoftware.b4a.BA$2.run(BA.java:387)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7091)
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:975)
** Receiver (firebasemessaging) OnReceive **
Cannot start from a receiver in debug mode.

B4X:
Sub CLV_VisibleRangeChanged (firstIndex As Int, LastIndex As Int)


    Dim ExtraSize As Int = 10
    For i = Max(0, firstIndex - ExtraSize) To Min(LastIndex + ExtraSize, CLV.Size - 1)
        
        Dim p As B4XView = CLV.GetPanel(i)

        If i > firstIndex - ExtraSize And i < LastIndex + ExtraSize Then
            
            
            If p.NumberOfViews = 0 Then
                
                    
                Dim mapa_mensaje1 As Map
                mapa_mensaje1.Initialize
                mapa_mensaje1= CLV.GetValue(i)
  Log(mapa_mensaje1)
                ' insertar la fecha
 
                DateTime.DateFormat ="dd/MM/yyyy"
                
                If DateTime.Date(DateTime.Now) <> DateTime.Date( mapa_mensaje1.Get("date")) Then
                    
                    Dim fecha As Label
                    fecha.Initialize("fecha")
                    fecha.Typeface = Typeface.SANS_SERIF
                    fecha.Text = DateTime.Date(mapa_mensaje1.Get("date"))
                    fecha.TextSize = 14
                    fecha.TextColor = Colors.Black
                    fecha.Textsize = fecha.TextSize/access.GetUserFontScale
                    fecha.BringToFront
                    fecha.Color = Colors.ARGB(180,25,208,35)
                    fecha.Gravity = Gravity.CENTER
                    
                    Dim cd As ColorDrawable
                    cd.Initialize2(Colors.ARGB(100,230,230,230), 5dip, 2dip, Colors.ARGB(100,230,230,230))
                    fecha.Background = cd
                    
                    p.AddView(fecha,35%x,0%y,30%x,4.5%y)
                    
                    top_fecha = 4.5%y
                
                Else
                top_fecha = 0%y
                
                End If

                If  clv_map.Get("prefijo_origen") = mapa_mensaje1.Get("prefijo_origen") Then
                    Label_texto.Initialize("label_texto")
                    Label_texto.TextSize = 17
                    Label_texto.TextSize = Label_texto.TextSize/access.GetUserFontScale
                    Label_texto.SingleLine = False
                    Label_texto.Typeface = Typeface.SANS_SERIF
                    Label_texto.Color = Colors.ARGB(255,226,226,226)
                    Label_texto.Padding=Array As Int (5dip, 2dip, 5dip, 2dip)
                
                    Dim cd As ColorDrawable
                    cd.Initialize(Colors.ARGB(250,208,201,244)    , 10dip)
                    Label_texto.Background= cd
                
                        Label_texto.Text = mapa_mensaje1.Get("mensaje")
                    
                
                  p.AddView(Label_texto,0.15%x,0.5%y + top_fecha,75%x,3%y)
        
                
            
                    Label_texto.Height=su.MeasureMultilineTextHeight(Label_texto,Label_texto.Text) +2.5%y
                
                    If Tamano_TextoHorizontal(Label_texto,Label_texto.Text) < 70%x Then
                        Label_texto.Width = Tamano_TextoHorizontal(Label_texto,Label_texto.Text)+3%x
                        Label_texto.SingleLine = True
                    
                        Label_texto.Left = 100%x-Label_texto.Width-10%x
            
                    Else
                        Label_texto.SingleLine = False
                        Label_texto.Left = 100%x-Label_texto.Width-10%x
                
                    End If

                Else
                
                p.Color = Colors.Transparent
    
                p.Visible = True
                CLV.ResizeItem(i,p.Height)
            
                'ScrollToLastItem
            
        End If

        Else
            'not visible
          ' If p.NumberOfViews > 0 Then
          '     p.RemoveAllViews '<--- remove the layout
        'End If
    End If
Next
    
                

End Sub
 

gregorio_adrian_gimenez

Active Member
Licensed User
Longtime User
Does it also happen in release mode? If so then please post the logs.

I highly recommend you to use the designer to create the item layout. It will be much simpler (and cross platform).

Hello, if in release mode the same thing happened. But it was solved in a strange way, I deleted the code and started to insert the code again and it did not generate the error. The only different thing I did was this, but I don't think it was that.

B4X:
                Dim tel_origen As String = clv_map.Get("prefijo_tel_origen")

                Dim tel_origen_enviado As String =mapa_mensaje1.Get("prefijo_tel_origen")
    
                If  tel_origen = tel_origen_enviado Then
                
                else
                
                end if

Regarding the use of the designer, I found that loading the customlistview is slower when inserting a layout and that is why I chose this option, is it wrong?

Thank you very much for the help
 
Upvote 0
Top