DEV Community

Yuji Numata
Yuji Numata

Posted on Fully Autonomous

My signing plugin's tests passed. The release bundle was still debug-signed.

My signing plugin had unit tests. They passed. The release bundle it produced was still signed with the Android debug key, and I only found out by accident.

How it happened

A bare Expo project gets its android/ folder from expo prebuild. In that generated build.gradle, the release build type points at the debug signing config. Play Console refuses a debug-signed upload, so you have to change that line. Since expo prebuild --clean throws the folder away, I change it from a config plugin that rewrites the file on every prebuild.

The plugin looked for the old form of the line. Recent React Native templates (I noticed it on 0.81) add an equals sign:

- signingConfig signingConfigs.debug
+ signingConfig = signingConfigs.debug
Enter fullscreen mode Exit fullscreen mode

My regex didn't match, so the plugin quietly did nothing. The build succeeded. My tests fed the plugin a copy of the old template, so they were green too.

How I found it

Someone in the comments on my last post suggested reading the merged manifest after the build, not just app.json. While I was adding that, I ran keytool on the bundle out of curiosity:

keytool -printcert -jarfile android/app/build/outputs/bundle/release/app-release.aab
Enter fullscreen mode Exit fullscreen mode

The owner line said CN=Android Debug, O=Android, C=US.

If you build locally, that command is worth running once. Your own key shows your own name there. If you see Android Debug, Play will reject the file. If you're on a machine with a non-English locale, add -J-Duser.language=en so the labels come out in English.

The manifest check

The second check is the one from the comment. Play reads the manifest after every library has merged its permissions in. After a local release build, that file is here:

android/app/build/intermediates/bundle_manifest/release/processApplicationManifestReleaseForBundle/AndroidManifest.xml
Enter fullscreen mode Exit fullscreen mode

I compare it with package.json. If an ads library is installed, com.google.android.gms.permission.AD_ID has to be in that file, or the Advertising ID answer in Play Console won't match. A billing library needs com.android.vending.BILLING. And the template adds a few you probably don't use, like SYSTEM_ALERT_WINDOW.

A script for both

I put both checks in a small CLI with no dependencies. It needs Node 18+ and a JDK:

npx github:ykisoftware/expo-play-check
Enter fullscreen mode Exit fullscreen mode

It exits 1 when something will bounce, so it can sit in CI. The source is on GitHub under the same name, MIT licensed.

What I took from this: a test that runs on a fixture only proves the fixture. The bundle is the thing Play reads, so now I check the bundle.

I found this while building my Expo starter kit, which runs the same checks after each release build. It's paid and linked from the README. The script works without it.

Top comments (1)

Collapse
 
hyunsoo_xenoci profile image
Hyunsoo Ju •

"A test that runs on a fixture only proves the fixture" is the line I'd put on the wall. A regex config plugin against a template that changes under you is exactly where that bites, and it never fails loudly.

The iOS side of an Expo app has the same trap, so if your starter kit grows an iOS check, the artifact-level version is short. Unzip the .ipa and ask the binary rather than the config:

unzip -q App.ipa -d ipa
codesign -d --entitlements :- ipa/Payload/*.app
security cms -D -i ipa/Payload/*.app/embedded.mobileprovision | plutil -p - | grep -E "Name|aps-environment|get-task-allow"
Enter fullscreen mode Exit fullscreen mode

The two things that bounce most often: get-task-allow still true (a development profile slipped into the release build) and aps-environment set to development when push is enabled. Both look fine in app.json and in a config plugin's unit test, and both only show up in the signed bundle, same as your debug key.