How To Ask Questions The Smart Way - Eric Steven Raymond
AI2 Power Users Canned Replies, mirrored June 2025
...
...
BackPack
(Canned Reply: ABG - BackPack)
The Backpack and Copy/paste facilities are in flux after upgrading the Blockly libraries.
I recommend downloading blocks using the Download as PNG right click option, saving the block images to your hard drive by name in a folder.
The png files can be dragged into the Blocks Workspace of this and other Projects.
They also serve as incremental backup.
...
BLE FAQ
(Canned Reply ABG - BLE FAQ with Latest Versions for Permissions)
...
Bluetooth split
Here is an updated blocks sample illustrating these ideas ...

...
BlueTooth text receiver sample, for single value per line
Here is a simple BlueTooth text receiver sample, for single value per line:
...
Chainsaw Joke
Chainsaw Joke
A city dweller buys a house in the country and needs to cut down some trees on his property.
He asks the local hardware store for something to use for his trees, and they sell him a chainsaw.
Two hours later, he returns to the store, all sweaty, torn, and bloodied. He throws the chainsaw down on the counter and complains it doesn't work.
The counterman inspects the chainsaw, verifying it's chain is seated and oiled, and that the gas supply is okay.
The counterman then pulls the starter rope and the chainsaw roars to life.
The customer then jumps back, and exclaims "What's that noise?"
...
Connect -> Companion
(Canned Reply Connect->Companion)
Using my PC's emulator because my phone's screen recorder is a pig
...
Delimiters
Be sure to use println() at the end of each message to send from the sending device, to signal end of message.
Only use print() in the middle of a message.
Be sure not to println() in the middle of a message, or you will break it into two short messages and mess up the item count after you split the message in AI2.
Do not rely on timing for this, which is unreliable.
In the AI2 Designer, set the Delimiter attribute of the BlueTooth Client component to 10 to recognize the End of Line character.
Also, return data is not immediately available after sending a request,
you have to start a Clock Timer repeating and watch for its arrival in the Clock Timer event. The repeat rate of the Clock Timer should be faster than the transmission rate in the sending device, to not flood the AI2 buffers.
In your Clock Timer, you should check
Is the BlueTooth Client still Connected?
Is Bytes Available > 0?
IF Bytes Available > 0 THEN
set message var to BT.ReceiveText(-1)
This takes advantage of a special case in the ReceiveText block:
ReceiveText(numberOfBytes)
Receive text from the connected Bluetooth device. If numberOfBytes is less than 0, read until a delimiter byte value is received.
If you are sending multiple data values per message separated by | or comma, have your message split into a local or global variable for inspection before trying to select list items from it. Test if (length of list(split list result) >= expected list length) before doing any select list item operations, to avoid taking a long walk on a short pier. This bulletproofing is necessary in case your sending device sneaks in some commentary messages with the data values.
Some people send temperature and humidity in separate messages with distinctive prefixes like "t:" (for temperature) and "h:" (for humidity).
(That's YAML format.)
The AI2 Charts component can recognize these and graph them. See Bluetooth Client Polling Rate - #12 by ABG
To receive YAML format messages, test if the incoming message contains ':' . If true, split it at ':' into a list variable, and find the prefix in item 1 and the value in item 2.
...
Designer Copy/Paste
Designer Copy/Paste
CTRL + C, CTRL + V
or
CTRL + INSERT, SHIFT + INSERT.
...
Bluetooth non-BLE SCAN Permission Blocks
(Canned Response ABG - Bluetooth non-BLE SCAN Permission Blocks)
The easiest solution, for immediate relief
(from @Barry_Meaker) ...
I had the same issue. The problem is your app does not have permission to see nearby devices. The solution is to give your app permission on your phone (no code changes in your app).
on your phone,
- goto settings
- search for your app
- in App Info for your app select Permissions
- change Nearby Devices from Not Allowed to Allowed
- Done
By the way, the very first time you run the app, Android will ask if you want to grant the app this permission. If you say no, or ignore the pop-up, the permission will be set as Denied. Android will not ask again.
Draggable blocks from a proposal by @ChrisWard Aug 2024:
A more complex approach, for professional app development:
See Bluetooth liste of devices deosn't work anymore - #7 by Anke
Special note for Xiaomi devices:
I have an error with bluetooth on android 12, Xiaomi Poco X3 NFC - #20 by Patryk_F
...
...
Designer Copy/Paste
AI2 has undocumented copy/paste (Ctrl-C/Ctrl-V) features in the Designer.
It doesn't take long to copy whole Arrangements from one Screen to another.
The accompanying blocks ride along.
<DOCTYPE
If something starts with DOCTYPE, it is an error message in html format and not what you might expect...
What about providing a screenshot of your relevant blocks? Where are you using the is in list block?
See also
...
...
Download Blocks and post them here
(Canned Reply: ABG - Download those blocks and post them here)
Please download and post each of those event block(s)/procedures here ...
P.S. These blocks can be dragged directly into your Blocks Editor workspace.
See Download Block Images for a demo.
...
Draggable
P.S. These blocks can be dragged directly into your Blocks Editor workspace.
...
BlueTooth Scanning Permissions
You need to ask for permission before scanning for devices.
Runtime error when using (Lỗi runtime khi sử dụng) BluetoothClient - #4 by Anke
...
Export & Upload .aia
(Canned Reply: ABG- Export & Upload .aia)
Export your .aia file and upload it here.
.
..
Export from Project List
This URL allows you to open AI2 to the Project List, without opening any project.
http://ai2.appinventor.mit.edu/?autoload=false
From that list, you can request Exports of Projects without trying to open them.
Upload the troublesome .aia here.
...
External vs Internal
External vs Internal
External vs Internal Sockets - TimAI2
...
Google Cloud Is Down
Google Cloud Is Down
Assuming you are using ai2.appinventor.mit.edu, it appears that Google Cloud is having some issues: https://downdetector.com/status/google-cloud/
I Don't do Extensions
The feature you are requesting is only available through extensions.
I personally neither use nor support extensions.
For support on a particular extension, I suggest contacting the extension developer
(if you can find them.)
...
https://doesappinventorrunonios.com/
...
https://appinventor.mit.edu/explore/ai2/support/concepts/mutators
...
Not found
I caught a quick peek at your code, and I have to recommend a recent tutorial on how to deal with not found lookups ...
How to Deal with notfound from lookups
...
Overloaded
MIT's AI2 servers are overloaded due to hardware failures, and their configurations try to share the overload. Unfortunately, that spreads the problem to build servers and Companion connection servers equally. This won't be resolved until new hardware arrives, or funds for paid Cloud servers arrive.
Try with ticking the legacy connection checkbox.
If that doesn't work, try connecting with USB.
PrepareAppIcon Task errored in Build
Icon
The image used for your App's display icon should be a square png or jpeg image with dimensions up to 1024x1024 pixels. Larger images may cause compiling or installing the app to fail. The build server will generate images of standard dimensions for Android devices.
...
Project Properties
Canned Response ABG - Project Properties
..
.
Public Only
(Canned Reply ABG - Public Only)
I do not provide private support.
You will get more informed and quicker worldwide support by asking in a new public thread.
Making this thread public.
...
Screen Switching Crashes
You added Clock Timers.
Clocks must be disabled before switching screens, or else they will cause crashes. It's like standing front of a window, throwing a boomerang, then walking away without catching the boomerang. Crash!
Also, you never close the screens you open, eventually leading to running out of memory.
See the screen switching section of
FAQ Section: Screens
...
temperature and humidity on separate lines
If you want to send your temperature and humidity on separate lines, you could alternatively send tag:value pairs, like
T:98.6\n
H:100\n
which would arrive individually if you use Delimiter 10 (\n).
Your AI2 logic would look like
if BT.bytesAvailable > 0 then
set local message to BT.ReadText(-1) (to get only 1 line)
if contains(message, ":") then
set local splits to split message at ":"
If (select item 1 of splits) = "T" then
set LabelTemperature.Text to (select item 2 of splits)
else if (select item 1 of splits) = "H" then
set LabelHumidity.Text to (select item 2 of splits)
else set LabelWhatHappenned to local message
end if
BlueTooth_YAML_delimiter_sample.aia (3.5 KB)
...
Too Many Blocks
When you have too many blocks spread out over too large a surface area,
the Blocks Editor hits a complexity limit when it tries to generate a blocks.png file for the screen.
There are two main approaches to deal with this:
- Start a Google Doc with a Table of Contents explaining your app, with sections for Design, Data, Code, including Downloaded Png images of all Events, Procedures, Globals, and with html cross-links for easy navigation. Such a doc becomes easier to read than a complete blocks image, because you have FIND, Next, PREV, back functionality, and you can add paragraphs of commentary around your code. This is my preferred life saver when doing a very large complex app. If you go this route, try to arrange your blocks geographically in a column matching the order of your Table of Contents, then do periodic Clean Up Blocks to pull them inline. This sometimes lowers the load on the Blocks Editor.
- 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.
...
TypeBlocking
Wait Loops
It occurred to me that you might be coming from an Arduino or IOT coding background, where you retain control forever and loop over time.
The AI2 environment is Event based, where you put things into motion on their own (
- start file operations
- ask for web data
- start a Sprite or Ball moving
- ask for input
- etc.)
and you have to take a leap of faith and let go of control,
leaving the rest of your code in the appropriate event block that will receive control after
your requested operation completes, for example
- file operation (read/write) completes
- Web data arrives
- Sprite or Ball collides with another or hits the edge of the Canvas
- user Clicks a Submit button
- etc.
It is unfortunate that the AI2 reference helps for such components don't mention this architectural style more often.
...
Waiting and Timing FAQ
(Canned Response ABG - Waiting and Timing FAQ)
Please see FAQ Section: Waiting and Timing
before you decide to code a delay() procedure in AI2.
...
switching your formula blocks from inline to external sockets
"switching your formula blocks from inline to external sockets"
...
...
responseContent, please
Please capture your responseContent as text and paste the text to this thread to allow us to compare the text against your parse attempts.
Show responseContent Text Copy and Paste Demo
...
Taifun's Project Oversized Tips
1
This list was made by @Taifun
- Use different screens wisely
Before starting to create another screen, first you should think about is it really necessary? See also Building apps with many screens and SteveJG's post about advantages/disadvantages , because in only one screen you also can use vertical arrangements to simulate different screens, just set the arrangements to visible = true/false as needed...
If you decided to use different screens, then you should switch them correctly, else you will run out of memory after a while... The recommended method of switching screens in App Inventor - App Inventor works best if you use images whose size matches the size you want them to appear on your screen. If you import larger images into your app, your app may run out of system memory. Using Images with App Inventor
by @Italo
First, you need to understand that the file size of an image is not the amount of memory it uses when it's being displayed. The file size is the compressed size, much like a zip or rar file. When viewed, the image needs to be decompressed.
For example, if your image says its file size is 100 kb, and its dimensions are 1024 x 768, 32 bit color, then that image uses over 3 mb of RAM (not 100 kb!) when you show it on the screen. ((1024 * 768 ) * 32) / 8 = 3,145,728 kb (3 mb)
Now, this is a mistake most people make when using arrangements as "virtual screens": They set different image components with their images loaded but hidden, instead of having only one image component and changing the picture according to the user's selection or app events, not knowing that apparently the hidden image components are also using the ram, (yes, even though they are invisible!).
3. Avoid redundancy
Probably it helps to read chapter 19 - 21 in Dave's book http://www.appinventor.org/book2 to get an idea how to do DRY programming with App Inventor - Don't repeat yourself
4. See SteveJG's monster list of tips and tricks
5. How to overcome the App Inventor project limit of 30 MB
6. Backup your project frequently