Android Question Error: code too large for try statement catch (Exception e) - is it a bug?

JOTHA

Well-Known Member
Licensed User
Hi community,
yesterday my app worked without errors, but today there is the following message, when I want to compile the code in Debug-Modus:
B4A Version: 10.60
Parse den Code. (1.00s)
Java Version: 8
Building folders structure. (0.14s)
Führe individuellen Aktion aus. (0.33s)
Kompiliere den Code. (1.29s)
Kompiliere Layoutcode. (0.04s)
Organisiere Libraries. (0.00s)
(AndroidX SDK)
Generiere R Datei. (0.00s)
Kompiliere Debugger-Code Error
B4A line: 984
End Sub
javac 1.8.0_221
shell\src\b4a\example\modul_070_subs_0.java:2887: error: code too large for try statement
catch (Exception e) {
^
1 error

To solve the problem, I deactivated all "try-catch" code in the source, but the error-message is the same.
If I compile in Release-Mode, everything is working.

Is it a bug?
 

JOTHA

Well-Known Member
Licensed User
Thank you Sandman.
I used the search function before but I found a statement from 2013 and meant, that is solved.
Now I understand that there is a limitation from java and I have to split the sourcecode if it is >64k.

My problem is caused by generating a PDF-File ... so I have to check out what is to do.
 
Upvote 0

JOTHA

Well-Known Member
Licensed User
Post some code.
Hello Erel,
thank you very much for your offer to help.
I found a solution by shortening the code.
It was only a large PDF-Page with a lot of text.
If someone is interested in ... I will post it here.
 
Upvote 0

DonManfred

Expert
Licensed User
It was only a large PDF-Page with a lot of text.
I can implemnent a PDF with 1.000 Pages in my app. It only needs a few lines of code to show them.

HOW did you add the PDF to your CODE??? Sounds like a big mistake.
 
Upvote 0

JOTHA

Well-Known Member
Licensed User
Sounds like a big mistake.
Yes you are right! 😁
I wanted a "millimeter-paper" underlying on every page and did it like this (first time):
B4X:
'    PDF.Canvas.DrawLine(5dip, 5dip, 210dip, 5dip, Colors.LightGray, 1)        '-- Quer-Linie 01
'    PDF.Canvas.DrawLine(5dip, 10dip, 210dip, 10dip, Colors.LightGray, 1)        '-- Quer-Linie 02
'    PDF.Canvas.DrawLine(5dip, 15dip, 210dip, 15dip, Colors.LightGray, 1)        '-- Quer-Linie 03
'    PDF.Canvas.DrawLine(5dip, 20dip, 210dip, 20dip, Colors.LightGray, 1)        '-- Quer-Linie 04
etc ...

I wasn't able to create a formula-code with "dip"-measures ...

The right way is to do it like this:
B4X:
    Dim QuerLinieLinks, QuerLinieOben, QuerLinieRechts As String
    QuerLinieLinks = 0
    QuerLinieOben = 0
    QuerLinieRechts = 595
    For i = 0 To 842 Step 10
        QuerLinieOben = i
        Log("M070-0417 -----► QuerLinieOben: "&QuerLinieOben&"")
        PDF.Canvas.DrawLine(QuerLinieLinks, QuerLinieOben,     QuerLinieRechts, QuerLinieOben, Colors.LightGray, 1)
    Next
etc. ...
... thats it. ;)
 
Upvote 0

JOTHA

Well-Known Member
Licensed User
I can implemnent a PDF with 1.000 Pages in my app
Do you use the Printing-Library or your PDFium-Lib?
I guess ... PDFium ;)

I use Printing and I should be able to shorten the code by splitting it in small Subs ... like this one (but it doesn't work)
B4X:
Sub Marker
    Dim PDF As PdfDocument
    PDF.Initialize
    PDF.Canvas.DrawLine(14, 289, 27, 289, Colors.Black, 1)
    PDF.Canvas.DrawLine(564, 289, 577, 289, Colors.Black, 1)
End Sub

I should make different Subs for a Page-Header and a Page-Footer ... :rolleyes:
 
Upvote 0

DonManfred

Expert
Licensed User
Upvote 0

JOTHA

Well-Known Member
Licensed User
I've seen that ...
Create PDF with b4a and php
.. and thanks for telling me the reporting tool ... it looks very good ...

but I don't need such a professional tool and I'd prefer a PDF-code without using a internet-connection.
 
Upvote 0
Top