Build failed! [RunD8] ERROR: d8 failed - Excessive number of blocks? I think NO

Dear community friends, once again I really need a lot of help.
I'm having a problem building my app.


BACKGROUND

A - I created my app with the "ai2" server and periodically exported the .aia files as backups (the last two are v51 and v52).
v51: 12021 blocks (.aia size 4.34MB)
v52: 12495 blocks (.aia size 4.35MB)

B - My app works properly when using the companion. I tried launching the companion from both the "ai2" and the "code" servers, and with two devices (Android 8 and 16).

C - When I tried to build the app from the "ai2" server, I received the error message
"Server error: could not save one or more files. Please try again later!"
In a previous post, we already addressed this issue and determined that the error was related to the number of blocks (>10k).
For this reason, I now use the "code" server to build my app. I built my v51 app (12021 blocks) and it works fine.


PROBLEM

When I try to build my v52 app (12495 blocks) from the "code" server, I get the error message
"Build failed! [RunD8] ERROR: d8 failed"
Doing some online research, it seems the problem is due to an excessive number of blocks, but I don't think that's the case because I've done some tests.


TESTS I CONDUCTED

1 - I gradually reduced the number of blocks in v52
*v52 with 11992 blocks: "Build" error (Strange! v51 with 12021 blocks has no problems)
*v52 with 11142 blocks: "Build" error (Strange! v51 with 12021 blocks has no problems)

2 - I have a very long "when WEB.GotText" block (3044 blocks). I split it into 3 blocks using "clocks", but that didn't solve the problem.
I'm not surprised by this because the same "when WEB.gotText" (3044 blocks) is present in v51 and doesn't cause any problems.

3 - I noticed that the "code" server address is now https://code2.appinventor.mit.edu/ (previously https://code.appinventor.mit.edu/).
Even if some limitations have changed, my v51 app still "Builds" without errors in "code2."

At this point, my attention focused on two very large "when WEB.GotText" (3044 blocks + 947 blocks).

4 - I tried collapsing the two "when WEB.GotText", but that didn't solve the problem.

5 - I tried renaming the two "when WEB.GotText", but that didn't solve the problem.

6 - I gradually eliminated the number of blocks in the two "when WEB.GotText" in v52, until only the two empty "when WEB.GotText" containers remained.
*v52 with 8506 blocks: "Build" error (Strange! v51 with 12,021 blocks has no problems)

7 - At this point, I disabled the two empty containers "when WEB.GotText". Now "code" server correctly "Builds" the app...
This is very strange because the two "when WEB.GotText" containers (now disabled) are empty! If I enable even just one of them, the error returns.

8 - I tried using AI2Offline, but I get the same error I initially received on the "ai2" server.
"Server error: could not save one or more files. Please try again later!" (see BACKGROUND)

9 - I tried using the "ai2-test" server, but I get the same error I initially received on the "ai2" server.
"Server error: could not save one or more files. Please try again later!" (see BACKGROUND)

What's going on?

You do not mention what it is you changed (added blocks, new procedures, components?) between V51 and V52?

Try a copy of V51, test compile, then add a few blocks, test compile, add a few more, test compile etc.

Do this all on the code server.

  • Reduce your block count:
    • Use parametrized procedures for common code
    • Use Media text files instead of big clumps of text blocks
    • Use generic blocks instead of repeating component event blocks
    • Encode repeating decision patterns into lookup tables loaded from Media csv text files (does your blocks image look like a box of combs?)
    • You don't need a component for every data instance. Reuse those components.
    • If you can't fit data into a ListView or List Picker, show a small subset of the data in an Arrangement and slide it across the larger list of data.

...

Hi @ABG

As I wrote, I think it is not simply related to block count. Please give me an help by well reading all mi post. Thanks

Hi @TIMAI2 thank you for reply.

I added logic blocks like “or” , “and” , “<“ , “>”.

I added a variable and I used multiple “set” blocks in “if” blocks”.

Finally I simply changed text in some labels.

Do you know other ways to build apk?

Please help me as in past you well did!

Thank you very much

The only approved method is to use the one provided by MIT in the AppInventor app

I have already made a suggestion on what to do.

However, a favoured quote (credited to @Boban) is that it is most likely

"you have too much of something"

1 Like

Here's another choke point I should add to my template:

Shrink the block count of your largest procedure or event, by dividing it up into calls to smaller procedures with fewer blocks. That might limit the stack height burden on the build process.

Can you elaborate what exactly are you doing in that event to require so many blocks?
More than 3000 blocks in that event sounds like a nightmare

Yes it is

@ABG already gave you some very good advice what needs to be done to reduce the block count

    • Use parametrized procedures for common code
    • Use Media text files instead of big clumps of text blocks
    • Use generic blocks instead of repeating component event blocks
    • Encode repeating decision patterns into lookup tables loaded from Media csv text files (does your blocks image look like a box of combs?)
    • You don't need a component for every data instance. Reuse those components.
    • If you can't fit data into a ListView or List Picker, show a small subset of the data in an Arrangement and slide it across the larger list of data.

Taifun

An example of above simplifications:

  • very long chains of “if variable between two values” ( used for example to set the background colour of an element ) can be substituted by a “for each item in list” ( also easier to maintain/update )

Thank you to all.

But please consider all tests I have already done.

I deleted many blocks in v52 , but v51 build apk with more blocks than v52.

I’ m trying to understand what is not working in v52.

I would concentrate on shrinking the biggest event block.

I repeat

Taifun

I don’t know why the content of web component is important if I said that when I completely remove it , I receive the same error message.

Please, carefully read my post

Sorry, I was talking about your v51
Talking again about your monster GotText event

EDIT: start with your working version v51 and drastically reduce the blocks in your monster event, see again the tips by @ABG .

After that then add more functionality

Taifun

What you also can do

Upload your app to https://unchive.kodular.io to get some statistics of your project and post the statistics overview

Taifun

Summary in unchive is exactly the same in v51 and v52. The only thing that changes is the “Total number of blocks”

How many procedures ( can’t read from image attached )?

P.S.

Also noted a “discrete amount” of clocks

The same number in v51…but v51 correctly builds, v52 no

This straw that breaks the camel's back?

Understood, I clearly can’t explain why v51 compiles correctly and v52 does not, I could only say: the odds are in favour of v51 ( as 52 is even ; - ).

P.S.
Also try exporting and re importing your aia as sometimes this fixes some leftover/zombies ( I generally call these “cadaveri” )