AI2 USB Connection works but AI2 says Companion not started when it is

I'm successfully using https://code-appinventor-mit-edu.ezproxy.canberra.edu.au (also tested this in ai2. as well) far as working in it, creating apps, etc. My desktop is Ubuntu v22. However, I wanted to be able to use the USB connection to my Android tablet, and have all that setup per info here Connecting to an Android phone or tablet with a USB cable .... I also have the AI2 Companion (v2.71u) running on my tablet. I don't use Wifi, so wished to use the USB connection, and I have it set on the tablet in the debug mode, mass storage setting, but not mounted on the desktop (all per the setup-device-usb page). I have supplied a series of screenshots below, that shows what happens.

Clicking on the USB connection option in AI2 interface, it does an attempt to connect to the USB, it then says it has connected to the USB, and then it goes on and attempts to open the "Companion" (which I can only imagine is the AI2 Companion which I already have running on the tablet), and finally after a number of tries, it says "Connection Failure: We could not start the MIT AI Companion with the Emulator. " Please see screenshot series below. What I don't understand is where does the Emulator suddenly come into this, when I am attempting to use the USB connection to connect to the tablet which is running the AI2 Companion already. And don't understand why it is failing.

I also supply an output of the test page: Test for Emulator/USB Connection Software which shows the "phone" (tablet) is connected to the desktop via USB, and that aiStarter is indeed started. See the screenshot below.


Note: You can also Right-Click and open this image in a NEW TAB, and Shift-Ctrl-++ to enlarge it.

BTW referring back to my previous post, I noted this info on the link below. So, "aiStarter" is used to let the USB connection work, or the Emulator work. However, as you can see in the prevous post, I was selecting the "USB" option, so I don't understand why it errors out at the end saying it could not start aiStarter in the Emulator.... In the screenshot in the previous post, I show that aiStarter test says it is running, so why does the USB menu option, error out doing anything with AI Companion in the Emulator? Seems like something is not right in the code?

https://appinventor-mit-edu.ezproxy.canberra.edu.au/explore/ai2/setup-emulator
"Using the emulator or the USB cable requires the use of a program named aiStarter. This program is the helper that permits the browser to communicate with the emulator or USB cable. The aiStarter program was installed when you installed the App Inventor Setup package. You do not need aiStarter if you are using only the wireless companion."

Additionally, I attempted a test of the AI2 Connect > USB with the Blockly version, and it gives a slightly different verbage end result with a "see this web page" for help, but the link goes to a page that says it no longer exists. And, it is still the same issue, I am trying to perform a Connect > USB, not a Connect > Emulator, so why is the USB connect to my Android tablet - while the USB Connected works - yet it fails on "connect to the Android emulator" ? Something is amiss.

image

Do you see any error messages in the aiStarter output? Or are there any error messages in the browser dev tools? It sounds like the process is mostly working if it's getting as far as detecting the USB is connected but unable to verify that the companion started.

No problem here (on a Pixel 7 Pro, Android 14):

Did you enable "Developer options"?
If so take a look here: https://community-appinventor-mit-edu.ezproxy.canberra.edu.au/t/nb189-emulator-issue-aistarter-download-link-issue/59727/17

Affirmative, I set all the developer settings as described on the tablet (Developer Options: USB Debugging, as well as when the tablet is attached over USB it is in mass-storage, and NOT mounted).... I believe I also made reference to the settings in my first post... also, the screenshot I showed in previous post also shows the USB Connection succeeded, but it thereafter it was trying to verify the Companion (on phone) was running, but finally failed saying it can't load it in the Emulator, which I don't understand since I chose Connect > USB, did not select Connect >Emulator, so no idea why the Emulator bit came into this during my testing (please examine screenshots I provided in the above posts)....

Another important question that comes up for me is this:
Help with aiStarter
QUOTE: "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."

So, I am running Ubuntu Linux v22, and am using https://code-appinventor-mit-edu.ezproxy.canberra.edu.au to do AI2 coding. I was also told that MIT does not provide/support any local computer software, so I don't understand that reference to "install the App Inventor Setup software". I am aware of the alternative AI2Offline being available, but does that have anything to do with the "App Inventor Setup software" being mentioned? If not, then what exactly is the "App Inventor Setup software"???

PS: I do see that the MIT website has these links refering to "App Inventor Setup software"
https://appinventor-mit-edu.ezproxy.canberra.edu.au/explore/ai2/setup-emulator

Step 1. Install the App Inventor Setup Software

Finally, that is also when I tried the AI2Offline, and that all worked fine far as using AI2 Web UI locally in browser, and building a .apk, and actually this is what allowed Code.appinventor.mit.edu to Connect > USB for me, but kept failing on checking for whatever components or the Companion to run (and then claimed to try to run Companion in the Emulator which I thought was strange).

So, now I am backtracking about what is "App Inventor Setup Software" because it seems to be where the issue may be....

I didn't mention anything about AI2Offline here. I use it with the main AI2 server. But it should work with code.appinventor.mit.edu too. My OS is Windows.

You beat me to the punch at posting more/less - I added some additional info... Also I mentioned that I / me was looking at AI2Offline as well... see my previous post. Particularly what I posted about "App Inventor Setup Software"

Hmm, what are you getting at? What's your problem?

I have just done a fresh install of the aiStarter software on my Xubuntu 22.04 LTS
(I had an old version installed so needed the uninstall commands too)

 2000  sudo rm -rf /usr/google/appinventor
 2001  sudo rm -rf ~/.appinventor
 2002  cd Downloads
 2003  sudo dpkg --install appinventor2-setup_2.3_all.deb
 2004  /usr/google/appinventor/commands-for-Appinventor/aiStarter &

  • Turned of wifi on my phone
  • Connected phone to computer
  • Set connection to usb debugging
  • Started AI Companion app
  • Opened a project in AI2 on my computer
  • Clicked Connect, then USB, and let the magic happen
  • After a couple of checks by AI2, project up and running on phone via USB

Directions from these two pages:

https://appinventor-mit-edu.ezproxy.canberra.edu.au/explore/ai2/linux
https://appinventor-mit-edu.ezproxy.canberra.edu.au/explore/ai2/setup-device-usb#step1

I believe I explained the issue and what i was then reviewing to see where the issue is... I can lay it out more simply perhaps...

1 - https:// code.appinventor.mit.edu Connect > USB
Works with my AI2Offline aiStarter running
USB Connects to tablet - see screenshot (above) please? It says USB Connected
But then it procedes to check to see if Companion is loaded, and then
finally exists with error about can't load the Companion in the Emulator (which is weird)

2 - I then backtrack and ask myself:
What is the this "App Inventor Setup Software" ... I see it is an old old .deb package
that does not work anymore on Linux, and even bombed with ./McKinney/ path name
meaning it was developed and packaged by that guy and it won't work.
And, MIT has stated they don't support desktop software.
Reference:
Connecting to an Android phone or tablet with a USB cable
Installing App Inventor 2 Setup on GNU/Linux

Summary: long story short - there does not appear to be a working "App Inventor Setup Software" for Linux. I say that based on the previously described experiences... and this prevents the USB connection to phone/tablet from working.

PS: TMAI2 I just now saw you post, after I posted the above... fyi I did NOT have any old version of app inventor locally....not until what i just explained. I am willing to try the .deb again, but it did not work for me first time.

Try this direct download url to download (may be time related so do it now)

https://mv-ezproxy-com.ezproxy.canberra.edu.au/api/public/dl/imWo1j1r

The file is 71.6mb

Downloading thank you

PS: have to follow this up tomorrow sometime, thank you. But looks like same one I downloaded last week.

-rw-rw-r-- 1 pgb pgb 75112754 Aug 15 18:25 'appinventor2-setup_2.3_all(1).deb'
-rw-rw-r-- 1 pgb pgb 75112754 Aug 4 17:48 appinventor2-setup_2.3_all.deb

How do you connect to the Internet from that tablet?

I had copied the AI Companion (v2.71u) from the desktop to the tablet over bluetooth. :wink:

I still have to try the desktop .deb install (again) later today... see later.

TIMAI2, and all,

So I started off rebooting the Ubuntu v22 computer, then doing the cleanup steps, checked the lib32z1 was already installed, and install step for the .deb package (the one you linked me to), ran the aiStarter and saw it listening in the terminal, (and fyi the developer setting was already in place for usb on the tablet), got into code.appinventor.mit.edu to an app, and did the Connect > USB, and there we go, it worked! And this time it did indeed load up the AI Companion on the tablet automatically and brought in the app on it.

dpkg-query -l | grep lib32z1 #already installed
apt-get install lib32z1 #says already latest vs.
ls -ld /usr/google/appinventor #dir not there
ls -l ~/.appinventor/* #removed "emulator" from the AI2Offline I believe.
ps ufax | grep aiStarter #made sure not running in process list
dpkg -i 'appinventor2-setup_2.3_all(1).deb' #install the newly downloaded .deb package
ls -ld /usr/google/appinventor/* #new stuff appeared
/usr/google/appinventor/commands-for-Appinventor/aiStarter & #ran and listened in terminal
[1] 138860
root@mypc:~# Bottle server starting up (using WSGIRefServer())...
Listening on http://127.0.0.1:8004/
ps ufax | grep aiStarter #saw running in process list
root@mypc:~/.appinventor# netstat -a
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 localhost:8004 0.0.0.0:* LISTEN

Test Page:

Is aiStarter running?

YES, aiStarter v2.3 running!

Is your phone connected via USB?

YES, your phone is connected via USB!

So it appears my previous issues I ran into were (A) the former .deb file (the "App Inventor Setup Software") install did not work right for some reason that first time, and I had to uninstall that .deb at the time, then (B) I also tested AI2Offline which also has an aiStarter, so that confused things, though the USB connection worked, it could never start the Companion. So at this point, things are good.

Thank you all.

(added to Platforms section of FAQ)