Edit Companion App

509 views
Skip to first unread message

Diego Barreiro

unread,
Jul 14, 2017, 12:32:45 PM7/14/17
to App Inventor Open Source Development
Is possible to edit the companion app to change the design?
Because as I see, in this path there is an .AIA format file: https://github.com/mit-cml/appinventor-sources/tree/master/appinventor/aiplayapp
Also, when I build the companion.APK file, I get in https://github.com/mit-cml/appinventor-sources/tree/master/appinventor/buildserver/build a ZIP file with that format; but if I rename it to a .AIA file I get this error: java.lang.IllegalArgumentException: Unable to parse file - cannot locate beginning of $JSON section

So, my question is:
Is possible to convert that into a normal .AIA file to edit the Companion app?

Evan Patton

unread,
Jul 14, 2017, 1:06:14 PM7/14/17
to App Inventor Open Source Development
That depends on exactly what you want to change. The companion app is created in App Inventor (the sources are in aiplayapp as you found), but most of the behavior is part of a Java class AppInvHTTPD. Can you give us a little more info about what you are trying to accomplish?

Evan

Diego Barreiro

unread,
Jul 14, 2017, 3:15:52 PM7/14/17
to App Inventor Open Source Development
Hi Evan, thanks for your response

What I want is to edit Arrangements, Labels' texts, Buttons' colours, etc., so I can redesign the app
I don't know if I have explained myself

Evan Patton

unread,
Jul 24, 2017, 4:17:44 PM7/24/17
to App Inventor Open Source Development
Hi Diego,

You need to do the following relative to the aiplayapp directory in the sources:
1. Rename the edu/mit/appinventor/aicompanion3 directory to follow the App Inventor package convention of appinventor/ai_[yourusername]/MITAI2Companion
2. Zip up all of the files under aiplayapp as an AIA, e.g., MITAI2Companion.aia

Then you should be able to load it into App Inventor to edit the project. Note that you will want to do this on a local instance when the Administrator flag to true. Being an admin will allow you to use the the special Build>Generate YAIL menu item to create the Screen1.yail file. To turn the project back into a structure the buildserver will build, export the project as an AIA and reverse these steps.

Evan

Diego Barreiro

unread,
Jul 30, 2017, 5:41:07 PM7/30/17
to App Inventor Open Source Development
Thanks for the response
I've done it and I changed all the design successfully, but when trying to build the app using `ant PlayApp` I get this error:

     [java] jul 30, 2017 11:33:42 PM com.google.appinventor.buildserver.Compiler generateClasses
     [java] GRAVE: Kawa compile has failed.
     [java] jul 30, 2017 11:33:42 PM com.google.appinventor.buildserver.Compiler generateClasses
     [java] INFORMACIÓN: Kawa compile time: 1.986 secondss
     [java] jul 30, 2017 11:33:42 PM com.google.appinventor.buildserver.Compiler generateClasses
     [java] INFORMACIÓN: Can't find class file: C:\Users\DIEGOB~1\AppData\Local\Temp\1501450419136_0.01837438148805426-0
\youngandroidproject\..\build\classes/io\makeroid\companion\Screen1.classs

BUILD FAILED
D:\Makeroid\appinventor\build.xml:56: The following error occurred while executing this line:
D:\Makeroid\appinventor\buildserver\build.xml:190: Java returned: 1

Total time: 10 seconds

I've changed the package name to io.makeroid.companion in all files

Evan Patton

unread,
Aug 1, 2017, 10:18:11 AM8/1/17
to App Inventor Open Source Development
To compile the app as part of the build process, you will also need to edit project.properties file and change the main property's package. You should also change the ACCEPTABLE_COMPANION_PACKAGE in YaVersion.java to use your updated package name otherwise the server will reject the new version.

Evan

Diego Barreiro

unread,
Aug 1, 2017, 6:42:12 PM8/1/17
to App Inventor Open Source Development
Hello Evan,
Finally we fixed the issue, and now the app compiles perfectly. Installing the app doesn't give errors, and the package is correct too; but we are unable to test apps
We get this error trying to connect to the Live server:

What can cause it? Or what is the solution to it?


Jeffrey Schiller

unread,
Aug 1, 2017, 11:17:45 PM8/1/17
to App Inventor Open Source Development
Without looking at your source, it is hard to say. I suspect that you didn't change the package name in all of the places that you need to. In particular make sure the package name referenced for runtime.scm matches the package name that runtime.scm thinks it should be.

Another issue which you will run into shortly is that Chrome will not allow a page loaded via https to contact the Companion via http. This is the primary reason why ai2.appinventor.mit.edu is not using SSL. You cannot just turn on SSL in the Companion because the Companion would then need a certificate that matches the domain name assigned to the IP address of the particular copy of the Companion.

-Jeff (Companion author)

Diego Barreiro

unread,
Aug 3, 2017, 11:56:59 AM8/3/17
to App Inventor Open Source Development
Hi Jeff

We fixed the companion. We got it to work
There was an error in the .yail file

Thanks for your response

Hybro Team

unread,
Sep 25, 2018, 2:55:15 AM9/25/18
to App Inventor Open Source Development
Hi, I tried to edit the companion and I have generated YAIL, change the src structure to edu.mit.appinventor.aicompanion3 and edited the Project.properties,
but I am still getting this error

Evan Patton

unread,
Sep 25, 2018, 4:38:20 PM9/25/18
to App Inventor Open Source Development
Are there any error messages above the point where you copied below? Usually there is a stack trace of some kind or other warning/error message to indicate why the Kawa compile failed.

Regards,
Evan

Hybro Team

unread,
Oct 7, 2018, 12:53:56 AM10/7/18
to App Inventor Open Source Development
As I quoted, I got the same error (BUILD FAILED) as Diego’s

Evan Patton

unread,
Oct 8, 2018, 4:05:53 PM10/8/18
to App Inventor Open Source Development
Without knowing what changes you've made, it's really hard to help debug your problem. Can you confirm that there are no warnings or errors showing up in App Inventor for the edited companion app? If there are, you will need to correct those first. You may also need to hand edit the package name in the YAIL file after generation so that it matches the path.

Regards,
Evan

Hybro Team

unread,
Oct 19, 2018, 10:57:59 PM10/19/18
to App Inventor Open Source Development
Hello Evan,

I edited the UI (only changing Title, About, Button Color, Height and Width, Font and Font Size, also, I added FAB and some more layout which only show when the FAB Clicked

Hybro Team

unread,
Oct 19, 2018, 11:04:07 PM10/19/18
to App Inventor Open Source Development
C2DAD5EE-A9ED-4235-A713-79189F76CF13.png

Hybro Team

unread,
Nov 3, 2018, 7:35:19 AM11/3/18
to App Inventor Open Source Development
Hi, any solution to my issue ?

Hybro Team

unread,
Nov 5, 2018, 6:33:27 AM11/5/18
to App Inventor Open Source Development
Hello, i changed the package name, edit project.properties file, change the main property's package and change the ACCEPTABLE_COMPANION_PACKAGE in YaVersion.java to io.hybrostudio.companion , then i build it again,
The same error occured : 

companion. -C /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/1541417335086_0.3680513102966282-0/youngandroidproject/../src/io/hybrostudio/companion/Screen1.yail /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/runtime890845151506699326.scm

     [java] Nov 05, 2018 7:29:04 PM com.google.appinventor.buildserver.Compiler generateClasses

     [java] SEVERE: Kawa compile has failed.

     [java] Nov 05, 2018 7:29:04 PM com.google.appinventor.buildserver.Compiler generateClasses

     [java] INFO: Kawa compile time: 2.979 seconds

     [java] Nov 05, 2018 7:29:04 PM com.google.appinventor.buildserver.Compiler generateClasses

     [java] INFO: Can't find class file: /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/1541417335086_0.3680513102966282-0/youngandroidproject/../build/classes/io/hybrostudio/companion/Screen1.class


BUILD FAILED

/Users/apple/Desktop/appinventor-sources/appinventor/build.xml:56: The following error occurred while executing this line:

/Users/apple/Desktop/appinventor-sources/appinventor/buildserver/build.xml:207: Java returned: 1


Total time: 30 seconds

Evan Patton

unread,
Nov 5, 2018, 5:10:59 PM11/5/18
to App Inventor Open Source Development
In Compiler.java, add the line System.err.println(kawaOutput); at line 1226. This will print the compilation error from Kawa to stderr and might give more of a clue as to why compilation is failing.

Regards,
Evan

Mas K

unread,
Nov 13, 2018, 5:36:40 AM11/13/18
to App Inventor Open Source Development
#Ask
What function "rendezvous.appinventor.mit.edu" on Companion App ?

And can it to edit?

Evan Patton

unread,
Nov 13, 2018, 7:42:13 PM11/13/18
to App Inventor Open Source Development
You can, but you will have to run your own rendezvous server. There is code in the misc directory to do this. You will then need to update the rendezvous path in both the companion and in appengine.

Regards,
Evan

Evan Patton

unread,
Nov 13, 2018, 7:43:51 PM11/13/18
to App Inventor Open Source Development
I realize that I didn't answer the first part of your post: The rendezvous server is used to exchange IP address information between the companion app and the web client so that the web client can send code for evaluation to the companion.

Regards,
Evan

nuoxuchen

unread,
Mar 30, 2019, 3:38:56 AM3/30/19
to App Inventor Open Source Development
Hello, I have the same problem, about "runtime error". How do you solve this problem?


在 2017年8月3日星期四 UTC+8下午11:56:59,Diego Barreiro Pérez写道:

Evan Patton

unread,
Apr 1, 2019, 3:55:05 PM4/1/19
to App Inventor Open Source Development
We'd need more information to help you solve your issue (and consider opening a new thread as this one is rather out of date). For example, can you use adb to get the logcat and show us the full stack trace for the RuntimeException?

Regards,
Evan

Abhijith Dominic

unread,
Jun 28, 2019, 12:38:13 PM6/28/19
to App Inventor Open Source Development
Hi,
I have Edited the Companion, Generated the Yail and changed the package name in the Yail file and in project.properties but i am receiving the Runtime error of : Attempt to Invoke virtual method........ on a Null object Reference. Its the same Error Diego has Received.
Any Idea Why this Happens?

Thanks

Abhijith Dominic

unread,
Jun 29, 2019, 9:00:55 AM6/29/19
to App Inventor Open Source Development
Hello,
I Have Managed to Fix the Runtime Issue. In Case anyone else is having the same Problem... This is the Solution.

In your .yail file, there is this line of Code : (define-form your.packagename.Screen1 Screen1). You have to Modify the Code like this :
(define-repl-form your.packagename.Screen1 Screen1). -repl has to be added manually.

Hope this helps Anyone in the Future.
Thanks

Reply all
Reply to author
Forward
0 new messages