Bug? IDE doesn't warn about missing libs when only referenced in layout

Sandman

Expert
Licensed User
Longtime User
(This post has a B4i companion here.)

Let's say you have a library that is a view. (Example: AS Checkbox, which is what I used when I found this issue.)

Add that view to a layout but don't reference it in code anywhere.

Disable the library in the Libraries Manager.

The IDE will not warn about a missing library.

The IDE will happily compile the project without complaining about the missing library.

If compiled as Debug, at app launch, an exception happens that seems unrelated:
B4X:
java.lang.RuntimeException: Unable to create service my.fine.app.starter: java.lang.RuntimeException: java.io.EOFException
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:4498)
    at android.app.ActivityThread.-$$Nest$mhandleCreateService(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2161)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7872)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Caused by: java.lang.RuntimeException: java.io.EOFException
    at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:164)
    at anywheresoftware.b4a.shell.Shell.start(Shell.java:102)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:105)
    at io.hardhat.id06.starter.onCreate(starter.java:34)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:4485)
    ... 9 more
Caused by: java.io.EOFException
    at java.io.DataInputStream.readFully(DataInputStream.java:205)
    at java.io.DataInputStream.readInt(DataInputStream.java:394)
    at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:136)
    ... 13 more

If compiled as Release, the app crashes when trying to load the layout.

It seems reasonable that the IDE should warn about missing library references, even if they are in layouts. The absolutely bare minimum would be that it complain about the missing reference during compilation and stop the compilation process.
 

Sandman

Expert
Licensed User
Longtime User
Once again I got bitten by this. At no point did the IDE inform me that a custom view was used in a layout and not enabled in the libraries manager.

And now users are posting bad ratings because my app is crashing for them.
 

Sandman

Expert
Licensed User
Longtime User
This is not exactly a bug and also not trivial to implement due to the structure of the layout files, without decoding the full layout during compilation.
I don't want to sidetrack this thread, I'll just note there has been several wishes over the years to change the internal format to json instead of the binary format. (Which would also be highly appreciated by people working with git, or the like. Binary blobs aren't great for diffing, for instance.)

I need to think about this...
Thanks, appreciated. I do understand it's complex.

(As it is now, I'm weighing my options and considering making a custom script to be run as part of the compilation, that parse the layouts and check with the source code. It doesn't really fill me with joy. 😓)
 

aeric

Expert
Licensed User
Longtime User
My point of views are:

  1. The library developer should listed the dependencies in the first post and post some notes
  2. The developer who want to consume the library should read and understand the library requirements
  3. If he doesn't clear, he should ask the library developer
  4. The most important thing is do countless time of test before making the app to production
 
Top