I've been working on developing a new CLI tool aimed at automating tasks for App Inventor projects. The project is currently in its development phase. While drafting the todo list, a question came to mind, and I could use some clarification.
I came across this command from the App Inventor buildserver documentation:
$ ant RunMain -Dzip.file=$HOME/MyDownloads/ImageUpload.zip -Duser.name=$USER -Doutput.dir=/tmp
My question is: Can this command be used to compile a .aia file (renamed to .zip) into an .apk?
Additionally, I have a few other related questions:
Will this command successfully compile an .aia into an .apk?
What additional dependencies (such as Java or Ant) are required to make it work?
Is the Android SDK necessary for this process?
Is the entire buildserver folder required, or are only specific components/files needed?
Could someone explain the internal process of compiling .aia to .apk? I understand this might be a lengthy explanation, so a summary would be greatly appreciated.
What is that Duser.name? And why is it required
Note: I don't want to use the full mit-cml repo cloned and then using the Build Server from there, instead only downloading the buildserver from the mit-cml repo and then using it with the CLI tool
I would like to take suggestions over this by Sir @ewpatton too
You do not need ant to run this. The minimum required set of items is the appropriate version of the JRE (e.g., Java 11) and the contents of the buildserver/build/run/lib directory after having compiled App Inventor. Then, from a directory containing the libs you can run:
This runs a build of foo.zip for user 'foo' and outputs the APK file (foo.apk) in the current working directory. If you need an AAB instead of an APK, adjust --ext accordingly.
We decompose the compilation process into a sequence of discrete tasks. You can look at the logic in AndroidBuildFactory.java in the buildserver module to see how the extension derives the specific sequence of tasks needed to compile the target. I won't go into detail since the code outlines what steps are needed to convert the AIA into the APK.
If the user doesn't have an existing android.keystore file, the username is used as the Common Name (CN) field of the certificate in a newly generated android.keystore file.
We don't publish compiled versions, so there isn't really a way to avoid this. To minimize the amount of building involved, you should cd buildserver and run ant to compile the buildserver. At that point you can copy the directory mentioned earlier to whatever system you are using to deploy your build infrastructure.
We will be deprecating Java 8 support in the near future as Google has dropped support for it from App Engine and the newer build tools for Android need Java 11 at a minimum (and likely soon to be Java 17). Currently, our code base can be built with either Java 8 or 11.
You will need the JDK to build the buildserver code, but once its built you only need the JRE to run it as the buildserver itself is self-contained.
Correct. This is effectively what we do in App Inventor. We compile with the JDK, but the buildserver images we deploy on our servers only bundle the JRE.