B4J Question MergeLibraries break my lib

Pendrush

Well-Known Member
Licensed User
Longtime User
#MergeLibraries: False = I can run app in Release mode
#MergeLibraries: True = App crash in Release mode

Stacktrace:
java.lang.RuntimeException: java.lang.StringIndexOutOfBoundsException: Range [0, -1) out of bounds for length 7
at anywheresoftware.b4a.keywords.Common$2$1.run(Common.java:1052)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
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:184)
at java.base/java.lang.Thread.run(Thread.java:1589)
Caused by: java.lang.StringIndexOutOfBoundsException: Range [0, -1) out of bounds for length 7
at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:55)
at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:52)
at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:213)
at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:210)
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:98)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckFromToIndex(Preconditions.java:112)
at java.base/jdk.internal.util.Preconditions.checkFromToIndex(Preconditions.java:349)
at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4602)
at java.base/java.lang.String.substring(String.java:2715)
at org.openqa.selenium.manager.SeleniumManager.<init>(SeleniumManager.java:81)
at org.openqa.selenium.manager.SeleniumManager.getInstance(SeleniumManager.java:107)
at org.openqa.selenium.remote.service.DriverFinder.<init>(DriverFinder.java:45)
at org.openqa.selenium.chrome.ChromeDriver.generateExecutor(ChromeDriver.java:98)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:88)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:83)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:72)
at com.pendrush.selenium.kotlin.SeleniumLib.initialize(SeleniumLib.kt:42)
at com.pendrush.selenium.Wrapper.initialize2(Wrapper.java:80)
at com.pendrush.selenium.Wrapper.Initialize(Wrapper.java:76)
at b4j.example.main$ResumableSub_AppStart.resume(main.java:92)
at anywheresoftware.b4a.keywords.Common$2$1.run(Common.java:1050)
... 7 more

Line 42 in wrapper lib:
Java:
private val options = ChromeOptions() // <- global declaration
driver = ChromeDriver(options)        // <- error line 42 from stacktrace: at com.pendrush.selenium.kotlin.SeleniumLib.initialize(SeleniumLib.kt:42)

The error is completely unrelated... I cannot get it.

This behavior also create unusable app with standalone package.

Library:

I need to build standalone package, any solution?
 

Pendrush

Well-Known Member
Licensed User
Longtime User
After some research, I found that some files from my library were not copied into the JAR file that was compiled in release mode with flag #MergeLibraries: True.
If I copy ALL the files from my kotlin-selenium-all.jar library, WITHOUT overwriting, into the compiled JAR everything works fine.

You can also see the difference in the size of the files, it is obvious that something is also missing in the Release JAR:

My Library:
B4X:
Pnd_Selenium.xml              70,210
Pnd_Selenium.jar               6,457
kotlin-selenium-all.jar   30,139,004

Release JAR (#MergeLibraries: True):
B4X:
Selenium7.jar             26,156,717

Any solution?
 
Last edited:
Upvote 0

Pendrush

Well-Known Member
Licensed User
Longtime User
2940 Files are missing in Release Jar.
PDF with folders and file names is attached to this post.
 

Attachments

  • 2940MissingFilesInReleaseJar.zip
    454 KB · Views: 5
Upvote 0
Top