Android Question Layout stopped loading - Runtime error

Discussion in 'Android Questions' started by FERNANDO SILVEIRA, Apr 16, 2018 at 9:22 PM.

Tags:
  1. FERNANDO SILVEIRA

    FERNANDO SILVEIRA 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:
    Code:
    '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(0xFFAFCDAF0xFFAFC6AF0xFF0000FF0xFFFF45000xFFDDA0DD))
        fundoRect.Initialize(
    10dip10dip10dip10dip)
        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
     

    Attached Files:

  2. OliverA

    OliverA Well-Known Member Licensed 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
    Code:
    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.
     
    FERNANDO SILVEIRA likes this.
  3. FERNANDO SILVEIRA

    FERNANDO SILVEIRA Member Licensed User

    Got you...
    Thank you very much.
     
Loading...