Social Icons

Help with problems connecting the emulator

App Inventor provides an Android emulator for people who do not have Android devices, or who would prefer not to use one while creating apps. To use the emulator, choose Emulator from the Connect dropdown menu. The emulator should start on your computer, and connect to App Inventor so you can test your app and do live development.

The process that starts the emulator involves several programs working together. There are many things that can go wrong, such as unexpected configurations, restrictions on the network you are using, or other software running on your computer that interferes with App Inventor. For school computers, we've seen several issues that interfere with App Inventor, including firewalls on school networks, restrictions on software the the machines can run, and ports being blocked. Symptoms you might encounter include the emulator starting up and then freezing, or not starting at all, or App Inventor displaying "unable to connect" messages.

If you encounter a problem connecting to the emulator, visit the page

Debugging issues in running the App Inventor Setup Tools and the emulator on Windows

This gives a step-by-step procedure for attempting to isolate and ifix issues. (This procedure is for Windows. The issues are the same for MacOS and we will be publishing a Mac version of this document soon.)
Please go through this procedure before filing an issue on the App Inventor forum. If you eventually file an issue, first search on the forum to see if others have experienced similar problems. When you post to the forum, describe the results of the steps you tried, so that people who want to help you will have more information about where to begin.

Here are some other things to investigate as part of your debugging.

Things to check first

Does the problem of the emulator not starting occur with just this project or with all your projects?

If the problem is with only this project then there is probably something in the project that is tickling a bug in App Inventor. Please submit an issue and include the project source (aia) file. On the other hand, if the emulator won't start for any of your projects, then continue with the debugging steps here. An intermediate case is when you have a large project that has many images or sounds, or many screens. In that case, try reduced versions of the project that have fewer screens or assets to see how large things before the problem occurs.

Is there another device connected to your computer?

If there is a phone plugged in, then unplug it. The current App Inventor 2 software can handle only a single device and will get confused if more than one device is connected. Similarly, App Inventor will get confused if there is more than one emulator running. Kill any running emulators before trying to start another one.

Is the setup software installed in the correct directory?

The App Inventor directory the Commands for App Inventor software should be installed in Applications on the Mac; or C:\\Program Files or C:\\Program Files (x86) on Windows; or /usr/google on GNU/Linux. The setup software won't find the emulator support if it's in a different location.

Is your browser running an extension that blocks connections?

An example of an extension that blocks connections is the NoScript extension for Firefox. If you are running this or something similar, you'll need to turn it off, or configure it to not block the App Inventor connections.

Is App Inventor asking you to restart the companion?

Part of the App Inventor software includes the App Inventor Companion app, running on the emulator. If App Inventor has trouble communicating with the emulator, it may ask you to restart the Companion. To do this, use the emulator on the computer screen: press the (image of the) menu key, and then the button to kill the app. If the Companion tarts up again, asking about a QR code, press the menu key and kill it again. Now select emulator again from the App Inventor connect drop-down menu. Restarting the Companion might not solve your problem (there might be another underlying cause) but it is a good first step.

Are you waiting long enough?

When the emulator starts, it first appears as a black screen with the word Android in the middle. In some cases, it can stay that way for as much as several minutes while the emulator program starts up. We don't know why this is, and it might not happen all the time, but we'll keep investigating. Once the emulator gets past that, the screen will turn completely black and then come up with the Android home screen. Shortly after that, App Inventor should recognize that the emulator has started and start the companion in the emulator, and then load the blocks for your app. If things break at some point in this startup, you'll need to do some further diagnosis (see below) but the first thing is to wait.

Further diagnosis and debugging

If you've tried everything above, and there are still problems, you'll need to do some diagnosis and debugging. This will require using the console commands. Try to get help if you are not familiar with using the command console.

As an overview, running the emulator involves the following
components:

  • The Android emulator program running on your computer.
  • The App Inventor Companion app running in the emulator.
  • The aiStarter program running in your computer. It manages the connection between the browser and the emulator.
  • The adb (Android Debug Bridge) program running on your computer, which lets the computer control attached Android devices.
  • A rendez-vous server running at MIT, which App Inventor and the Companion use to inform each other of their IP address.

You may have to check some or all of these in the following diagnostic steps.

Can the computer run the emulator program at all?

If the emulator does not start at all (i.e.,you don't see the emulator window appear on the computer screen). It might be that there is a permissions issue in accessing files or directories that keeps the emulator from starting. There are also cases where administrative software prevents school computers from running scripts (bat files). This will also prevent the emulator from working. To diagnose this, get out of App Inventor, go to the the Commands for App Inventor directory and run the command run-emulator. Examine the console output for the emulator program to see if that gives you a hint about why the emulator isn't starting. (Don't worry if you see a warning about adjusting the partition size -- that's normal.) After you've dealt with the problem, try run-emulator again. Then kill the emulator program and try App Inventor with starting the emulator as usual.

What is aiStarter starter and how do I start it?

The aiStarter program is installed on your computer when you install the App Inventor Setup software. It provides communication between App Inventor running in the browser, and other parts of App Inventor. Whenever you want to use the emulator or the USB cable, you need to make sure that aiStarter is running. If it is not running, you'll get an error message saying that aiStarter does not appear to be running. On Windows, there should be a button on your desktop that starts aiStarter. On the Mac, aiStarter should start automatically, so Mac users should not have to worry about this. In case aiStarter somehow does need to be started manually on the Mac, find it using Spotlight, use the Finder to go to /Applications/AppInventor/commands-for-App, and double click on aiStarter. On GNU/Linux, this program is in /usr/local/bin. You should be able to start it by typing aiStarter from a terminal.

How can I tell if aiStarter is running correctly?

aiStarter is running correctly if the emulator (or USB) connect. If you want to diagnose a problem with aiStarter, try running aiStarter from the console.
Then, when you try to connect the emulator, the console output for aiStarter should show a sequence of "probes" of the form

127.0.0.1 - - [01/Dec/2013 11:28:30} "GET /replstart/emulator-5554 HTTP/1.1" 2000

There might also be problems, like a message about blocked ports, or issues with the adb program. For a blocked port, check whether there is another program on the computer that is using the port.

Is adb running correctly?

The adb program can sometime get confused, especially if there are other issues. Open a console in the Commands to App Inventor directory, and run the program adbrestart and see if that helps.

Is the correct device on line?

If the emulator is started and has been in the process of starting up for a while (and is past the completely black screen), run the command adb devices in a console window. The result should show a list of devices:

emulator-5554 device

There should be exactly one device: the emulator. Disconnect any other devices. If the status of the emulator is offline rather than connected, then you might not have waited long enough, or there might be some other program using the emulator port 5554. You'll need to find that program and disable it. If the emulator doesn't continue starting up, kill it and try connecting again.

Is the emulator running, but App Inventor keeps counting down in a loop trying to connect to it?

This means that App Inventor cannot communicate with the AI Companion program running in the emulator. The first thing to try here is to reinstall the AI setup software as described here: How to update the App Inventor Software. If this doesn't work, then check if adb is running, as described above).

Is the emulator hanging waiting to load blocks?

If the emulator had gotten through the entire startup sequence, started loading your app and hangs waiting for blocks, then there might be a bug in your program that is preventing the blocks form being loaded. Check your program in the designer and blocks editor. If you need help, file and issue and include the program source (aia file).

Other Emulator issues

My app runs on the emulator, but images do not appear.

Some people have observed a problem where the app runs on the emulator, but images do not appear. To fix this, reload the App Inventor page in your browser. (Use shift-reload to also reload the cache.) Then try connecting to the emulator again.

When connecting to the emulator, App Inventor says: "Network Error Communicating with Companion. Try resetting the Companion and reconnecting."

This message means that App Inventor believes that it's connected (to the emulator), but it is getting no response from the AI Companion software that should be running in the emulator. There are several possible possible different and we're currently updating the setup tools to fix as many as we can. In the meantime, one thing to try is to delete .appinventor folder of your home directory and try connecting to the emulator again. And try starting connecting two or three times. If these reconnect attempts don't work, try resetting the AI companion program. Use the menu key (on the emulator) and select "stop this application". Then reload the browser page, and try connecting again. If the doesn't help, kill the emulator window, reload the browser page, and try again. If this still does not work, please report an issue.

Is a firewall blocking aiStarter or the emulator?

If the emulator loads and starts, but then you see an error that there is a problem communicating with the Companion, one possible (but unlikely) cause is that a firewall is blocking connections between App Inventor and the emulator. Windows and MacOS both come with firewalls included with the operating system. Neither of these should create problems for App Inventor, but your computer might have other firewall software installed (for example, AVG link scanner). If it does, you'll need to configure that firewall to allow both aiStarter and emulator.exe through.

Can your computer see the rendez-vous server?

Using your browser (not App Inventor) try to visit the page at http://rendezvous.appinventor.mit.edu. It should look like a copy of the App Inventor page (but it is not the App Inventor service, so don't try to use it as that). If you cannot visit it this page, the App Inventor will not work. Check with network provider to determine why this connection is blocked.

To be continued as we get more experience ...


<<Back to Setup Emulator Connection

<<Back to Main Setup Page