Android Question Layout stopped loading - Runtime error

FERNANDO SILVEIRA

Active Member
Licensed User
I was working on this layout and, between changes, I don't know why started presenting this error.

Line 30 ==> Parent.LoadLayout("Drawing")

  • Error occurred on line: 30 (Drawings)
  • java.lang.RuntimeException: java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.reflect.Type[] java.lang.reflect.ParameterizedType.getActualTypeArguments()' on a null object reference
  • at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
Drawings module:
B4X:
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(Parent As B4XView)
    Parent.LoadLayout("Drawing")
    canvas.Initialize(pnlDrawing)
'                        Colors:        (0)Fundo0   (1)Fundo1   (2)Snake    (3)Bird     (4)vago
    wColors.Initialize2(Array As Int(0xFFAFCDAF, 0xFFAFC6AF, 0xFF0000FF, 0xFFFF4500, 0xFFDDA0DD))
    fundoRect.Initialize(10dip, 10dip, 10dip, 10dip)
    pnlDrawing.Top = 0
    pnlDrawing.left = 0
    wLineWidth = pnlDrawing.Width - wMargin
    wColumnHeight = pnlDrawing.Height - wMargin - wBottonMargin
    wMaxColumns = (wLineWidth / (wCellSize + wGridLine)) - 1
    wMaxLines = (wColumnHeight / (wCellSize + wGridLine)) - 2
    pnlKeys.left = (pnlDrawing.width - 95dip) / 2
    Log("Gridsize: " & wMaxColumns & ", " & wMaxLines)
   
    SnakeSize = 1
    SnakeDir = KEY_RIGHT        ' 1=Up    2=Down    3=Left    4=Right    0=Stop
    TabSnakeCell(0) = GetCell(Rnd(5, wMaxLines - 5), wMaxColumns)
    TabSnakeDir(0) = KEY_RIGHT
   
    PlotBird
    PlotSnake
    SnakeMove
End Sub


Any clues, will be welcome.
Regards,
Fernando
 

Attachments

  • APP07 Snake.zip
    20.2 KB · Views: 325

OliverA

Expert
Licensed User
Longtime User
Looks like naming your constants the same name as the ImageView(s) used in your layout file (even though they are cased differently) caused the issues. I just renamed your constants
B4X:
Public const cKEY_UP As Int = 1
Public const cKEY_DOWN As Int = 2
Public const cKEY_LEFT As Int = 3
Public const cKEY_RIGHT As Int = 4
Public const cKEY_STOP As Int = 0
throughout the class and everything worked.
 
Upvote 0
Top