Android Question [SOLVED] Strange errors when compile to library from B4XPages

max123

Well-Known Member
Licensed User
Longtime User
Hi all,

some days ago I released the B4J WebGL Library

Now I'm happy to inform all users that I have almost completed writing the WebGL library for B4A.

Almost everything works, already some demos have been tested and works well on Android Emulator, at 50-60 FPS or less depending of the scene complexity.
I don't have a super PC, just a Ryzen7 minipc with integrated Vega 8 1.2Ghz video card, and the emulator consume 50-80% of CPU when render pretty complex full scenes, so this is really promising..... I have not yet tested on physical devices but I will do it soon.

Now, after everything works (almost) I have this big problem.
The library was developed on top of a B4XPages project, with the inline class everything works, but if I compile the class and then import it into
another instance of the IDE creating another new B4XPages project, when I compile I get this error:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
Initializing WebGL Library ...
Initialize => Parent: anywheresoftware.b4a.BA@73df597
[22:29:51] >>>>>>>> SetupWebChromeClient
java.lang.RuntimeException: java.lang.ClassNotFoundException: b4a.webgl$example$one$webgl$MyWebChromeClient
at anywheresoftware.b4a.keywords.Common$14.run(Common.java:1750)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8177)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
Caused by: java.lang.ClassNotFoundException: b4a.webgl$example$one$webgl$MyWebChromeClient
at anywheresoftware.b4j.object.JavaObject.getCorrectClassName(JavaObject.java:289)
at anywheresoftware.b4j.object.JavaObject.InitializeNewInstance(JavaObject.java:84)
at b4a.example.webgl._setupwebchromeclient(webgl.java:3156)
at b4a.example.webgl._initialize(webgl.java:2345)
at b4a.example.b4xmainpage$ResumableSub_Button1_Click.resume(b4xmainpage.java:83)
at anywheresoftware.b4a.keywords.Common$14.run(Common.java:1748)
... 8 more
It seem do not find the class where I initialize some stuff in native Java.
And this is the log if I compile in Debug mode:
Copying updated assets files (4)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Error occurred on line: 359 (B4XPagesManager)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:1087)
at b4a.webgl.example.one.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:1068)
at b4a.webgl.example.one.b4xpagesmanager._showpage(b4xpagesmanager.java:425)
at b4a.webgl.example.one.b4xpagesmanager._addpage(b4xpagesmanager.java:245)
at b4a.webgl.example.one.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:259)
at b4a.webgl.example.one.b4xpagesmanager._initialize(b4xpagesmanager.java:165)
at b4a.webgl.example.one.main._activity_create(main.java:415)
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:157)
at b4a.webgl.example.one.main.afterFirstLayout(main.java:105)
at b4a.webgl.example.one.main.access$000(main.java:17)
at b4a.webgl.example.one.main$WaitForLayout.run(main.java:83)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8177)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
Caused by: java.lang.RuntimeException: java.lang.Exception: Sub B4XPage_Created signature does not match expected signature.
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:336)
at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:285)
... 25 more
Caused by: java.lang.Exception: Sub B4XPage_Created signature does not match expected signature.
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:321)
... 26 more
** Activity (main) Resume **

Please someone know how to get it working ?

As explained, with inline class it works, but after compiling as library it does not works.
I even Jetified the library with Jetifier tool in the B4A IDE.

The problem seem to be the library, not the project code itself, the code is simple and it works with inline class.
If in a new blank B4XPages project I compile without checking in the libraries tab the WebGL library, it compiles a default project template,
if I just check the library in the library tab, without write any code, this error happen.

Thanks for any help
 
Last edited:

max123

Well-Known Member
Licensed User
Longtime User
Thanks for reply @Erel

(The jetifier is a thing of the past - never required with the new toolchain).
Please where I can find some posts that explain this ?

For the problem I solved it this way:
B4X:
'    WebChromeClient.InitializeNewInstance(Application.PackageName & ".webgl$MyWebChromeClient", Null) ' Original not working when compiled to library
 
    ' Changed to ...
    Dim PackageName As String = GetType(Me)
    Log("Library package: " & PackageName)' b4a.example.webgl
    WebChromeClient.InitializeNewInstance(PackageName & "$MyWebChromeClient", Null)
Now it seem to work even when compiled to library and imported in a new project.

Now I found some other issues related to the fact that the library copy files (threejs distribution zip) from assets to DirInternal (different in B4J WebGL library where user place the files manually to DirData inside developing machine) that will not work, even this works with inline class but do not when compiled and used in a new project,
but eventually I will open a new thread for these questions.

I'm not sure how the library is organized, but it will be simpler to build a b4xlib library instead of compiling the code. It is a matter of zipping the classes and changing the extension to b4xlib
The library is just a single class.

The B4J WebGL library is free of use for all users, but because the B4A WebGL library is a lot more complex and required me more than 600 hours to develop (and not yet finished) I want release this as donationware, so I cannot build a b4xlib library, this time I need to protect code and my very long work.

Even the B4J WebGL Library is free, but the code is not public, because it required me 400 and more hours of work.
All these required a very big work.

I released more free code on this forum, but that required less work. I cannot do the same this time.
May in future I will release B4J WebGL source code.

Thanks for your your advices. I wish you Happy New Year ;)
Max
 
Last edited:
Upvote 0
Top