Updated on / dernière mise à jour : 06/15/2022
Good day all,
Here's a solution to the 5 meg limit imposed by MIT's App Inventor Classic and App Inventor 2…
1) Save your AI app as a .apk file.
2) Download ApkTool from http://ibotpeaches.github.io/Apktool and install it to your computer.
3) Copy your .apk file to the Apktool folder located in your computer's c: drive (should normally be located at c:/apktool).
4) Open your computer's command prompt terminal; be sure to go back to the c:/ by typing cd.. in the terminal (you may have to do so more than once). Once at c:/, type cd apktool (if you installed Apktool in this particular folder, that is).
5) Still in the terminal, type apktool d NameOfYourFile.apk (i.e.: apktool d Test.apk). This will "unzip" your .apk file and a folder (NameOfYourFile) shall be created; in it, you'll find your .apk's manifest and other related folders and files. If you see a folder called meta-inf, delete it. Open the asset folder; you will be able to update your files there (delete or add any required files for your app)… The good news is: no need to worry about the 5 meg limit anymore!
6) Once this is done, go back to the terminal and type apktool b NameOfYourFile NameOfYourFile.apk (i.e.: apktool b Test Test.apk).
7) By doing so, you now "zipped" back your app to a standard .apk file, which also includes the files you added to the asset folder. Copy this new .apk file back to your desktop…
8) You will now have to use a program called JarSigner in order to sign your .apk file. It is notably included to Java version 184.108.40.206 and that is the version that I use (Jarsigner may not be included to later versions of Java though). Hence, you can download Java 220.127.116.11 from http://filehippo.com/download_jre_32/14872/. Once this Java version is downloaded and installed to your computer, you will have to open a command prompt terminal and locate the Jarsigner program. In my computer, it is under Java's bin folder… c:/Program Files/Java/jdk1.6.0_45/bin/… Another way to do it, since it is important to keep an updated version of Java on your computer, could be to install Sejda PDF Desktop on your PC (free version) instead; this program also includes JarSigner (under the folder C:\Program Files\Sejda PDF Desktop\resources\vendor\java\bin).
9) Once in the bin folder (and always in your command terminal), type: jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 -keystore android.keystore C:LocationOfYourDesktopNameOfYourFile.apk androidkey (i.e.: jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 -keystore android.keystore C:UsersRobDesktopTest.apk androidkey)… N.B.: remember that your android.keystore file must also be included to this particular bin folder; your apps' android.keystore file can be downloaded from your app creation platform (ie.: MIT's app inventor 2). If this file is not placed under the bin folder, the command simply won't work.
10) Jarsigner will ask for your keystore passphrase… by default, the AI keystore passphrase (or password) is "android". Your .apk is now signed. Bravo.
11) Before uploading it to Google Play, you still need to zipalign it! The Zipalign tool is part of Android SDK (1.6 onwards) and can be found under the tools folder of the SDK. To use it, you will have to run the following command in your terminal: zipalign -v 4 source.apk destination.apk. In example: zipalign -v 4 Test.apk Test2.apk … Once the zipping is done, delete Test.apk and rename Test2.apk to Test.apk (in order to preserve the original name of the file). NB.: some people told me they just can't find this file in Android Studio… Zipalign can be found under the following folder on your PC (once Android Studio is installed): C:/Users/YourOwnUserNameOnYourPC/AppData/Local/Android/Sdk/build-tools/30.0.3/zipalign (ie.: C:/Users/Robert/AppData/Local/Android/Sdk/build-tools/30.0.3/zipalign). An idea: create a new folder called Zipalign under c:/, copy the Zipalign file in it; when you need to zipalign your app, simply copy the apk file to this new Zipalign folder and run zipalign in the terminal. Voilà!
12) Test your .apk in your mobile phone and if everything's fine you'll be ready for uploading it to Google Play !