Android Question Instructions on use of the new 10.7 Build App Bundle feature?

CaptKronos

Active Member
Licensed User
Thanks Erel. These are the steps I took to successfully upload a new test project.
B4X:
c:\java\jdk-11.0.1\bin\keytool -genkey -v -keystore my-release-key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias b4a

c:\java\jdk-11.0.1\bin\keytool -exportcert -rfc -keystore my-release-key.jks -alias b4a -file upload_certificate.pem
(Erel's instructions were missing a space between b4a and -file)

C:\Android\build-tools\30.0.3\zipalign.exe -v -p 4 Objects\Test.aab TestAligned.aab

C:\Android\build-tools\30.0.3\apksigner.bat sign --ks my-release-key.jks --out signed.aab --min-sdk-version 14 TestAligned.aab
(I had to add the "--min-sdk-version 14" to fix the error: "Failed to determine APK's minimum supported platform version.")
I'm not sure if the zipalign command is required. I tried with and without, and both worked.
I'm not sure why the apksigner couldn't determine the min SDK version.

Next step will be to try with an already published app.
 
Upvote 0

CaptKronos

Active Member
Licensed User
It's a completely new app. As I said, the next thing I'm going to do is try with an app that has already been published.
 
Upvote 0

CaptKronos

Active Member
Licensed User
Successfully completed an App Bundle upgrade with an existing app. Here are the steps I took.

Within Google Play Console, click on "Create new release" as per usual and then click the "Opt-in" button.

Choose "Export and upload a key from Java keystore".

You can then follow the steps shown under this option, but just to be explicit this is what I did:

Download PEPK tool and run:
B4X:
java -jar pepk.jar --keystore="C:\Users\bob_n\Documents\Basic4Android\bob.keystore" --alias=b4a --output=encrypted_private_key_path --encryptionkey=eb10fxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
The keystore value is the contents of File in B4A's Tools->Private Sign Key dialog box.
The encryptionkey value is the value shown on the currently visible Google Play Console page.

On running the above pepk command, you will be asked for a password. Use the password from the Private Sign Key dialog.

Upload the resulting file "encrypted_private_key_path" by clicking the Google Play Console "Upload the upload key certificate".

I didn't do the optional step: "For increased security, create a new upload key (optional)".

You should now be able to upload aab files just as easily as apk files.
 
Upvote 0

CaptKronos

Active Member
Licensed User
About the new app:

What happens if you switch the signing key to my-release-key.jsk in the IDE?
Do you still need to do any extra step?
You can do it with #SignKeyFile.

If it works, I can add a conditional symbol for AAB to make it simpler.
As a sanity check, I compiled the new app (called test) using my regular keystore. On uploading to the Google Play Console I received the following (expected) error: "Your Android App Bundle is signed with the wrong key. Ensure that your App Bundle is signed with the correct signing key and try again. Your app bundle is expected to be signed with the certificate with fingerprint:"
Then, within the IDE, I switched to using my-release-key.jsk as the keystore and entered the corresponding password. I exited the Private Sign Key dialog and then re-entered it. my-release-key.jsk seemed to have been loaded correctly (the "Signature (read only)" field was populated).
I ran Build App Bundle and unfortuately received a fail at the sign stage:
B4X:
B4A Version: 10.70 BETA #2
Parsing code.    (0.01s)
    Java Version: 8
Building folders structure.    (0.04s)
Compiling code.    (0.09s)
    
ObfuscatorMap.txt file created in Objects folder.
Compiling layouts code.    (0.00s)
Organizing libraries.    (0.00s)
    (AndroidX SDK)
Compiling resources    (0.11s)
Linking resources    (0.58s)
Compiling generated Java code.    (1.32s)
Convert byte code - optimized dex.    (0.44s)
Copying libraries resources    (14.12s)
Building app bundle    (7.28s)
Signing AAB file    Error
On checking the project's Objects folder I found: test.aab and test.aab.sig
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Thank you for your help!

I'll soon release beta #3 which will make signing new apps simpler.
You need to add code similar to:
B4X:
#if AAB
    #SignKeyFile: my-release-key.jks
    #SignKeyPassword: xxxxxxx
    #SignKeyAlgorithm: -digestalg SHA1 -sigalg SHA256withRSA
#end if

AAB is a conditional symbol that is added automatically when building bundles.
 
Upvote 0

CaptKronos

Active Member
Licensed User
Somehow I missed the beta #3 release, but having now tried it, I can confirm that using the new AAB conditional symbol works very well.
 
Upvote 0
Top