Cant Complete apk Build (OutOf Memmory?)

Hello,my project is unable to complete apk Build and i get an error message DX execution faild , but in AI Companion it working with no problem (compile successfully)
After a lot of time checking i found out that :if i dsiable a few block (doesnt matter which) the building process is successfully completed.

I have a lot of blocks in one page :slight_smile:

In offline version everything works fine.

With my litle knowledge i thing the problem is java.lang.OutOfMemoryError: Java heap space
and to fix it you must change to -Xmx2048m for the building apk process to work

There are a lot of reasons for why the DX error occurs, most notably you have a lot of something. You said that you have a lot of blocks on one screen, which may be the issue.

Can you try building your app on the code server (http://code.appinventor.mit.edu/) and see if it works?

  • 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?)
1 Like

Hello George - how many Blocks? Right Mouse Click in the Blocks workspace to find out.

9747 blocks

Exactly. The average user never needs more than 2K blocks. You will start to experience lags in the Blocks editor when you reach around 1K blocks, depending on what device and what browser you're using.

Look for the following to reduce the amount of blocks you have:

  • Are there too many virtual screens? Can you split some into real screens?

  • Do you have long bits of code where you repeated a lot of things? Try procedures, or lists with iterator loops (for-each, for-each-number).

no, the same error :
0%
App Inventor is unable to compile this project.
The compiler error output was
________Preparing application icon
________Creating animation xml
________Creating style xml
________Creating provider_path xml
________Creating network_security_config xml
________Generating adaptive icon file
________Generating round adaptive icon file
________Generating adaptive icon background file
________Generating manifest file
________Attaching native libraries
________Attaching Android Archive (AAR) libraries
________Attaching component assets
________Invoking AAPT
AAPT time: 1.689 seconds
________Compiling source files
(compiling appinventor/ai_george_chalkidis/test/Screen1.yail to appinventor.ai_george_chalkidis.test.Screen1)
(compiling appinventor/ai_george_chalkidis/test/Screen2.yail to appinventor.ai_george_chalkidis.test.Screen2)
(compiling /tmp/runtime6884702272298633441.scm to com.google.youngandroid.runtime)
Kawa compile time: 12.166 seconds
________Invoking DX
DX time: 66.586000 seconds
YAIL compiler - DX execution failed.

I'd recommend you to trim your blocks to 3000 in order to compile your app. How many do you have now?

i have bluetooth that send real time varibles with refresh rate about 80ms thats why i use one screen with virtual pages

You can also try storing the variable in TinyDB, or pass it around among different screens using start values.

if i set up bluetooth connection in screen 2 for example and if i change to real page then do i have to reintilalise the bluetooth (it will disconnect?) or it will continiue to sending and recieving data?

We do not have an offline version!

You are using a third party program and I think you have to stick with that as there may well be incompatibility issues. Why are you even even seeking out help with App Inventor if your Offline program is working fine?

If you have set it up on a Screen, then swap screens, Bluetooth is lost. This is because the Screens are effectively individual programs that do not share the same memory allocation.