B4J Question [BANANO] java.lang.RuntimeException: Object should first be initialized (Map).

Alexander Stolte

Expert
Licensed User
Longtime User
Hey,

i wanted to create my 1st test project, so I created a UI project and took the main code from this example:
When I start the project now, banano crashes at this point:
B4X:
BANano.Build(File.DirApp)
With this error:
Error occurred on line: 24 (Main) java.lang.RuntimeException: Object should first be initialized (Map). at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:49) at anywheresoftware.b4a.objects.collections.Map.getSize(Map.java:131) at com.ab.banano.BANano.PrepareLayout(Unknown Source) at com.ab.banano.BANano.a(Unknown Source) at com.ab.banano.BANano.a(Unknown Source) at com.ab.banano.BANano.Build(Unknown Source) at b4j.example.main._appstart(main.java:82) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:109) at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98) at anywheresoftware.b4a.BA.raiseEvent(BA.java:96) at b4j.example.main.start(main.java:38) at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428) at java.base/java.security.AccessController.doPrivileged(Native Method) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427) at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96) at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174) at java.base/java.lang.Thread.run(Thread.java:834)ΩΩ:
Error occurred on line: 24 (Main)
java.lang.RuntimeException: Object should first be initialized (Map).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:49)
    at anywheresoftware.b4a.objects.collections.Map.getSize(Map.java:131)
    at com.ab.banano.BANano.PrepareLayout(Unknown Source)
    at com.ab.banano.BANano.a(Unknown Source)
    at com.ab.banano.BANano.a(Unknown Source)
    at com.ab.banano.BANano.Build(Unknown Source)
    at b4j.example.main._appstart(main.java:82)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:109)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:96)
    at b4j.example.main.start(main.java:38)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
    at java.base/java.lang.Thread.run(Thread.java:834)
What i'm doing wrong?
Project is attached.
 

Attachments

  • Banano First.zip
    28.1 KB · Views: 129

Mashiane

Expert
Licensed User
Longtime User
1. Please run one of the examples from the BANano Download that is based on the SkeletonUI that Alain did.

The attached project im sorry to say, it does nothing, because there is no code in Main.BANano_Ready.

2. Copy the Skeleton library from BANAno download to your external libraries and reference it in your project, you will have custom components to add via the abstract designer. You can drag and drop these on a layout and use BANano.LoadLayout to load them.

3. Do you want to learn how to create a BANAno library / create an BANano app?
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
1. Please run one of the examples from the BANano Download that is based on the SkeletonUI that Alain did.
I've already done that, but I want to start from 0 and work my way up step by step.
3. Do you want to learn how to create a BANAno library / create an BANano app?
BANano apps, yes

The attached project im sorry to say, it does nothing, because there is no code in Main.BANano_Ready.
But your code does not work too
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
But your attached project works.
Fine, but I don't know what you configured differently than I did.
 
Upvote 0

Mashiane

Expert
Licensed User
Longtime User
But your attached project works.
Are you referring to the DummiesLikeMe01 example?

The code you are using is for building a BANano Library and is different from the working project you are referring to in the DummiesLikeMe01 example and also different from the BANano download\Demo that has been done.

Your Code

B4X:
Sub AppStart (Form1 As Form, Args() As String)
    ' you can change some output params here
    BANano.Initialize("BANano", "BANanoSkeleton",12)
    BANano.HTML_NAME = "index.html"
 
    BANano.Header.Title="BANano Skeleton"
    BANano.ExternalTestConnectionServer = "http://gorgeousapps.com"
    BANano.Header.AddCSSFile("skeleton-all.min.css")
 
    ' start the build
   #if release
       BANano.BuildAsLibrary()
   #else
    BANano.Build(File.DirApp)
   #end if
 
    ExitApplication
End Sub

' HERE STARTS YOUR APP
Sub BANano_Ready()

End Sub

This is my code from the DummiesLikeMe01 Main Module

B4X:
Sub AppStart (Form1 As Form, Args() As String)
    'initialize banano object with event, appname (must not have space) and version
    BANano.Initialize("BANano", "MyApp",DateTime.now)
    'the name of the html file
    BANano.HTML_NAME = "index.html"
    'the title of the page
    BANano.Header.Title = "MyApp"
    'do not use service workers for PWA
    BANano.TranspilerOptions.UseServiceWorker = False
    'transpile b4j code to html, css and javascript and store output in File.DirApp
    'the webiste/website will be loaded in \Objects\MyApp where you saved your project
    BANano.Build(File.dirApp)
    'open the compiled index file
    Dim URL As String = File.GetUri(File.Combine(File.dirapp,"MyApp"),"index.html")
    fx.ShowExternalDocument(URL)
    ExitApplication
End Sub

'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub

Sub BANano_Ready
    '****javascript****
    'var body = document.getElementById("body");
    'var.innerHTML = 'Hello Alain Bailleul!';
    
    '****jquery****
    'var body = $("#body");
    'body.append("Hello Alain Bailleul!");
    
    '****banano****
    Dim body As BANanoElement = BANano.GetElement("#body")
    body.Append("Hello Alain Bailleul!")
End Sub

And it shows..

1637274282818.png


As a start, rather structure your AppStart code the same way Alain did it in the BANano Download\Demo folder. You can also run his examples e.g. Website demo on how he has structured his apps.

All the best
 
Upvote 0
Top