<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Snuglab Dev</title>
    <description>The latest articles on DEV Community by Snuglab Dev (@snuglab_dev).</description>
    <link>https://dev.to/snuglab_dev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4249861%2F2071bed6-7713-4344-976a-8be776030eac.png</url>
      <title>DEV Community: Snuglab Dev</title>
      <link>https://dev.to/snuglab_dev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/snuglab_dev"/>
    <language>en</language>
    <item>
      <title>5 checks I put in front of every Capacitor release build (so a bad AAB never reaches Google Play)</title>
      <dc:creator>Snuglab Dev</dc:creator>
      <pubDate>Tue, 17 Nov 2026 12:39:48 +0000</pubDate>
      <link>https://dev.to/snuglab_dev/5-checks-i-put-in-front-of-every-capacitor-release-build-so-a-bad-aab-never-reaches-google-play-4o19</link>
      <guid>https://dev.to/snuglab_dev/5-checks-i-put-in-front-of-every-capacitor-release-build-so-a-bad-aab-never-reaches-google-play-4o19</guid>
      <description>&lt;p&gt;Wrapping a web app with Capacitor takes an afternoon. Getting a &lt;em&gt;correct&lt;/em&gt; signed bundle onto Google Play takes longer, mostly because the expensive mistakes happen after the code works: a build with last week's web files, a versionCode you already used, an app ID you can never change.&lt;/p&gt;

&lt;p&gt;Each of those costs a Play Console round trip, and for new personal accounts every wasted upload also eats into the closed-test window (12 testers opted in for 14 days; check your own Console for current numbers). So I put the checks in code, in front of the release build, instead of relying on memory.&lt;/p&gt;

&lt;p&gt;This is what each check does and why. Everything below is plain Node and Gradle, no framework. The snippets come from the scripts I use; I've only tested them on macOS (Node 24, JDK 21, Capacitor 8), so treat Windows/Linux as untested.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Never build Android from stale web files
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;./gradlew bundleRelease&lt;/code&gt; packages whatever is currently inside &lt;code&gt;android/app/src/main/assets/public&lt;/code&gt;. If you forgot &lt;code&gt;npx cap sync android&lt;/code&gt;, you ship an old version of your app under a new version number.&lt;/p&gt;

&lt;p&gt;The release script always runs the same three steps in order, and nothing else:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'npm'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'run'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'build'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                 &lt;span class="c1"&gt;// fresh web build&lt;/span&gt;
&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'npx'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'cap'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'sync'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'android'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;       &lt;span class="c1"&gt;// copy it into the Android project&lt;/span&gt;
&lt;span class="nf"&gt;gradle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'bundleRelease'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                    &lt;span class="c1"&gt;// only then build the bundle&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Rule of thumb: your release command should be one command. If it's three commands you type by hand, one day you'll skip one.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Refuse to reuse a versionCode
&lt;/h2&gt;

&lt;p&gt;Google Play rejects an upload whose &lt;code&gt;versionCode&lt;/code&gt; is not higher than every one you've used. You find out after uploading, which is the slow way.&lt;/p&gt;

&lt;p&gt;The script records the last release build and refuses to build again with the same code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;last&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;readFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;LAST&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'utf8'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;last&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;versionCode&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;fail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`versionCode ${v.code} was already used for your last release build.`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="s1"&gt;'Run "npm run version:bump" first.'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A tiny &lt;code&gt;version:bump&lt;/code&gt; script increments &lt;code&gt;versionCode&lt;/code&gt; and &lt;code&gt;versionName&lt;/code&gt; in &lt;code&gt;android/app/build.gradle&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Honest limitation: this only knows about release builds made on &lt;em&gt;this machine&lt;/em&gt;. It can't see what you uploaded from somewhere else, and if &lt;code&gt;release/&lt;/code&gt; is git-ignored a fresh clone starts with no history. It catches the common slip (rebuilding without bumping), not every case.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Block the placeholder appId
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;appId&lt;/code&gt; becomes the app's permanent identity on Google Play. You can't change it after publishing, so a leftover &lt;code&gt;com.example.myapp&lt;/code&gt; is a mistake you want to catch before the first upload, not after.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;/^&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;\&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;example&lt;/span&gt;\&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cfg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;appId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;fail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`appId is still "${cfg.appId}".`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Set your own in capacitor.config.json.'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;doctor&lt;/code&gt; command checks the same thing earlier, plus the format (lowercase letters, numbers, dots), so you find out before you even start a build.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Don't build a release without a signing key (and never commit it)
&lt;/h2&gt;

&lt;p&gt;A release bundle built without a configured keystore either fails late or isn't signed the way you expect. The script checks that &lt;code&gt;android/keystore.properties&lt;/code&gt; exists before it starts Gradle, and a one-time command creates the key with &lt;code&gt;keytool&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;keytool -genkeypair -v -keystore keys/upload-keystore.jks \
  -alias upload -keyalg RSA -keysize 2048 -validity 10000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two things worth adding:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;.gitignore&lt;/code&gt; entries for &lt;code&gt;keys/&lt;/code&gt;, &lt;code&gt;*.jks&lt;/code&gt;, &lt;code&gt;*.keystore&lt;/code&gt; and &lt;code&gt;keystore.properties&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;a loud reminder to back the key and password up &lt;em&gt;somewhere else&lt;/em&gt;. With Play App Signing this is your &lt;em&gt;upload&lt;/em&gt; key; lose it and you're waiting on a Google reset instead of shipping.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. Check the toolchain before the 10-minute build
&lt;/h2&gt;

&lt;p&gt;The most common first-build failure isn't your code, it's Java or the SDK. A &lt;code&gt;doctor&lt;/code&gt; command that runs in a second saves a lot of confusing Gradle output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;✔ Node.js 24.5.0
✔ Java 21
✔ Android SDK
✔ appId com.yourname.notes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It looks for JDK 21+ (including the JDK bundled with Android Studio) and finds the Android SDK. In the full kit, the build step also writes &lt;code&gt;android/local.properties&lt;/code&gt; with &lt;code&gt;sdk.dir&lt;/code&gt;, so Gradle doesn't fail with "SDK location not found". (The open-source &lt;code&gt;doctor&lt;/code&gt; below only checks; it doesn't write that file.)&lt;/p&gt;

&lt;h2&gt;
  
  
  What these checks don't cover
&lt;/h2&gt;

&lt;p&gt;They don't make Google approve your app. Production access still depends on real testers using the app, updates during the test, and specific answers in the application, and a web app that is just a website in a frame can still be rejected under the minimum functionality policy. The checks only remove the &lt;em&gt;self-inflicted&lt;/em&gt; failures.&lt;/p&gt;

&lt;h2&gt;
  
  
  Want the scripts instead of rebuilding them?
&lt;/h2&gt;

&lt;p&gt;Two of them, the toolchain &lt;code&gt;doctor&lt;/code&gt; and the &lt;code&gt;version:bump&lt;/code&gt; script, are open source (MIT): &lt;a href="https://github.com/snuglabtech/capacitor-play-preflight" rel="noopener noreferrer"&gt;https://github.com/snuglabtech/capacitor-play-preflight&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I also packaged the whole set (doctor, setup, icon and splash generation, guided keystore, version guard, signed build) with a step-by-step guide and Play Console templates:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Free:&lt;/strong&gt; a guide to the 12-tester / 14-day closed test (day-by-day plan, tester messages, how to answer the production-access questions): &lt;a href="https://snuglab.gumroad.com/l/closed-testing" rel="noopener noreferrer"&gt;https://snuglab.gumroad.com/l/closed-testing&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Kit ($21):&lt;/strong&gt; &lt;a href="https://snuglab.gumroad.com/l/webapp-to-play" rel="noopener noreferrer"&gt;https://snuglab.gumroad.com/l/webapp-to-play&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Disclosure: both are mine. Tested on macOS only so far; feedback from Windows and Linux users is very welcome.&lt;/p&gt;

&lt;p&gt;What's the build mistake that cost you the most time? I'm collecting them for the next version of the checks.&lt;/p&gt;

</description>
      <category>android</category>
      <category>capacitor</category>
      <category>webdev</category>
      <category>googleplay</category>
    </item>
  </channel>
</rss>
