Android Question error: code too large

hi
I get this error when compiling, I have a lot of code and it is mostly in Webview. what should I do?

B4A Version: 10.0 Java Version: 11 Parsing code. (0.34s) Building folders structure. (0.03s) Compiling code. (0.31s) Compiling layouts code. (0.00s) Organizing libraries. (0.00s) (AndroidX SDK) Generating R file. (0.00s) Compiling generated Java code. Error B4A line: 212 End Sub src\com\online\iris\chart_display.java:1060: error: code too large public static String _webview1_loadhtml() throws Exception{ ^:
 

MicroDrie

Well-Known Member
Licensed User
Longtime User
code too large public static String _webview1_loadhtml()
You can try to reduce the length of the static string by using a lateral string which combine several other strings like
B4X:
Dim FirstPart as string = $"First part of your HTML code"$
Dim SecondPart as string = $"Second part of your HTMLcode"$
Dim YourHTL as string = $"${FirstPart}${SecondPart}"$
 
Upvote 0

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
If your string literal is that large, I would suggest adding it as a text/html file to your files folder and then loading it into your string:
Load file from assets:
psHtmlData = File.ReadString(File.DirAssets, "example.txt")
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
public static String _webview1_loadhtml() throws Exception{ ^:
That's not a string literal, it's a declaration of a public method returning a String and the error is a code error that seems to occur at End Sub so I suspect that the method is too large and needs refactoring into several Subs.
 
Upvote 0
Top