I am working on a CICD pipeline for a React Native Android mobile application using AWS Code Build and Code Pipeline.
When build a debug bundle (./gradlew bundleDebug) the resulting .aab file is not signed:
>keytool -printcert -jarfile app-debug.aab
Not a signed jar file
When I build a release bundle (./gradlew bundleRelease) the resulting .aab file is signed properly.
This is the relevant portion of my build.gradle:
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
release {
storeFile file('release.keystore')
storePassword System.getenv('GOOGLE_KEYSTORE_PWD')
keyAlias System.getenv('GOOGLE_KEYSTORE_ALIAS')
keyPassword System.getenv('GOOGLE_KEYSTORE_PWD')
}
}
buildTypes {
release {
// Caution! In production, you need to generate your own keystore file.
// see https://reactnative.dev/docs/signed-apk-android.
signingConfig signingConfigs.release
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
I inject the base64 decoded release certificate from AWS Secrets Manager into the project source at android/app/release.keystore in the build script. The debug.keystore, release.keystore and build.gradle exist in the code repo at android/app/. gradlew bundleXXXX is run from the android directory.
Initially, when I ran gradlew signingReport it recognized both the release and debug keystores in the codebuild source location /codebuild/output/src634901523/src/android/app/. But, it was followed by several missing keystore errors for /root/.android/debug.keystore.
2023-01-11T09:26:22.714-05:00 > Task :app:signingReport
2023-01-11T09:26:22.714-05:00 Variant: debug
2023-01-11T09:26:22.714-05:00 Config: debug
2023-01-11T09:26:22.714-05:00 Store: /codebuild/output/src634901523/src/android/app/debug.keystore
2023-01-11T09:26:22.714-05:00 Alias: androiddebugkey
2023-01-11T09:26:22.714-05:00 MD5: 20:F4:61:48:B7:2D:8E:5E:5C:A2:3D:37:A4:F4:14:90
2023-01-11T09:26:22.714-05:00 SHA1: 5E:8F:16:06:2E:A3:CD:2C:4A:0D:54:78:76:BA:A6:F3:8C:AB:F6:25
2023-01-11T09:26:22.714-05:00 SHA-256: FA:C6:17:45:DC:09:03:78:6F:B9:ED:E6:2A:96:2B:39:9F:73:48:F0:BB:6F:89:9B:83:32:66:75:91:03:3B:9C
2023-01-11T09:26:22.714-05:00 Valid until: Tuesday, April 30, 2052
2023-01-11T09:26:22.714-05:00 ----------
2023-01-11T09:26:22.714-05:00 Variant: release
2023-01-11T09:26:22.714-05:00 Config: release
2023-01-11T09:26:22.714-05:00 Store: /codebuild/output/src634901523/src/android/app/release.keystore
2023-01-11T09:26:22.714-05:00 Alias: ***
2023-01-11T09:26:22.714-05:00 MD5: ***
2023-01-11T09:26:22.714-05:00 SHA1: ***
2023-01-11T09:26:22.714-05:00 SHA-256: ***
2023-01-11T09:26:22.714-05:00 Valid until: Saturday, May 28, 2050
2023-01-11T09:26:22.714-05:00 ----------
2023-01-11T09:26:22.714-05:00 Variant: debugAndroidTest
2023-01-11T09:26:22.714-05:00 Config: debug
2023-01-11T09:26:22.714-05:00 Store: /codebuild/output/src634901523/src/android/app/debug.keystore
2023-01-11T09:26:22.714-05:00 Alias: androiddebugkey
2023-01-11T09:26:22.714-05:00 MD5: 20:F4:61:48:B7:2D:8E:5E:5C:A2:3D:37:A4:F4:14:90
2023-01-11T09:26:22.714-05:00 SHA1: 5E:8F:16:06:2E:A3:CD:2C:4A:0D:54:78:76:BA:A6:F3:8C:AB:F6:25
2023-01-11T09:26:22.714-05:00 SHA-256: FA:C6:17:45:DC:09:03:78:6F:B9:ED:E6:2A:96:2B:39:9F:73:48:F0:BB:6F:89:9B:83:32:66:75:91:03:3B:9C
2023-01-11T09:26:22.714-05:00 Valid until: Tuesday, April 30, 2052
2023-01-11T09:26:22.714-05:00 ----------
2023-01-11T09:26:22.714-05:00
2023-01-11T09:26:22.714-05:00 > Task :react-native-app-auth:signingReport
2023-01-11T09:26:22.714-05:00 Variant: debugAndroidTest
2023-01-11T09:26:22.714-05:00 Config: debug
2023-01-11T09:26:22.714-05:00 Store: /root/.android/debug.keystore
2023-01-11T09:26:22.714-05:00 Alias: AndroidDebugKey
2023-01-11T09:26:22.714-05:00 Error: Missing keystore
2023-01-11T09:26:22.714-05:00 ----------
2023-01-11T09:26:22.714-05:00
2023-01-11T09:26:22.714-05:00 > Task :react-native-async-storage_async-storage:signingReport
2023-01-11T09:26:22.714-05:00 Variant: debugAndroidTest
2023-01-11T09:26:22.714-05:00 Config: debug
2023-01-11T09:26:22.714-05:00 Store: /root/.android/debug.keystore
2023-01-11T09:26:22.714-05:00 Alias: AndroidDebugKey
2023-01-11T09:26:22.714-05:00 Error: Missing keystore
2023-01-11T09:26:22.714-05:00 ----------
...
So, in my build script, I also copied the debug.keystore to /root/.android/debug.keystore and this removed all missing keystore errors in the signingReport.
However, I still cannot get any debug .aab signed. While, the release .aab is signed with the release certificate properly.
I've tried many different combinations of build.gradle settings and providing the keystore files in different locations. Including adding an equivalent debug build type which references the debug signingConfig. Nothing will fix this issue I can find. Prior to this endeavor, we were successfully building a signed .apk using the debug.keystore as a release type with ./gradlew assembleRelease. But now I need to have a production bundle I can upload to Google signed with a valid cert, while keeping the lower level environments signed with the debug.keystore.