Skip to content

[GSoC] Android App Bundles#2237

Merged
ewpatton merged 20 commits intomit-cml:masterfrom
barreeeiroo:gsoc
Jan 13, 2021
Merged

[GSoC] Android App Bundles#2237
ewpatton merged 20 commits intomit-cml:masterfrom
barreeeiroo:gsoc

Conversation

@barreeeiroo
Copy link
Member

@barreeeiroo barreeeiroo commented Jul 10, 2020

Closes #1903

This PR adds the feature to export MIT App Inventor 2 projects as Android App Bundles (.aab), to be distributed through Google Play Store. This is part of my Google Summer of Code 2020 project proposal.

Changes in this pull can be seen live at aab.appinventor.barreiro.xyz.
Some useful docs can be found in this folder.

Maybe this should be merged with "Squash & Merge" to just make a single commit with the feature.

@barreeeiroo
Copy link
Member Author

So, it seems like JAVA_HOME environment variable is set in some Linux machines, and it is causing an error in the signing step. I'll consider other options, like maybe calling command line directly (as jarsigner command is installed when installing java), or maybe adding the executable binary into the sources.
Thoughts?

@ewpatton ewpatton modified the milestones: GSOC Release, nb187 Dec 1, 2020
Copy link
Member

@ewpatton ewpatton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mostly there. There are a few things to address but not much. Also, is protoc acutally used anywhere? If so, why is only the mac version checked in? If not, we should remove the binary since it just increases the repo size for no reason.

@barreeeiroo If you want me to make the changes, please let me know.

@Description("Download button shown in barcode dialog")
String barcodeDownloadAab();

@DefaultMessage("<b>Click the button to download the app, right-click on it to copy a download link, or scan the " +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something we should check is whether this affects the translations. If so, we may want to keep it as two separate strings so we can reuse the existing translations.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May want to check the other entries for issues as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Humm, it will probably show the older version in the other languages until someone manually changes it. I have now moved it into a barcodeWarning2 key, to always force to display the updated one (although it will require a translation anyway) and don't show different content depending on language.

@barreeeiroo
Copy link
Member Author

barreeeiroo commented Dec 4, 2020

This is mostly there. There are a few things to address but not much. Also, is protoc acutally used anywhere? If so, why is only the mac version checked in? If not, we should remove the binary since it just increases the repo size for no reason.

@barreeeiroo If you want me to make the changes, please let me know.

@ewpatton I would like to make the changes by myself, if possible. When do you wish to have them, so I can get some time for it?
And yes, I mistakenly forgot to remove protoc, it is not used anywhere.

@ewpatton
Copy link
Member

ewpatton commented Dec 4, 2020

I'd like to put this into the upcoming release this month. We're planning to update the test server today but can put in this version without merging the change to master. If we could have a final version by next week that'd be helpful.

@ewpatton
Copy link
Member

ewpatton commented Dec 4, 2020

@AppInventorWorkerBee retest this please

@jisqyv jisqyv self-requested a review December 5, 2020 03:03
Copy link
Member

@jisqyv jisqyv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I run "ant PlayAppAab it fails:

 [java] INFO: ____Executing null/bin/jarsigner -sigalg SHA256withRSA -digestalg SHA-256 -keystore /tmp/1607138147663_0.5920950606732425-0/android.keystore -storepass android /tmp/1607138147663_0.5920950606732425-0/youngandroidproject/../build/deploy/MIT AI2 Companion.aab AndroidKey
 [java] Dec 04, 2020 10:16:18 PM com.google.appinventor.buildserver.Execution execute
 [java] WARNING: ____Execution failure: 
 [java] java.io.IOException: Cannot run program "null/bin/jarsigner": error=2, No such file or directory

if (osName.equals("Mac OS X")) {
jarsignerTool = System.getenv("JAVA_HOME") + "/bin/jarsigner";
} else if (osName.equals("Linux")) {
jarsignerTool = System.getenv("JAVA_HOME") + "/bin/jarsigner";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work. JAVA_HOME isn't necessarily set in the buildserver environment. You should use System.getProperty("java.home"). However this gives you the JRE home. So you have to do a ../bin/jarsigner to get to it. You can construct the path identically for Mac OS and Linux. But you have to separate out Windows because of the need to add the .exe on the end of the jarsigner binary name.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we use the JDK in the Docker image, we can bypass all this by invoking jarsigner without any qualification as it'll be in the PATH. I've tried this on macOS 10.15, Windows 10, and Ubuntu 18.04 and it worked (no need to even specify .exe on Windows). However, since we only use the JRE in the buildserver image, we would need to embed the jarsigner executable similarly to other tools (aapt, apksigner, etc.). Since we don't have the rights to redistribute jarsigner, it seems like using the JDK in the buildserver is the safer route.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already embed jarsigner (the buildserver has the jre and a few additions from the jdk). We used to use it a few versions ago before we switched to apksigner.

@ewpatton
Copy link
Member

ewpatton commented Dec 5, 2020

Regarding my previous comment, here is the diff of what I tested.

diff --git a/appinventor/buildserver/src/com/google/appinventor/buildserver/Compiler.java b/appinventor/buildserver/src/com/google/appinventor/buildserver/Compiler.java
index 2a4da1b803..bcca6e91f8 100644
--- a/appinventor/buildserver/src/com/google/appinventor/buildserver/Compiler.java
+++ b/appinventor/buildserver/src/com/google/appinventor/buildserver/Compiler.java
@@ -2454,20 +2454,7 @@ public final class Compiler {
   private boolean bundleTool(File buildDir, int childProcessRam, String tmpPackageName,
                              String outputFileName, File deployDir, String keystoreFilePath, String dexedClassesDir) {
     try {
-      String osName = System.getProperty("os.name");
-      String jarsignerTool;
-      if (osName.equals("Mac OS X")) {
-        jarsignerTool = System.getenv("JAVA_HOME") + "/bin/jarsigner";
-      } else if (osName.equals("Linux")) {
-        jarsignerTool = System.getenv("JAVA_HOME") + "/bin/jarsigner";
-      } else if (osName.startsWith("Windows")) {
-        jarsignerTool = System.getenv("JAVA_HOME") + "\\bin\\jarsigner.exe";
-      } else {
-        LOG.warning("YAIL compiler - cannot run Jarsigner on OS " + osName);
-        err.println("YAIL compiler - cannot run AAPT2 on OS " + osName);
-        userErrors.print(String.format(ERROR_IN_STAGE, "AabCompiler"));
-        return false;
-      }
+      String jarsignerTool = "jarsigner";
       String fileName = outputFileName;
       if (fileName == null) {
         fileName = project.getProjectName() + ".aab";

@jisqyv
Copy link
Member

jisqyv commented Dec 5, 2020

With Evan's patch things seem to work with our normal buildserver (containerized) environment.

@ewpatton ewpatton added the on ai2-test Code is deployed on ai2-test.appinventor.mit.edu label Dec 6, 2020
@ewpatton ewpatton merged commit 6516283 into mit-cml:master Jan 13, 2021
Vishwas-Adiga pushed a commit to Vishwas-Adiga/appinventor-sources that referenced this pull request Apr 5, 2021
@jisqyv jisqyv removed the on ai2-test Code is deployed on ai2-test.appinventor.mit.edu label Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate Android App Bundles

3 participants