2014년 12월 8일 월요일

Companion connection error on emulator / over wifi / over USB

I'm a teacher in the UK and currently putting together my own scheme of work with tutorial videos for AI2.

Everything was going great last week, made several template apps, written up some lesson plans and now I come back to it and I'm really struggling with testing my apps (which worked seamlessly last week)

No matter which connection method / computer / android device I use I continually get companion connection errors whilst testing ever the most simple app.
Once the error occurs it takes anthing from 2/3 to 10 attempts to reconnect, only for it to happen again 5 mins later.

So here's what I see:
Over Wifi (app companion)
mid way through running app, connection error appears try to reconnect, device scans QR code and then computer and device do nothing, QR remains on the screen and eventually times out. I stop the companion on the tablet and try again until it works. (usually go away have a cuppa then come back)

Over USB & Emulator exactly the same problem occurs except I often see an error "1801: Security Error Receiving blocks from browser"

I tried:
Reset connections
Hard Reset
Galaxy 3S
Nexus 7 2014
Restarting machine
Factory reset of tablet
disable antivirus

Any help / thoughts would be much appreciated

try Firefox, see also https://groups.google.com/forum/#!category-topic/mitappinventortest/f9bBBMJrMAI

I am using Firefox 32.0.3 getting same error. I could not run single app using this MIT app inventor.

some weeks ago there was an issue with the Google Chrome version, therefore we recommended to use Firefox instead.
But the new Chrome version now runs fine. What happens, if you test with the current Chrome Version 38.0.2125.111 m ? Also you could try the current Firefox 33.0.3....

When were you doing this testing James?   On November 7th, MIT had some serious hardware problems with their build servers.  It created some havoc for quite a few users.  The servers appear to be running properly now.  When was the last time you tried?

James, we do not recommend disabling virus checkers.

Some of your error messages are unique.   I have not seen them before.  Do you have multiple browser windows open, are are you on a school network?  and when was the last time you ran your virus checker?

If your testing was on the 7th, just try working with your project again for another try.   If you still are not running, I may have some other ideas and things to check.

@SteveJG: Phani hijacked this old thread from James, because he got the same error ...

@Taifun..... thanks .... answer is still the same.   The build server issue the other day was really nasty and might be Phani's issue.   

what is "blosks area is not initialized yet" ?

When I want to download this  apk
it show me this message 
how can i do ?

can you tell me what happen is it? thank you.

Most likely there is a coding error in your blocks.

One of the following  probably applies to your code (all may not apply to your code):

1)  You have coding errors in your blocks.  In the Blocks editor, look in the lower 
left for the yellow and red triangle icons.    If the red icon has a value larger than 0, 
you have a serious coding error.  Find the block in your code that has a red triangle and 
fix it.   Red triangles always inhibit creating an apk or running a project in the 
emulator or possibly creating an aia file.     Yellow triangles are more forgiving, 
however, sometimes, these need to be fixed because they trip an internal warning and 
you do not get a compile, so fix the yellow triangles too.

2) Your source file (the aia file) is larger than the 5Mb limit allowed in AI2 or you 
put images or other resources in your Media (resources) that you do not use in the app. 
 All the images and sounds in resources count toward the 5Mb limit.    You can program 
apps larger than 5Mb in the browser, but they will not compile and might not run in the 
emulator or the project may not save as an aia. If this is the case you need to reduce 
the size of your image and/or sound files.   Most image files can be made quite small 
by resizing them using a photo manipulation program on your PC to less than 50Kb each.

3)  You might have more than 10 Screens in your app.  AI2 becomes unstable when more 
than ten screens are used.

4) You might have set a Screen icon for your project that is too large. Use an image 
sizeof 48x48 px or 96x96px instead and only use jpg or png images.  *.ico files are not 

5) You did not code the entire project using App Inventor 2.   If you used one of the 
third-party AI2 clones,you might not be able to load a Project into the AI2 compiler or 
create an apk with the standard AI2.

6) If you incorrectly modified the project's Manifest files, you may have issues.

7)  Sometimes, if you have LOTS of Layouts on a single screen,  the apk might not 

Is one or more of these true?   Check your code, create an aia and see how big the source is , make changes and try to compile again.


Thank you very much. 

but above problems are not in my app.

I tryed it that I found my app problem,

 my app proublem is "when I do the app ,I cut to the web that it data false" , I thought,after I searching for network again.

thank your suggestion that me found it. :))

Slider thumbposition convert to integer

i need convert slider position to integer and then send it as 1Byte number via bluetooth. 
can some help me with this ??


It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.


when i run app and move slider i get "Error 510: Could not decode "55,37" as an integer."

use the round block 

Returns the given number rounded to the closest integer. If the fractional part is < .5 it will be rounded down. It it is > .5 it will be rounded up. If it is exactly equal to .5, numbers with an even whole part will be rounded down, and numbers with an odd whole part will be rounded up. (This method is called round to even.)

instead of using the evaluate but ignore result block, see here how to connect correctly
A simple Bluetooth Chat with App Inventor 2

thx :)

is the any chance to add encoder wheel as show on photo ??

yes, you could use an image sprite and the wheel as image, then depending on the rotation of the sprite you could extract the corresponding value

first do the tutorials http://appinventor.mit.edu/explore/ai2/tutorials.html to learn the basics of App Inventor, then try something and follow the

Make a control using an AI2 Canvas.

Here is the concept... I R an Engineer, not an aRtist so bare with IT.   If you are Neet, it won't Bee soooo messy.
Have fun.

You probably don't want to copy all this stuff so try the aia.   Mind the settings on the Design screen and realize, you can fix this up in many different ways.  You can change the "Volume" by touching the dial or by using the buttons ..... oh my, there is not any error control.... don't get burned, when u do it, do it right.

Does that work?



Please guide me that how can I provide (a feature in my android app.) of google+ and facebook connectivity as we used to see in today's android apps.

AI2 free online eBook   http://appinventor.mit.edu/explore/ai2/tutorials.html   ... the links are at the bottom of the Web page.

Do some tutorials and do a little reading, and you might be able to build what you want with App Inventor 2.

Try some blocks; post a screen capture of what you have done and then ask a specific question and you will get advice here.

NFC Tags

I've my first NFC smartphone.
To use AI I need "to initialize" NFC tags (empty tags) with other NFC app (just write something).
It's the same for you?

Thanks a lot 

Samsung S5 TextToSpeech1

I am trying to make my first project with MIT App Inventor 2 beta, connected to my Galaxy S5.
..when i am trying it on the phone the button works, I hear the click, but  no speech.
Is there any knowing problem with S5 text to speech?

Make sure Text-To-Speech is installed and enabled on the phone.

Full screen swipe wtih text

I have made an app which is a simple RSS Reader.

Each news is presented fullscreen with title, image, and short text.

I want the user to change of news by swiping left or right

I understand that :
> the only way to do swipe is to use Canvas  : is it true ?
> canvas work well with images but not with text (paint text makes dirty fonts) : is it true ?

So I see several posibilities :
> use multiple small canvas between lines of text to capture touch which would occure on the text. it seems however that this solution is complexe and hazardous
> build an image with titleText + image + shortText, and show this image in a full screen canvas. The issue here is that I do not know how to do this image building.

Can you advise me on my understanding and potential workarounds

the only way to do swipe is to use Canvas  : is it true ?
yes, but you also could use the webviewer together with some JavaScript, but this is a little bit more complicated to set this up....
see also this App Inventor Classic example to display some text in the webviewer https://puravidaapps.com/label.php
I could convert that into App Inventor 2 and add the swipe functionality. Do you like to be the sponsor of that tutorial? If yes, just contact me by email.

I now updated my tutorial for App Inventor 2 and added touch gesture support, see here

how to detect color in app inventor

hi, i mad a app where the ball has to detect if its touching the canvas background (light blue). the point of this app is to stay in a path (a white .PNG) i want to make it so when you get of the path, it will trigger a different screen. any ideas?

- stashu kozlowski

here are some screen shots of my code

as already recommended by Enis in your other thread is it possible for a sprite to detect is its touching a color?
 "You need to check that color every time you move the sprite"

and some questions:
what is the timer interval of your clock?
what happens, if you set the ball manually to a x/y coordinate with the light blue background?
use Do it to debug your blocks

PS: please do not start a new thread next time, just continue the old thread if there are still issues

What I have done in an app like this (a bird flying through the sky) is to have a picture as canvas background image. In your case the blue color AND the white path. Then you can test for the canvas pixel color at a specific location, as in my example:

Where I test that the bird is still flying on top of my blue color (-18...) each time the timer event fires and if not, it must have hit something.
I think you can draw on the canvas and detect the drawn color, but if you have a sprite and your sprite is on top of that, you will see only the canvas color.

hey, sorry that i posted the same question in the forums. but i lost the link to the forum.  

what is the timer interval of your clock? 90 (for the ball movement), 150 (for the background/path movement).
what happens, if you set the ball manually to a x/y coordinate with the light blue background? nothing. it suppose to open a "you lost" screen

is it possible if i turn my app to a .apk and you took a look for me. 

the .png is just the white path. i need to make it so that when it touches the canvas (light blue)

You can append an .aia in this forum, but an .apk is prohibited.
I cannot promise that I will look at it immediately, but I will give it a try.

Thank you so much. i appreciate the help a lot.

there is no rush. after all your helping me :D


You made your life rather difficult by coding the whole app, having some wrong assumptions. 
The way to do software development is to make something small first, make sure it works, and then add something and then another, until you are ready.
Incremental development this is called and with AI this is really easy to do because of the real time testing that you can do.

But in your case your ball is off the path from the start and therefore you jump to an end screen immediately, making any testing impossible!

So, start again, taking into account the following:
1. Although you can have a canvas of 4500 pixels, what you see is only as wide as your real screen, about 480 pixels on my phone.
2. So if you place a ball at x=2000, it is way out of sight.
3. Why do you have 3 timers? They will start interfering and for the buttons it would be much simpler to just use the button.Click event to move the ball up or down when the event happens. And the moving or having moved off the white path is easily combined. Which leaves you with only one timer and a more responsive game.
4. replace the open EndScreen with a notifier message until you have everything debugged.
5. Small thing: it is better to test whether the pixel color is not white, instead whether it is blue, because in the later case you could put some things on the canvas or give it other colors, etc.

And then, post on your progress!

Maybe I should apologize. After peeling of the things which made it impossible to debug your app, and when I corrected some problems, I understood what you were trying to do. And I think there is a problem. As soon as you enable the color detection, the sprite with the white path disappears. I will try to ask more knowledeable people.

Could you do something for me? Run the attached .aia and report what happens? On my phone the display freezes with the cyan background color after a second or so, but the staff at MIT do not have this problem.
Probably it is a weird timing problem, related to my phone and maybe also yours. PLEASE report your results.

You can fix the app by enabling the two disabled blocks in the Timer event block (it somehow solves the timing issue when you write something as label text in the timer event block). Then use the app as an example of much simpler way of what you want to do. As you can see you can move the path sprite by setting the right direction and speed in the designer and then you need only one timer.


How do you turn off the sound that the blocks make???

How do you turn off the sound the blockes make, when you join them,its irritating cause I was trying to watch life of brain montypython and all i could hear was click click click...
plz help

You can't... If you're trying to watch a movie, then you're not concentrating on programming.

I suggest you watch the movie, then do some programming...

Actually, you probably should do the programming first, and when you're done, THEN watch the movie.

New built in maths block to convert Decimal to Hexdecimal

I have been working on adding a few extra builtin maths blocks one of which calculates a new x y coordinate based on the angle and distance and this is working fine. 

I'm adding another block to convert decimal to hexdecimal which should be pretty straight forward in scheme but for some reason when I compile the companion app it crashes. Below is the scheme code I have added just to test the code conversion code works. The code is added to 

(define (math-dec-hex)
   (number->string 11 16)

When I compile and start the companion app with this code the companion app crashes straight away when it starts

I have tested the code on the following online sandbox here http://repl.it/examples/

here is a screen shot and the result is correct in green

Can anyone shed light on why the same code crashes the companion app?

Did you build your own Companion based on your updated code?

I also did the amendment on the latest version of AI code with no other changes.

here is the logcat report when I start the companion app

11-09 19:38:24.250: D/AndroidRuntime(20558): Shutting down VM
11-09 19:38:24.258: E/AndroidRuntime(20558): FATAL EXCEPTION: main
11-09 19:38:24.258: E/AndroidRuntime(20558): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{edu.mit.appinventor.aicompanion3/edu.mit.appinventor.aicompanion3.Screen1}: java.lang.ClassNotFoundException: Didn't find class "edu.mit.appinventor.aicompanion3.Screen1" on path: /data/app/edu.mit.appinventor.aicompanion3-1.apk
11-09 19:38:24.258: E/AndroidRuntime(20558):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2171)
11-09 19:38:24.258: E/AndroidRuntime(20558):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2295)
11-09 19:38:24.258: E/AndroidRuntime(20558):  at android.app.ActivityThread.access$700(ActivityThread.java:150)
11-09 19:38:24.258: E/AndroidRuntime(20558):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
11-09 19:38:24.258: E/AndroidRuntime(20558):  at android.os.Handler.dispatchMessage(Handler.java:99)
11-09 19:38:24.258: E/AndroidRuntime(20558):  at android.os.Looper.loop(Looper.java:175)
11-09 19:38:24.258: E/AndroidRuntime(20558):  at android.app.ActivityThread.main(ActivityThread.java:5279)
11-09 19:38:24.258: E/AndroidRuntime(20558):  at java.lang.reflect.Method.invokeNative(Native Method)
11-09 19:38:24.258: E/AndroidRuntime(20558):  at java.lang.reflect.Method.invoke(Method.java:511)
11-09 19:38:24.258: E/AndroidRuntime(20558):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
11-09 19:38:24.258: E/AndroidRuntime(20558):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
11-09 19:38:24.258: E/AndroidRuntime(20558):  at dalvik.system.NativeStart.main(Native Method)
11-09 19:38:24.258: E/AndroidRuntime(20558): Caused by: java.lang.ClassNotFoundException: Didn't find class "edu.mit.appinventor.aicompanion3.Screen1" on path: /data/app/edu.mit.appinventor.aicompanion3-1.apk
11-09 19:38:24.258: E/AndroidRuntime(20558):  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
11-09 19:38:24.258: E/AndroidRuntime(20558):  at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
11-09 19:38:24.258: E/AndroidRuntime(20558):  at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
11-09 19:38:24.258: E/AndroidRuntime(20558):  at android.app.Instrumentation.newActivity(Instrumentation.java:1071)
11-09 19:38:24.258: E/AndroidRuntime(20558):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162)
11-09 19:38:24.258: E/AndroidRuntime(20558):  ... 11 more

I have put the mod on git

Attached is the compiled companion app that crashes.

Yes, the Kawa we use supports number->string (I tested it). I'll looking into your changes now...

So I've checkout out your code and it fails to compile (The Kawa compilation fails).

I found the problem. We define our own version of number->string in runtime.scm that takes only one argument. Your test function is calling it with two (which is OK with the kawa builtin version, but not with the redefined version in runtime.scm)!

I have it working. I've attached a ZIP file to this message which contains the output of git format-patch. Use "git am" to read the enclosed file.

This patch renames number->string to appinventor-number->string (this needs more testing!). I also added a Dec To Hex Test block to exercise the code.

Thanks for looking at this Jeff. 
Will have a look at this tonight when I get home from work

You saw that Jeff figured it out.   My stupidity for shadowing number->string.
I'll fix that in a release,soon.  In the meantime, just patch runtime.scm to use another name, and change the block generator to use the new name.

There used to be some Scheme based unit tests that we encouraged developers to add to when they created or modified scheme code for new blocks. Does that still exist?  It might have caught something like this.

Those unit tests still exist.   They would not have caught Gereth's bug, since he wasn't making any changes to existing code, just using Kawa's number->string in a way that the code in runtime.scm was shadowing.   That shadowing's been there from the beginning (my fault).

regarding sending email without selecting app

I want to send email without popup of select app to complete action.
I have done the codding BT it asks me to select app to complete action and hen it send email.
Now I want to do something which will send mail without taking permission.
I am ready to set to and from id manually.

Different eMail solutions for App Inventor

Connecting one app over multiple phones

I have an app that I made but I was wondering how I could get it to work on multiple phones as if they are connected. It's a food app so I was wondering how I could update the menu on the app on one phone and have it change the menu on someone else's phone using the same app. Is this possible and how?

you will need a server database 
one phone (client) updates the database and all other phones (clients) read the new data
one possibility is is to use a fusiontable, see the Pizza Party tutorial

is there a way to divide the blocks editor?

i'm new at this, and having fun :)

when making a complicated app or game, the block editor is crammed with builds. at the end, sifting through all that in order to find a specific build is like finding a needle in a hay stack...

what i do is trying to keep related builds in areas in my mind and on the blocks 'canvas'.

then i thought, why not make an option for sub-dividing the canvas to tab-controlled partitions? let me name the tabs as i see fit - movement, score, etc.  - and keep an option to go back to a full canvas.

other options:
 - draw big squares on the block canvas and number them
 - give me the option to zoom in and out on the block editor canvas 
- create "earmarks" index that zooms in on the matching earmark

you get the idea.

The following article may give you some ideas to proceed:  http://ai2.appinventor.mit.edu/reference/other/manyscreens.html  with some of your screen stuff.

The following article address drawing squares on the block canvas

You could do something similar by placing sprites on the canvas and use them as Buttons (they are not but they have properties you can use to make them behave like a button).

I think Steve's answer is not a reply to jimm's question. 

There has been quite some discussion on how the blocks edtior could be made more user friendly to large projects and eventually something will happen, I sincerely hope.
For now, the best option is to collapse the blocks and sort them by category. Then just expand what you need while developing. Sometimes I also make screenshots of relevant blocks, so that I can have more windows open with the same thing.
If you are a programmer, then you might try to some development yourself, because AI2 is open source.


I'm making a Snake game with App Inventor 2 but I don't know how to grow the snake, everything workes except how to grow the snake.

You advance the snake by drawing its head in the next square
in the direction its headed, and adding the head's position at 
position 1 of a list of its prior positions.

To grow the snake, fail to clear the board of its tail
(the last position in the list).

Thanks, but i'm a bit new to AI2 and i don't know excactly what you mean.
I'll send the code, hope you could help me.

Be aware that many do not want to load .aia's (takes too much time from our precious volunteer hours). Next time, post a screenshot of relevant blocks.
Anyway, in your movebody procedure, you should have some if-then-else logic: 
if the heading = 0, then x-body = x-head - 10 and y-body = y-head,
if the heading is 90 then x-body = x-head and y-body = y-head - 10 etc.
If necessary, do some tutorials te get familiar with if-then-else logic and how to adjust the blocks in AI2.
But then the fun starts, because you have only one body part now. You will need to add more sprites if you want to have a longer snake, keep the positions in a list, as Abraham said.

Okay thanks, i thought i wouldn't need more sprites because i can just muliply the one i have but i'll figure something out if you want screens i cant send

Unfortunately you cannot clone sprites programmatically in AI2. But you can of course use the same image for all the sprites.
After I wrote my reply I realized that you can avoid all the if-then-else if you do the positioning of the body in the event blocks, because there you know already what the heading will be, the thing on which the x and y setting of the body depends. Later you could do something even more fancy by having arguments to the procedure movebody, giving it the increments to x and y as input. But I advise to wait with that until you have more experience and also to complete one of the screens first. Maybe you can then find a way to combine both the sensor and the arrow versions.

I ment i can send screens btw, but could you help me out a bit step by step.
Here is my block's picture

That is not quite the idea. We help you if you are stuck and try to point into the right direction and for the rest: it is your effort, your game.
Your picture looks ok to me though.

Just a quick thing: my canvas flickers when the snake is moving, sometimes it stops randomly but it's pretty strange any help?

refer to: search for snake


I tried to compile my apk, and then show that, somebody help me

Somebody know hot to solve it, its for a high school project:

App Inventor is unable to compile this project. 
The compiler error output was 

________Preparing application icon
________Creating animation xml
________Determining permissions
________Generating manifest file
________Attaching native libraries
________Copying native libraries
________Attaching component assets
________Compiling source files
(compiling appinventor/ai_jijadan/Lego/Screen1.yail to appinventor.ai_jijadan.Lego.Screen1)
ERROR: appinventor/ai_jijadan/Lego/Screen1.yail line 234: duplicate declaration of 'Nxt'
ERROR: appinventor/ai_jijadan/Lego/Screen1.yail line 209: (this is the previous declaration of 'Nxt')
Kawa compile time: 1.689 seconds

You have coding errors in your blocks.  In the Blocks editor, look in the lower left corner of the window for the yellow and red triangle icons. If the red icon has a value larger than 0, you have a serious coding error.  Find the block in your code that has a red triangle and fix it.   Red triangles always inhibit creating an apk or running a project in the emulator or possibly creating an aia file.     Yellow triangles are more forgiving, however, sometimes, these need to be fixed because they trip an internal warning and not billing puzzle piece sockets are left un-filled.

Somewhere in your Lego NXT commands, you are either calling a Nxt incorrectly or the app calls it twice.  Without seeing a screen capture of your blocks, we can only guess.  Find the error, change some blocks (or temporarily disable any of your Nxt command blocks to see which is causing the problem) and try to compile again.    The DoIt AI2 debugger might also be your friend.


apk won't install

Created the apk, saved it, loaded it onto my tablet via usb transfer.  I click the file to install it, it gives the permissions, then a "Cancel" or "Install" button appear, I can click the cancel, it highlights that button and closes if needed, the install button looks normal, but it won't highlight or click...
I've deleted and downloaded it again.  I've resaved the apk from the builder... I've added it to my device multiple ways (direct online download), etc. still with no fix.
I am able to install other apks I've created today from the builder with no problems.

Any help appreciated, I've also rebooted the device after install, then retried, and rebooted and full power down after deleting before reinstalling etc.

Make sure you have the security setting for allowing installs from unknown sources is on.  OTherwise, your device will block installation

It is checked, other apks I have made today work.  Not sure why this one isn't.

Problema na conexão (Problem connecting)

I have this problem and I can not emulate.

One issue is that your Companion is not up to date.  The current Companion is 2.23               and you are using 2.11      If you are using the emulator, Connect > Hard Reset    and follow the directions in the drop down.    If you are coding on your device you need to download the latest version from Google Play.

There may be other issues, however using an old version of Companion can cause many issues.

Update Companion and try again.

no option to use < or > sign.

while using the "if" command i have no option to use the > sign, is there any solution for this?

You can use a > sign  with an IF block.  What are you trying to do?   Show a screen capture of what you are trying to do with an explanation of what is not working and you will receive specific advice.

You might read the following about  the IF block  and logic blocks.   http://www.appinventor.org/Chapter18  

Did that help?

If not, post some blocks or tell us more about what you want to do with the greater than sign (>).

I'm having a similar problem. I'm trying to follow this tutorial and I can't add a greater than block that lets me add the subsequent blocks in the attached image. 

Any help would be greatly appreciated!

Worked it out myself. Right click --> External Inputs!

Error 702 when Switching Screens

When the "play" button on the title screen is pressed, it says "Unable to prepare blahblahblah.mid." However, I have it set in the block editors that the music player will stop when the button is pressed. The next screen (level selector) doesn't open. Can someone help me out?

For reference, this is happening when I'm using the companion app on my phone.

(If anyone's curious, this is my girlfriend's Christmas present (or our anniversary present if it takes too long). She likes the Indie Game "Five Nights at Freddy's" and she also loves My Little Pony. )

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

For supported audio formats, see Android Supported Media Formats.

That fixed it!