2014년 12월 16일 화요일

App Inventor cannot connect to emulator


Started evaluating MIT App Inventor (ver 2.2) on Windows 7 (from Administrator account). Since I don't have Android devices, I have to use an emulator.
aiStarter.exe and emulator.exe both work when explicitly started, but
when I start aiStarter.exe and ai2.appinventor.mit.edu/#5440960545685504 onChrome and then do Connect/Emulator, emulator.exe is not started, and aiStarterdisply messages like:
127.0.0.1 - - [16/Dec/2014 04:15:13] "GET /echeck/ HTTP/1.1" 200 38
The system cannot find the path specified.
Problem checking for devices : status 1 
I tried disabling Chrome extensions, and trying to start ai2.appinventor.mit.edu fromFireFox and Maxthon browsers, with identical negative results.
Both Googling and searching appinventor.mit.edu didn't help.
  1. What is the failed path in the error message referring to?
  2. Any suggestions how to debug App-Inventor/emulator startup failure?




Do you have BlueStacks loaded on your PC?   BlueStacks creates serious issues for running AI2.

You are trying to use the emulator to run an existing Project that you coded, there could be issues with the code you reproduced. Have you tried running any other projects?

Try this.   Create a NEW Project from the Designer screen.   Place a button on the screen.  Nothing else.  Go to  Connect>Emulator   and run the new one button project.  Does the simple project display an image of a button?   Knowing this works or does not helps answer your questions.

You are using Companion version 2.2?   Sorry that is out of date, what you might try doing is    Connect >  Hard Restart .   That should bring up a pop up screen that will allow you to update Companion to the current version.  Follow the directions on the screen exactly.  Read every word and it should set up the latest Companion.  When you are done, close your Chrome browser and then restart and try again.  Did that work?

If that did not work, try the in case of issues options here http://appinventor.mit.edu/explore/ai2/support/troubleshooting.html  and follow the recommendations.

There are lots of reasons the emulator might not be working, here are some more possibilities but since you are new, probably only a few apply to you.

One of the following  possibly 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 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.

2) Your source file (the aia file) is larger than the 5Mb limit allowed in AI2 (the aia can not be larger than 5Mb). You may have 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 along with the source code.    You can program 
apps larger than 5Mb in the browser, but the apps 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.  Projects CAN be built with slightly more screen but then you should expect your app to occasionally behave erratically.

4) You might have set a Screen icon in the Designer Properties 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 
supported.  The 'icon' (actually an image) can be as large as 520x520 (I think that is the size GooglePlay apps require).  The smaller 'icons' work fine otherwise.

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 using a third-party tool, you may have issues.

7)  Sometimes, if you have LOTS of Layouts on a single screen,  the apk might not 
compile. How many is a lot?  I do not know, keep adding layouts and buttons, compile and try again...when the server crashes, you got a lot.

8)  The network you are using may be overloaded (possibly a school network), or you have other applications running in the background on your computer, or your virus checker is doing a scan.  Sometimes, just trying to access the MIT server a few minutes later will give you a more favorable response.

9)  If you have BlueStacks on your home PC (BlueStacks is a special emulator that allows Android apps to run on a PC).  The Google emulator on AI2 cannot run unless BlueStacks is disabled and all of the BlueStacks processes are shut down.  On a Windows PC, you use the Task Manager to 'kill' running processes.

10)  Are you using Sensor controls (except for the clock)?   Most Sensor controls or controls related to sms or the phone do not work in the emulators.  They need to be tested on a device.

11) If this is an issue about the Project loading slowly on your device or on the emulator:  Be aware, the more images, layouts, components you have on a screen, the longer it takes for the emulator and Companion to render the graphical screen.  How fast the emulator renders is partially a function of your hardware...how much ram you have, your cpu clock speed etc. Sometimes, with lots of graphics, the emulator will just give up.   Can you develop live using WIFI or using USB? These options almost always render faster than the emulator but will not be at lightning speed if you have lots of graphics.  Be patient.

12)  This happens too:   We have seen instances where it is probable the Google Cloud messed up; other instances where an older PC has had memory issues and caused file corruption of the Project and instances where a user is using a very slow Internet connection (like dial-up) and it is just too slow.

13)  Do you have an AVG, Eset or AVAST virus checker.  Some versions of these products have been reported inhibit running the emulator unless (in the case of AVG) the Advanced Link settings on the software are set to allow AI2 communication.

Anything on the list familiar to you?      Let us know when/if you get it working.   If it is still a problem, return here and tell us what you tried



Sorry you're having issues. First I'm wondering whether you specified an alternate directory for the setup tools when you installed them. Can you tell me where they reside. Also, if you could try and run the run-emulator.bat command located in the AppInventor/commands-for-Appinventor/run-emulator.bat this should launch the emulator (THIS IS NOT THE PREFERRED WAY TO LAUNCH THE EMULATOR) and let me know if it loaded. You should see the companion app on the phone and it can be started too. 



Thanks for the prompt answer Andrew,
  1. I used an alternate directory on first install, but then revert to the default directory on a subsequent uninstall/reinstall.
    Current directory is C:\Program Files\AppInventor
  2. As I wrote in my OP, the emulator runs fine, either started with emulator.exe or with run-emulator.bat - however, it does not connect to socket http://127.0.0.1:8004/ and thus does not mimic the app that is in App Inventor, namely - this is what I see:

    when the App-Inventor-2/Designer looks like:




Do you have BlueStacks loaded on your PC?   BlueStacks creates serious issues for running AI2.

You are trying to use the emulator to run an existing Project that you coded, there could be issues with the code you reproduced. Have you tried running any other projects?

Try this.   Create a NEW Project from the Designer screen.   Place a button on the screen.  Nothing else.  Go to  Connect>Emulator   and run the new one button project.  Does the simple project display an image of a button?   Knowing this works or does not helps answer your questions.


As you can see in the MIT App Inventor.PNG attachment of my OP, that's precisely what I did. 


You are using Companion version 2.2?   Sorry that is out of date, what you might try doing is


I installed the latest software per http://appinventor.mit.edu/explore/ai2/setup.html instactions (if that's outdated, boy, do they have a speedy version cycles at MIT :-)


   Connect >  Hard Restart .   That should bring up a pop up screen that will allow you to update Companion to the current version.  Follow the directions on the screen


I did that several times, when trying to debug myself, prior to posting my OP.


exactly.  Read every word and it should set up the latest Companion.  When you are done, close your Chrome browser and then restart and try again.  Did that work?

If that did not work, try the in case of issues options here http://appinventor.mit.edu/explore/ai2/support/troubleshooting.html   and follow the recommendations.

There are lots of reasons the emulator might not be working, here are some more possibilities but since you are new, probably only a few apply to you.

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


...


9)  If you have BlueStacks on your home PC (BlueStacks is a special emulator that allows Android apps to run on a PC).  The Google emulator on AI2 cannot run unless BlueStacks is disabled and all of the BlueStacks processes are shut down.  On a Windows PC, you use the Task Manager to 'kill' running processes.

I do have BlueStacks, and when saw your suggestion, I silently said: eureka!
Alas, even with BlueStacks stopped and all BlueStacks processes killed, I still get:


13)  Do you have an AVG, Eset or AVAST virus checker.  Some versions of these products have been reported inhibit running the emulator unless (in the case of AVG) the Advanced Link settings on the software are set to allow AI2 communication.


My antivirus is Avira (version 14.0.7.468 2014-11-24): any known collisions App Inventor 2 emulator has with that antivirus product?


Anything on the list familiar to you?      Let us know when/if you get it working.   If it is still a problem, return here and tell us what you tried



Thanks for the suggestions Steve, but none seem to pinpoint my particular problem.



Some observations Ron:

"As you can see in the MIT App Inventor.PNG attachment of my OP, that's precisely what I did. "    .... No it appears you did not, you put information in the event handler from what I can tell and set the button name to TalkToMe.  The entire project I suggest is a button.   No Block code.   Just add the button.    Oh well.


" (if that's outdated, boy, do they have a speedy version cycles at MIT :-)"   Well, 2.2 is outdated, we are up to 2.23 .   You said you did the Hard Reset?  You can check the companion version by using the Help menu item on the AI2 browser and selecting  About.    Is this version 2.23...?  

Here is another test: Try the connection tester here:  http://appinventor.mit.edu/test/      It should tell you your are running starter version 2.2; does it?


"Avira" might be another one..see if it has an option for 'advanced settings' or something to allow links ...if it does have a place to change this, configure it to allow http://ai2.appinventor.mit.edu/     I do not recommend running without a virus checker, so I do not recommend you turn yours off to test.

You indicated to Andrew you did NOT install the ADB in the default directory.  Did you read the caution?  What this means is that you should NOT use the uninstall.exe file that is associated with the emulator ..Why, because there is a bug the will result possibly in deleting most anything that is in the directory you did install in.
What might be happening is Avira may not be allowing ADB to link.

Did you do what Andrew recommended using an alternative way to start the ADB?     



Decide to start from scratch.
I went to http://appinventor.mit.edu/explore/ai2/update-setup-software.html and followed "How to Update the App Inventor Setup Software"

 

1.  Uninstalled current App Inventor

2.  Booted my machine

3.  Downloaded the latest Windows installer fromhttp://appinv.us/aisetup_windows

4.  Installed the AppInventor_Setup_Installer_v_2_2 (1).exe that I downloaded, accepting all the installer's defaults. The installation directory was chosen by the installer in C:\Program Files (x86)\AppInventor

5.  Logged out and after logging in again - aiStarteris running

6.  Killed all the BlueStack processes

7.  Tried Connect/Emulator. Emulator won't start, though it's not failing as previously

8.  Started emulator using run_emulator.bat

9.  After a few tries, finally emulator is syncing with App Inventor 2


Thanks Steve and Andrew for you invaluable input.


댓글 1개: