<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jai Goyal on Medium]]></title>
        <description><![CDATA[Stories by Jai Goyal on Medium]]></description>
        <link>https://medium.com/@goyaljai?source=rss-90534ad9d452------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*tSxS5GdvIPeFdDBw7AFZjg.png</url>
            <title>Stories by Jai Goyal on Medium</title>
            <link>https://medium.com/@goyaljai?source=rss-90534ad9d452------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 15:50:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@goyaljai/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Let’s clone & build AOSP Android 17]]></title>
            <link>https://goyaljai.medium.com/lets-clone-build-aosp-android-17-659554404340?source=rss-90534ad9d452------2</link>
            <guid isPermaLink="false">https://medium.com/p/659554404340</guid>
            <category><![CDATA[aosp]]></category>
            <category><![CDATA[droidcon]]></category>
            <category><![CDATA[cuttlefish]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Jai Goyal]]></dc:creator>
            <pubDate>Fri, 26 Jun 2026 07:30:59 GMT</pubDate>
            <atom:updated>2026-06-26T07:31:54.535Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*50VvY-mt1BILfaTXHW1_-g.png" /></figure><h3>It’s a different OS than you built last year.</h3><p>If you only read the AOSP docs, building Android 17 looks like a six-line command.</p><p>So before you set aside a Friday / Weekend for “build AOSP 17”, you probably want to know:</p><ul><li><strong>What lunch target do I pick?</strong> The names changed.</li><li><strong>Will my existing AVD even mount the resulting </strong><strong>system.img?</strong> Maybe not.</li><li><strong>Can I run Cuttlefish on a generic cloud VM in 2026?</strong> Yes — but with a small set of patches and a user-space toolchain. I will help you create that.</li></ul><p>Before going to A17, Lets first see what google has changed in A17 and What it tells, Where google is heading towards in terms of AOSP.</p><p>These are not typical “Release Notes” or “Changelogs” that google releases, You will find it when you will make your hands dirty.</p><h3>1. 16 KB page-size is the default for the emulator</h3><p>Android 15 introduced 16 KB-page-size variants of system images. In 17, they’re the <em>default</em> AVD target on arm64. The new lunch alias is sdk_phone16k_arm64-cp2a-userdebug; the SDK image directory is google_apis_playstore_ps16k/arm64-v8a.</p><p>If you produce a 4 KB image and try to swap it into a 16 KB AVD (or vice-versa), the AVD won’t mount it — the sizes are baked into linker assumptions and segment alignment, not just kernel settings.</p><p>If you ship Android apps, you probably already saw the <a href="https://developer.android.com/guide/practices/page-sizes">16 KB requirement</a> land for new Play Store uploads on a17+. Same constraint, top to bottom — the OS itself is now built 16 KB.</p><h3>2. cp2a is the new release config</h3><p>a15 used cp1a, a16 used cp1b/bp2a, a17 uses cp2a as the stable release config. You’ll see it in:</p><ul><li>lunch target names (sdk_phone16k_arm64-cp2a-userdebug)</li><li>out/target/product/&lt;product&gt;/system.img provenance strings</li><li>ro.build.id — CP2A.260605.016 was the snapshot for r1</li></ul><p>If your CI scripts hard-coded cp1a paths, swap them.</p><h3>3. Google quietly moved to Compose. SystemUI is the bellwether.</h3><p>The clearest signal is SystemUI itself. Android has been migrating it to a “scene container” for a couple of releases — a Jetpack-Compose scene graph that replaces the legacy View-tree panel. In a17 the flag flips: <strong>scene container is the default</strong> lockscreen, shade, and bouncer host.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VtQL2FsVR2A3nc42gs30DQ.png" /></figure><p>This is just how SystemUI did it. But if you check any UI code in framework, the derivatives are landing Compose implementations.</p><h3>4. AOSP’s Dagger codegen is KSP, not kapt</h3><p>In a16 the SystemUI-side Dagger graph was generated by <strong>kapt</strong> (Kotlin Annotation Processing — kapt generates Java stubs for your Kotlin code, then runs javac on them with the annotation processor). In a17 it’s <strong>KSP</strong> (Kotlin Symbol Processing — same idea, but the processor reads Kotlin’s symbol table directly and generates Kotlin/Java output without the stub-and-javac round trip).</p><p>I found this thing when I tried to compile SystemUI with my own changes and it started crashing.</p><p>The change will mostly be invisible to you — until you add a single @Provides parameter and the build fails with:</p><pre>error: unresolved reference &#39;DaggerReferenceGlobalRootComponent&#39;.<br>import com.android.systemui.dagger.DaggerReferenceGlobalRootComponent</pre><p>If you see it, look at what changed in your Dagger graph in the last 30 minutes — not at the application module that threw the error.</p><p>How will it look like in a knowledge graph</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qh4S3ZwD78lS1nsuSzJedg.png" /></figure><h3>Lets clone A17 now</h3><p>This time lets try something different. we will NOT use <strong>sudo</strong>. We will use <strong>micromamba</strong>, It works and resolves environment with no Python install, no base env clutter, and no sudo</p><p>Lets setup <strong>micromamba</strong></p><pre>cd ~<br>curl -L micro.mamba.pm/install.sh | bash<br>source ~/.bashrc<br><br>micromamba create -y -n aosp -c conda-forge \<br>  python=3.11 openjdk=21 ninja zip unzip rsync git \<br>  clang lld m4 perl xz zstd \<br>  libasound libpulse \<br>  libwayland-client libwayland-cursor libwayland-server \<br>  libxkbcommon<br><br>micromamba activate aosp</pre><p>The display/audio libs aren’t for the build itself — Cuttlefish’s operator wants them at launch. Get them in the env now; you’ll thank me later.</p><h4>Lets setup repo</h4><pre>mkdir -p ~/bin<br>curl https://storage.googleapis.com/git-repo-downloads/repo &gt; ~/bin/repo<br>chmod +x ~/bin/repo<br>echo &#39;export PATH=$HOME/bin:$PATH&#39; &gt;&gt; ~/.bashrc; source ~/.bashrc</pre><h4>Lets clone and checkout (repo init and checkout)</h4><pre>mkdir ~/a17 &amp;&amp; cd ~/a17<br>repo init -u https://android.googlesource.com/platform/manifest -b android-17.0.0_r1<br>repo sync -c -j$(nproc) --no-clone-bundle --optimized-fetch</pre><p>Now, after cloning the repository, building the code, and making changes to the Android framework, <strong>there are three ways to create, host, and flash the images.</strong></p><p>For this bring-up, I used the following three methods:</p><blockquote><strong>a.</strong> a generic image you can flash to a physical device,</blockquote><blockquote><strong>b.</strong> an emulator image you can swap into an Android Studio AVD on your Mac, and</blockquote><blockquote><strong>c. </strong>a Cuttlefish image you can boot on the VM. All three share the same source tree — you just lunch a different target.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*53pZc-nEq0hzeqPFbPemAg.png" /><figcaption>visual representation</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V4Wa5CKQPOTk6xd9UrFqXg.png" /><figcaption>Memory map. Save it.</figcaption></figure><h3>Build 1: For a physical device (the GSI path)</h3><pre>source build/envsetup.sh<br>lunch aosp_arm64-cp2a-userdebug<br>time m</pre><pre>adb reboot bootloader<br>fastboot flashing unlock        # one-time, requires reboot + on-screen confirm<br>fastboot erase system_a; fastboot erase system_b<br>fastboot flash system out/target/product/generic_arm64/system.img<br>fastboot --disable-verity --disable-verification flash vbmeta \<br>    out/target/product/generic_arm64/vbmeta.img<br>fastboot reboot</pre><p>The GSI is hardware-agnostic by design, but to keep the example concrete I flashed to a <strong>Pixel 8 Pro (codename </strong><strong>husky)</strong>. Any Pixel from the 6 series onward works the same way.</p><h3>Build 2: For an emulator on your Mac</h3><pre>source build/envsetup.sh<br>lunch sdk_phone16k_arm64-cp2a-userdebug<br>time m</pre><p>The product dir is out/target/product/emu64a16k/. The artefact you want for an AVD swap is system-qemu.img — a packed superimage that mounts cleanly under the AVD emulator.</p><p>From your Mac, after scp‘ing that file down, point a Pixel-class AVD at it (use the 16 KB system image base in Android Studio’s SDK Manager, then replace its system.img with yours). The AVD boots in under a minute.</p><h3>Build 3: For Cuttlefish on the build VM</h3><pre>source build/envsetup.sh<br>lunch aosp_cf_arm64_phone-userdebug<br>time m</pre><p>But <strong>this will fail</strong> as Google has removed the support to allow developers to run and test Android operating system images on Linux servers or in the cloud without needing physical hardware.</p><blockquote>Dont know why ? But I got you.</blockquote><p>Here are the changes that we have to do</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/99b96818bd2aac19cd6be72800490271/href">https://medium.com/media/99b96818bd2aac19cd6be72800490271/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b3d5418ccf184bd3a77a6d536d2ecd89/href">https://medium.com/media/b3d5418ccf184bd3a77a6d536d2ecd89/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/577915553083805ee99608785d4a5b29/href">https://medium.com/media/577915553083805ee99608785d4a5b29/href</a></iframe><p>once it is done, here is one time script that I have created so that you do have to.</p><pre>#!/usr/bin/env bash<br># AOSP a17 Cuttlefish — no-sudo conda env + cf-root layout<br># -------------------------------------------------------<br># Produces:<br>#   ~/micromamba/envs/aosp/   conda env with every shared object Cuttlefish wants<br>#   ~/cf/                     Cuttlefish runtime root (HOME override)<br>#   ~/cf/etc/...              stub files Cuttlefish expects to find<br>#<br># Run this once, after micromamba is installed, *before* you launch_cvd.<br># Assumes you have already built aosp_cf_arm64_phone-userdebug under ~/a17.<br>#<br># This script is idempotent — re-run it after any of the above are missing<br># and it will only re-create what is missing.<br><br>set -euo pipefail<br><br>ENV_NAME=&quot;${ENV_NAME:-aosp}&quot;<br>CF_ROOT=&quot;${CF_ROOT:-$HOME/cf}&quot;<br>AOSP_OUT=&quot;${AOSP_OUT:-$HOME/a17/out/target/product/vsoc_arm64}&quot;<br><br># --- 1. conda env with display / audio / wayland .so&#39;s --------------------<br>if ! micromamba env list | grep -q &quot;^\s*${ENV_NAME}\s&quot;; then<br>    micromamba create -y -n &quot;${ENV_NAME}&quot; -c conda-forge \<br>        python=3.11 openjdk=21 \<br>        ninja zip unzip rsync git xz zstd \<br>        clang lld m4 perl \<br>        libasound libpulse \<br>        libwayland-client libwayland-cursor libwayland-server \<br>        libxkbcommon libpng libjpeg-turbo \<br>        ffmpeg<br>fi<br>eval &quot;$(micromamba shell hook --shell bash)&quot;<br>micromamba activate &quot;${ENV_NAME}&quot;<br><br># --- 2. cf-root layout ----------------------------------------------------<br>mkdir -p &quot;${CF_ROOT}&quot;/{bin,etc,lib64,share,cuttlefish}<br>mkdir -p &quot;${CF_ROOT}/etc/cvd_config&quot;<br><br># Cuttlefish copies its host artefacts here. If you&#39;ve already built the<br># cuttlefish target, copy them across:<br>if [[ -d &quot;${AOSP_OUT}/cvd-host_package&quot; ]]; then<br>    rsync -a --update &quot;${AOSP_OUT}/cvd-host_package/&quot; &quot;${CF_ROOT}/&quot;<br>fi<br><br># Stub files Cuttlefish expects but doesn&#39;t actually read for no-network mode<br>: &gt; &quot;${CF_ROOT}/etc/cvd_config/cvd_config_phone.json&quot; || true<br>: &gt; &quot;${CF_ROOT}/fetcher_config.json&quot; || true<br><br># --- 3. point LD_LIBRARY_PATH at the conda env&#39;s lib dir -----------------<br>ENV_LIB=&quot;${HOME}/micromamba/envs/${ENV_NAME}/lib&quot;<br>echo &quot;LD_LIBRARY_PATH should include: ${ENV_LIB}:${CF_ROOT}/lib64&quot;<br><br># --- 4. swap in the QEMU wrapper (file 0003) -----------------------------<br>QEMU_DIR=&quot;${CF_ROOT}/bin/x86_64-linux-gnu/qemu&quot;<br>if [[ -f &quot;${QEMU_DIR}/qemu-system-aarch64&quot; &amp;&amp; ! -f &quot;${QEMU_DIR}/qemu-system-aarch64.real&quot; ]]; then<br>    mv &quot;${QEMU_DIR}/qemu-system-aarch64&quot; &quot;${QEMU_DIR}/qemu-system-aarch64.real&quot;<br>    install -m 0755 &quot;$(dirname &quot;$0&quot;)/0003-qemu-system-aarch64-LD_LIBRARY_PATH-wrapper.sh&quot; \<br>        &quot;${QEMU_DIR}/qemu-system-aarch64&quot;<br>fi<br><br>echo<br>echo &quot;OK — environment ready. Launch with: launch-cuttlefish.sh&quot;</pre><pre>#!/usr/bin/env bash<br># AOSP a17 Cuttlefish — the launch incantation that actually works on a<br># stock GCP VM in a hardened image.<br>#<br># Prereqs (one-time): 0001-* / 0002-* patches applied to device/google/cuttlefish,<br># 0003-* QEMU wrapper installed, and 0004-* env script run.<br>#<br># Run as: launch-cuttlefish.sh [extra launch_cvd flags...]<br><br>set -euo pipefail<br><br>CF_ROOT=&quot;${CF_ROOT:-$HOME/cf}&quot;<br>ENV_NAME=&quot;${ENV_NAME:-aosp}&quot;<br>ENV_LIB=&quot;${HOME}/micromamba/envs/${ENV_NAME}/lib&quot;<br>AOSP_OUT=&quot;${AOSP_OUT:-$HOME/a17/out/target/product/vsoc_arm64}&quot;<br><br># Always start from a clean lockfile state — Cuttlefish doesn&#39;t reliably<br># pick up half-initialised previous runs.<br>pkill -9 -f &quot;${CF_ROOT}/bin&quot; 2&gt;/dev/null || true<br>rm -rf &quot;${CF_ROOT}/cuttlefish&quot;/* /tmp/cf_* 2&gt;/dev/null || true<br><br>HOME=&quot;${CF_ROOT}&quot; \<br>LD_LIBRARY_PATH=&quot;${ENV_LIB}:${CF_ROOT}/lib64&quot; \<br>&quot;${CF_ROOT}/bin/launch_cvd&quot; \<br>    --enable_tap_devices=false \<br>    --start_webrtc=true \<br>    --start_webrtc_sig_server=true \<br>    --webrtc_sig_server_addr=0.0.0.0 \<br>    --webrtc_sig_server_port=8443 \<br>    --system_image_dir=&quot;${AOSP_OUT}&quot; \<br>    --vm_manager=qemu_cli \<br>    --daemon \<br>    --report_anonymous_usage_stats=n \<br>    &quot;$@&quot;<br><br>sleep 2<br>echo<br>echo &quot;Operator listening on 0.0.0.0:8443&quot;<br>echo &quot;Local test:  curl -ksI https://localhost:8443/&quot;<br>echo &quot;Tunnel from your laptop:&quot;<br>echo &quot;    gcloud compute ssh &lt;vm&gt; --zone &lt;z&gt; -- -N -L 8443:localhost:8443&quot;<br><br>echo &quot;Then open: https://localhost:8443/&quot;</pre><h3>Exposing Cuttlefish to a browser</h3><p>Once the operator is up, just run this command from your VM. for me its GCP</p><pre>gcloud compute ssh aosp-build-vm \<br>  --zone &lt;zone&gt; \<br>  -- -N -L 8443:localhost:8443</pre><h3>Closing Thoughts</h3><p>Last but not the least, Lets discuss what has changed from Android 16 to Android 17</p><h3>1. Release configs explode — cp2a joins the list (build system)</h3><pre>a16 build/release/release_configs/<br>  bp2a.textproto, eng, root, user, userdebug                    [5 files]</pre><pre>a17 build/release/release_configs/<br>  ap2a, ap3a, ap4a, bp1a, bp2a, bp3a, bp4a,<br>  cp1a, cp2a,                          ← the new release config<br>  eng, mainline_2026_01..04, trunk_staging,<br>  user, userdebug                                              [17 files]</pre><p>Twelve net-new release configs in a17, including the entire cp* family and four monthly mainline trains. This is the lunch &lt;product&gt;-&lt;release&gt;-&lt;variant&gt; syntax change with receipts — the bare aosp_arm64-userdebug you used to type on a16 no longer resolves on a17 because there is no implicit “default” release any more.</p><h3>2. SystemUI grows Gradle alongside Soong (path tree + build system)</h3><p>frameworks/base/packages/SystemUI/ in a17 picks up a complete Gradle scaffolding that doesn’t exist in a16:</p><p>New in a17build.gradle, build.gradle.kts, settings.gradlebuildParams/, gradle/, libs/flag_check.py, release.shCODEOWNERS, Migration.md</p><p>Soong/Kati is still the source of truth for the platform build, but SystemUI is now buildable as a standalone Gradle module — the plumbing Google needs to share SystemUI surfaces (lockscreen, shade, Quick Settings) with non-AOSP consumers like Wear, Auto, and ARC.</p><h3>3. KSP shows up in SystemUI/Android.bp (build system)</h3><pre>a16  packages/SystemUI/Android.bp  →  0 references to KSP, 0 to kapt<br>a17  packages/SystemUI/Android.bp  →  4 references to KSP, 0 to kapt</pre><p>The kapt→KSP migration is no longer “soon” or “behind a flag” — SystemUI’s Soong module declares Kotlin-Symbol-Processing plugins directly. This is exactly the regression source the article’s DaggerReferenceGlobalRootComponent example points at.</p><h3>4. New pods/ directory: modular packaging (path tree)</h3><pre>a16  SystemUI/  →  no pods/<br>a17  SystemUI/pods/scene/                  ← scene container as a pod<br>     SystemUI/pods/...                     ← more pods follow</pre><p>pods/ is Google’s new modular sub-target convention for SystemUI — each pod is a self-contained module (its own AndroidManifest, build file, sources, tests). The scene container appears in this dir first, which is consistent with the article’s Compose-default claim — it’s not just <em>one</em> Compose scene graph in SystemUI, it’s the <em>first inhabitant</em> of a new modular structure designed around Compose.</p><h3>5. Ravenwood + a device/deviceless test split (framework)</h3><pre>a16  multivalentTests/                                          [single test surface]<br>a17  multivalentTests/<br>     multivalentTestsForDevice/                                 [on-device flavor]<br>     multivalentTestsForDeviceless/                             [host JVM flavor]<br>     ravenwood.sysprop                                          [Ravenwood config</pre><p>Google is changing how Android framework and SystemUI tests are executed</p><p>Google is making Android framework and SystemUI testing run directly on a normal JVM using <a href="https://android.googlesource.com/platform//frameworks/base/+/5fb06d3335b8a8dc343541399a3c0ccc6826628c/ravenwood">Ravenwood</a>, eliminating the need for emulators or devices for many tests, which makes CI faster, cheaper, and easier to run anywhere.</p><h3>Where to read more about Android 17 internals</h3><ul><li><a href="https://source.android.com/">Android 17 release notes</a> — the canonical changelog on source.android.com</li><li><a href="https://developer.android.com/guide/practices/page-sizes">16 KB page-size guide</a> — what you need to know about the page-size flip, from the app side</li><li><a href="https://dagger.dev/dev-guide/ksp.html">KSP for Dagger</a> — Dagger’s KSP migration guide; mostly transparent to consumers, exactly described above</li><li><a href="https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-17.0.0_r1/packages/SystemUI/compose/">Compose for SystemUI</a> — start here for the new scene-container architecture</li><li>device/google/cuttlefish/host/commands/launch_cvd — the source of truth for what each --flag actually does (the --helpfull dump is also useful)</li></ul><blockquote>Connect with me on LinkedIn : <a href="https://www.linkedin.com/in/goyaljai/"><strong><em>https://www.linkedin.com/in/goyaljai/</em></strong></a> for further updates and articles like this.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=659554404340" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Gave Claude a Real Browser with My Google Login — Here’s What Happened]]></title>
            <link>https://goyaljai.medium.com/i-gave-claude-a-real-browser-with-my-google-login-heres-what-happened-deabec5c64c7?source=rss-90534ad9d452------2</link>
            <guid isPermaLink="false">https://medium.com/p/deabec5c64c7</guid>
            <dc:creator><![CDATA[Jai Goyal]]></dc:creator>
            <pubDate>Wed, 06 May 2026 14:01:44 GMT</pubDate>
            <atom:updated>2026-05-06T17:35:23.870Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H21ChsWdYzcRfspckRzffw.png" /></figure><h3><strong>No extension. No developer flags. No sandbox. Just Claude, Chrome, and my actual session.</strong></h3><p>Your coworkers are going to read this article this week. Some of them are going to set this up. And then they’re going to stop doing the thing you still do 40 times a day — opening a tab, searching something, copying the result, pasting it into their AI chat.</p><p><strong>I’m not going to sugarcoat it:</strong> this is one of those setups that, once you have it, you can’t believe you worked without it.</p><h3><strong>What You’re Still Doing (And Don’t Have To)</strong></h3><p>Most people’s AI + browser workflow in 2026:</p><p>1. Ask Claude something<br>2. Claude says “I can’t browse the internet” or returns 401/402/403/404 HTTP Code<br>3. You open a tab, search manually, copy the result, paste it back<br>4. Repeat. Forever.</p><p>Some people have upgraded to pasting screenshots. That’s slightly better. You’re still doing all the legwork.</p><p>What if Claude could just <strong>open the browser itself</strong>?</p><h3>What I can achieve in 10 Minutes</h3><p>I connected Claude Code to a real Chrome browser — my Chrome — with my Google account already logged in. Not a sandboxed Chromium. Not a headless ghost. My actual Chrome, my actual profile, my actual session.</p><p>No browser extension. No `chrome://inspect` toggles. No terminal flags. No recorder.</p><p>One script. One login. Done.</p><p>Here’s what that looks like in practice:</p><p><strong><em>&gt; Me: </em>”Search Google for who is Donald Trump”</strong></p><p>Claude opened Chrome, typed the query, hit Enter — and Google showed results with <strong>my profile avatar in the top right corner</strong>. Fully authenticated. Zero friction.</p><p>That’s not a demo. That’s my actual workflow.</p><h3>How to Set This Up (It Takes 10 Minutes)</h3><p>You need <strong>Claude Code</strong> installed. If you don’t have it — fix that first, then come back.</p><h4>Step 1: Run the One-Time Setup Script</h4><pre>bash &lt;(curl -fsSL https://gist.github.com/goyaljai/d3c916c37aff1c1a3535ec261839d7e5/raw/abeba73e44ab8eca376e91ccaf9b710b8eb2309b/setup-claude-browser-playwright.sh)</pre><h4>What it does:</h4><ol><li>Installs Playwright MCP — the browser automation server for Claude Code</li><li>Installs the <strong>custom skill that I have created</strong> called /browser-agent skill into ~/.claude/commands/</li></ol><p>3. Writes always-on browser rules into your Claude config — cookie handling, auto-scroll, smart URL extraction, curl downloads. Active in every session, no command needed</p><p>4. Opens a plain Chrome window — no recorder, no code panel, nothing weird</p><p>5. You log in (optional — skip it and Claude still browses public sites without authentication)</p><p>6. You close the browser</p><p>7. If you logged in: session cookies are saved to ~/.claude/playwright-auth.json</p><p>8. Claude is reconfigured to reload your session on every start</p><h4>Step 2: Restart Claude Code</h4><p>That’s it. Claude now opens Chrome with your Google account already signed in — every single time.</p><h3>What This Actually Unlocks</h3><p>Things that used to take 20 minutes of manual clicking:</p><p>- <strong>Check if our competitor updated their pricing</strong>— Claude opens it, reads it, tells you what changed<br>- <strong>Pull today’s numbers from our internal dashboard</strong>— Claude logs in (with your session) and reads the data<br>- <strong>Take a screenshot of our landing page on mobile</strong>— Claude resizes the browser, screenshots it, done<br>- <strong>Download all 58 photos from this match album</strong>— Claude scrolls through the whole page, extracts every URL, downloads them all via curl</p><p>The key difference from every other “AI browsing” demo you’ve seen: <strong>you only log in once</strong>. After that, Claude carries your authenticated session on every run. No re-login. No 2FA prompts. No “please sign in to continue.”</p><p>The Part Nobody Else Has Figured Out</p><p>Most “AI browser agents” use a fresh sandboxed Chromium — no cookies, no sessions, no logins. The moment you need anything behind authentication, they hit a wall.</p><p>This setup saves your <strong>real session cookies</strong> the first time and reloads them every time. That’s the unlock.</p><p>But saving the session is only half of it. The other half is making Claude smart enough to actually use the browser reliably — and that’s where the script goes further than anything else I’ve seen.</p><h3>What the Script Installs (Beyond Just the Session)</h3><h4>This script has a skill embedded itself that gets active as and when you chat with claude.</h4><p>The script doesn’t just wire up authentication. It also configures Claude with browser automation rules that are <strong>always active</strong> — not just when you invoke a special command.</p><p>Under the hood, Playwright with some nuances that matter:</p><p><strong>Always on — no command needed:</strong></p><p>- <strong>Cookie banners dismissed automatically.</strong> On every new page, Claude spots the consent overlay and accepts it before doing anything else. You never get stuck on a GDPR wall.</p><p>- <strong>Auto-scroll before every extraction. </strong>Most sites lazy-load content as you scroll. Without this, you get the first 10 items on the page and think that’s everything. With it, Claude runs a scroll loop — scroll, wait, check if new content appeared, repeat — until the page stops growing. This is how you get all 58 photos in an album, not just the ones above the fold. It’s also how you’d tell Claude to scroll your Instagram feed until it finds a food reel — and it actually keeps scrolling until it does.</p><p>- <strong>Downloads via curl, not browser dialogs.</strong> When you ask Claude to download files, it extracts the direct URLs and downloads them cleanly to a folder. No “Save As” dialog hunting, no browser download manager, no mystery files in random locations.</p><p><strong>With `/browser-agent` for complex tasks:</strong></p><p>This is where it stops being a tool and starts feeling like delegation.</p><p>Type `/browser-agent` followed by whatever you want done, and Claude operates the browser the way a careful human would.</p><p>Most browser automation breaks the moment something unexpected appears on screen. This doesn’t — because Claude reads the page state at every step instead of blindly executing a sequence.</p><p>&gt; `/browser-agent go to our dashboard and pull this week’s signups`</p><h4>When Your Session Expires</h4><p>Google sessions last a few weeks. When yours expires, re-run the script:</p><pre>bash &lt;(curl -fsSL https://gist.github.com/goyaljai/d3c916c37aff1c1a3535ec261839d7e5/raw/abeba73e44ab8eca376e91ccaf9b710b8eb2309b/setup-claude-browser-playwright.sh)Log in, restart Claude, back to normal. Two minutes.</pre><h4>The Bottom Line</h4><p>Ten minutes. One script. No extension, no developer flags, no recorder.</p><p>Claude now has a browser. Your browser. With your logins, your sessions, your authenticated tools.</p><p>The instructions are right here. The gap between you and your coworkers who set this up today is exactly the time it takes you to run one command.</p><p><strong>Built with Claude Code + Playwright MCP. Under the hood: session cookies, auto-scroll loops, and curl. On the surface: Claude just does the thing you asked.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=deabec5c64c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LLMs, RAG, and AI Agents Explained with a Simple Car Analogy ]]></title>
            <link>https://blog.stackademic.com/llms-rag-and-ai-agents-explained-with-a-simple-car-analogy-f87d4081e9b7?source=rss-90534ad9d452------2</link>
            <guid isPermaLink="false">https://medium.com/p/f87d4081e9b7</guid>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Jai Goyal]]></dc:creator>
            <pubDate>Sat, 14 Mar 2026 05:51:13 GMT</pubDate>
            <atom:updated>2026-03-17T07:40:33.428Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qt-a4DlMXZyD-6m2QRFvZQ.png" /></figure><blockquote>Have you seen everyone talking about “LLMs,” “Context Windows,” “RAG,” and now “Agents”? It feels like a new language.</blockquote><blockquote>“What is this? What does it all actually do together?”</blockquote><h3>If you’re confused, this simple analogy is for you.</h3><p>Imagine you are driving a car on a long trip. Let’s break down how an LLM application is like that journey:</p><h3>1️⃣ <strong>The Car’s Engine (The LLM):</strong></h3><p>This is the core power. It’s what makes the system “go.” Think of this as the LLM (like GPT-4). It’s the brain, the processor. (As Andrej Karpathy says, the CPU).</p><h3>2️⃣ <strong>The Fuel (The Context):</strong></h3><p>You can’t drive without gas. “Context” is the information you give the LLM <em>right now</em> in your prompt. If you give it the wrong info (or “fuel”), the trip won’t go well.</p><h3>3️⃣ The Driver’s Driving Record &amp; GPS (The Memory / RAG):</h3><p>This is <em>everything the driver knows</em> from past trips and the map they are using. In an LLM system, “Memory” (or RAG) is the specialized database of your company’s files, old conversations, and real-world knowledge that the system can access. It’s the “experience.”</p><h3>4️⃣ <strong>The Road (The Orchestration / Framework):</strong></h3><p>The road guides the car from A to B. “Orchestration” is the framework (like LangChain or AutoGen) that guides the LLM through a multi-step task, connects it to memory, and directs it to the final goal.</p><h3>5️⃣ <strong>The Driver (You / The Agent):</strong></h3><p>Who is behind the wheel? That’s you, and increasingly, an <strong>AI Agent</strong>. The agent makes the decisions, plans the route, decides when to look at the map (the memory), and when to use the steering wheel (the context).</p><p>So, when people talk about What is ChatGPT?</p><p><strong>ChatGPT = The complete car system that I described above</strong></p><p>It includes:</p><ul><li>the <strong>LLM engine</strong></li><li><strong>context management</strong></li><li><strong>memory tools</strong></li><li><strong>orchestration</strong></li><li>sometimes <strong>agent behavior</strong></li></ul><p>All wrapped into an easy chat interface called ChatGPT.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qt-a4DlMXZyD-6m2QRFvZQ.png" /><figcaption>LLMs Mental Model</figcaption></figure><p>What other complex AI concepts are you struggling to understand? Let me know in the comments, and let’s simplify it.</p><p>#AI #LLMs #GenerativeAI #AIAgents #SimplifyingAI #MentalModel #MachineLearning</p><p>Follow me on Linkedin for more : <a href="https://www.linkedin.com/in/goyaljai">https://www.linkedin.com/in/goyaljai</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f87d4081e9b7" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/llms-rag-and-ai-agents-explained-with-a-simple-car-analogy-f87d4081e9b7">LLMs, RAG, and AI Agents Explained with a Simple Car Analogy 🚗</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running a Custom AOSP ROM on the Android Emulator (Android 16)]]></title>
            <link>https://goyaljai.medium.com/building-and-running-a-custom-aosp-rom-on-the-android-emulator-android-16-41153203bc3a?source=rss-90534ad9d452------2</link>
            <guid isPermaLink="false">https://medium.com/p/41153203bc3a</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[rom]]></category>
            <category><![CDATA[bazel]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[aosp]]></category>
            <dc:creator><![CDATA[Jai Goyal]]></dc:creator>
            <pubDate>Sat, 14 Mar 2026 05:40:01 GMT</pubDate>
            <atom:updated>2026-03-14T13:49:37.348Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_NGJrLpMe-D47lnH8EcoVw.jpeg" /></figure><p>If you’ve already synced AOSP and want to test your custom ROM directly on the Android Emulator instead of flashing a physical device, this guide walks you through the exact steps.</p><p>This method builds a system image package that can be installed into your Android SDK and booted like any official emulator image.</p><h3>Make sure your environment is set up:</h3><pre>source build/envsetup.sh</pre><h3>Step 1 — Choose the Emulator Lunch Target</h3><p>Depending on your architecture, select one of the following:</p><h3>🔹 For x86_64 (Recommended for most PCs)</h3><pre>lunch sdk_phone_x86_64</pre><p>or for a debug build:</p><pre>lunch sdk_phone_x86_64-userdebug</pre><h3>🔹 For x86 (Older Systems)</h3><pre>lunch sdk_phone_x86</pre><p>or</p><pre>lunch sdk_phone_x86-userdebug</pre><h3>🔹 For ARM64 Emulator</h3><pre>lunch sdk_phone_arm64</pre><p>or</p><pre>lunch sdk_phone_arm64-userdebug</pre><blockquote><em>💡 </em><strong><em>Tip:</em></strong><em><br> </em><em>x86_64 is much faster on Intel/AMD machines.<br> </em><em>arm64 is useful if you&#39;re targeting ARM behavior testing.</em></blockquote><h3>Step 2 — Build the Emulator System Image</h3><p>Now compile AOSP:</p><pre>make -j$(nproc)</pre><p>After the main build completes, generate the emulator SDK image package:</p><pre>make -j$(nproc) make_emu_zip</pre><p>This will create a flashable emulator system image ZIP file.</p><h3>Step 3 — Locate the Generated Emulator ZIP</h3><p>After the build finishes, you will find a file like:</p><pre>sdk-repo-linux-system-images-eng.{your_user_name}.zip</pre><p>The file will be located inside:</p><pre>out/target/product/sdk_phone_x86_64/</pre><p>(or the folder matching your selected lunch target)</p><h3>Step 4 — Install the System Image into Android SDK</h3><h3>1️⃣ Download on Local Machine and Extract the ZIP</h3><p>Unzip the file:</p><pre>unzip sdk-repo-linux-system-images-eng.{your_user_name}.zip</pre><p>You will see a folder such as:</p><pre>x86_64/</pre><h3>2️⃣ Move It to Your SDK Directory</h3><p>On macOS:</p><pre>/Library/Android/sdk/system-images/android-36/default/x86_64</pre><p>On Linux:</p><pre>~/Android/Sdk/system-images/android-36/default/x86_64</pre><p>If the directory does not exist, create emulator from the Step 5:</p><p>Then copy the extracted contents into that folder.</p><h3>Step 5 — Create the Emulator</h3><ol><li>Open <strong>Android Studio</strong></li><li>Go to <strong>Device Manager</strong></li><li>Create a new Virtual Device</li><li>Select and Start the emulator.</li></ol><p>Once it is done, Restart Studio and Re-run the Emulator, It will have your images that you downloaded and added above.</p><h3>Why This Method Is Powerful</h3><p>✅ No need to flash physical devices<br> ✅ Faster iteration cycle<br> ✅ Safe testing environment<br> ✅ Perfect for framework and system development</p><h3>Once you’re comfortable with this workflow, you can:</h3><ul><li>Integrate custom frameworks</li><li>Add system apps</li><li>Modify services</li><li>Test new Android features</li></ul><p>Happy hacking 🚀</p><p>Follow me for More : <a href="https://www.linkedin.com/in/goyaljai">https://www.linkedin.com/in/goyaljai</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41153203bc3a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Contribute to AOSP (Android Open Source Project)]]></title>
            <link>https://proandroiddev.com/how-to-contribute-to-aosp-android-open-source-project-d934cfc8c16d?source=rss-90534ad9d452------2</link>
            <guid isPermaLink="false">https://medium.com/p/d934cfc8c16d</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[aosp]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Jai Goyal]]></dc:creator>
            <pubDate>Fri, 30 Jan 2026 19:09:35 GMT</pubDate>
            <atom:updated>2026-02-26T02:22:08.730Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*eKxc623D79g0u2fcXC5-IQ.jpeg" /><figcaption>How to Contribute to AOSP (Android Open Source Project)</figcaption></figure><p>Contributing to the <strong>Android Open Source Project (AOSP)</strong> is a great way to learn large-scale open-source development and collaborate with developers across the world. This guide walks you through the complete process — from setting up accounts to uploading your first patch.</p><h3>1. Understand AOSP</h3><p>AOSP is the open-source core of the Android operating system maintained by Google. Anyone can view the code, suggest improvements, fix bugs, or add features by contributing through Google’s Gerrit code review system.</p><h3>Follow this article to Setup AOSP (if not already done yet) :</h3><h3><a href="https://goyaljai.medium.com/building-flashing-a-custom-aosp-gsi-on-pixel-arm64-android-16-1313b4211c53">https://goyaljai.medium.com/building-flashing-a-custom-aosp-gsi-on-pixel-arm64-android-16-1313b4211c53</a></h3><h3>2. Sign the Contributor License Agreement (CLA)</h3><p>Before contributing any code, you <strong>must sign Google’s Individual Contributor License Agreement (CLA)</strong>.<br>This allows Google to legally accept your contributions.</p><p>👉 Sign the agreement here:<br><a href="https://cla.developers.google.com/about/google-individual">https://cla.developers.google.com/about/google-individual</a></p><blockquote><em>⚠️ You only need to sign this </em><strong><em>once</em></strong><em>.</em></blockquote><h3>3. Create a Gerrit Account</h3><p>AOSP uses <strong>Gerrit</strong> for code reviews.</p><ol><li>Visit: <a href="https://android-review.googlesource.com/">https://android-review.googlesource.com</a></li><li>Sign in using the same Google account used for the CLA</li><li>Complete your profile setup</li></ol><p>This account will be used to upload and review code changes.</p><h3>4. Set Up Git Configuration</h3><p>Configure Git with your name and email (must match your Gerrit account):</p><pre>git config --global user.name &quot;Jai Goyal&quot;<br>git config --global user.email &quot;goyaljai.y14@gmail.com&quot;</pre><p>These details will appear in your commits.</p><h3>5. Find an Issue to Work On</h3><p>You can find bugs, feature requests, or tasks in the <strong>Google Issue Tracker</strong>.</p><p>👉 Browse issues here:<br><a href="https://issuetracker.google.com/">https://issuetracker.google.com</a></p><h3>6. Create a New Branch</h3><p>Before making changes, create a new working branch:</p><pre>git checkout -b aosp-main aosp/main</pre><p>This keeps your work separate from the main branch and follows AOSP best practices.</p><h3>7. Make Your Changes</h3><ul><li>Navigate to the relevant folder</li><li>Fix the bug or add the feature</li><li>Test your changes locally if possible</li><li>Follow AOSP coding standards and commit message guidelines</li></ul><h3>8. Upload Your Changes for Review</h3><p>Once your code is ready, upload it to Gerrit for review:</p><pre>repo upload &lt;folder&gt;</pre><p>Example:</p><pre>repo upload frameworks/base</pre><p>After uploading:</p><ul><li>Your change will appear in Gerrit</li><li>Reviewers may request modifications</li><li>Update your code and re-upload if needed</li></ul><h3>9. Respond to Reviews</h3><p>Code reviews are a normal part of the process:</p><ul><li>Be polite and responsive</li><li>Make requested changes</li><li>Learn from feedback</li></ul><p>Once approved, your patch will be merged into AOSP 🎉</p><h3>10. Keep Contributing</h3><p>After your first contribution:</p><ul><li>Pick more complex issues</li><li>Review others’ code</li><li>Join AOSP discussions and mailing lists</li></ul><p>Open-source is a marathon, not a sprint 🚀</p><h3>Conclusion</h3><p>Contributing to AOSP is an excellent way to grow as a developer and give back to the Android ecosystem. By signing the CLA, setting up Gerrit, choosing the right issues, and following the contribution workflow, you can successfully make your mark in AOSP.</p><p>Happy contributing! 😊</p><p><a href="https://www.linkedin.com/in/goyaljai?originalSubdomain=in">https://www.linkedin.com/in/goyaljai</a> : Follow me for more</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d934cfc8c16d" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/how-to-contribute-to-aosp-android-open-source-project-d934cfc8c16d">How to Contribute to AOSP (Android Open Source Project)</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Was Afraid of KMP & CMP — Now I Don’t Want to Build Apps Without Them]]></title>
            <link>https://blog.stackademic.com/i-was-afraid-of-kmp-cmp-now-i-dont-want-to-build-apps-without-them-841428c8379c?source=rss-90534ad9d452------2</link>
            <guid isPermaLink="false">https://medium.com/p/841428c8379c</guid>
            <category><![CDATA[kotlin-multiplatform]]></category>
            <category><![CDATA[compose-multiplatform]]></category>
            <category><![CDATA[kmp]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[kotlin-beginners]]></category>
            <dc:creator><![CDATA[Jai Goyal]]></dc:creator>
            <pubDate>Thu, 15 Jan 2026 11:31:29 GMT</pubDate>
            <atom:updated>2026-01-15T12:45:36.012Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n_w_drjH76w7jR94tX2r4Q.png" /></figure><p>If you’ve ever heard terms like <strong>Kotlin Multiplatform (KMP)</strong> or <strong>Compose Multiplatform (CMP)</strong>, your first reaction might have been:<em>“Sounds powerful… but also scary.” </em>You’re not alone.</p><h3>Why Developers Are Afraid of KMP &amp; CMP (And Why Trying Them Can Be Revolutionary)</h3><p>If you’ve ever heard terms like <strong>Kotlin Multiplatform (KMP)</strong> or <strong>Compose Multiplatform (CMP)</strong>, your first reaction might have been:</p><blockquote><em>“Sounds powerful… but also scary.”</em></blockquote><p>You’re not alone.</p><p>Many developers avoid KMP and CMP because they <em>look complex</em>, <em>sound experimental</em>, or <em>feel like too much mental overhead</em>. Multiple platforms? Shared code? New build setups? New UI paradigms?</p><p>But here’s the truth:</p><p>👉 <strong>Once you try them, they can completely change how you think about building apps.</strong></p><p>This article is written for <strong>beginners</strong>. By the end, you’ll understand:</p><ul><li>What KMP and CMP are</li><li>How to set up a project</li><li>How to structure your code using <strong>real KMP architecture patterns</strong></li></ul><h3>Why Developers Are Afraid to Try KMP &amp; CMP</h3><p>Common fears include:</p><ul><li>“Multiplatform debugging must be painful”</li><li>“Build times will explode”</li><li>“UI can’t be shared properly”</li><li>“The learning curve is too steep”</li></ul><p>But here’s the key idea:</p><blockquote><strong><em>KMP doesn’t replace platform knowledge — it reduces duplication.</em></strong></blockquote><p>You still write Android code.<br>You still write iOS code.<br>You just stop rewriting the <em>same logic</em> again and again.</p><h3>What Is Kotlin Multiplatform (KMP)?</h3><p><strong>Kotlin Multiplatform</strong> allows you to write <strong>shared business logic</strong> once and use it across:</p><ul><li>Android</li><li>iOS</li><li>Desktop</li><li>Web</li><li>Backend</li></ul><p>Instead of duplicating:</p><ul><li>Validation</li><li>Networking</li><li>Domain logic</li><li>Models</li></ul><p>You share them.</p><h3>A Simple KMP Example</h3><h3>Shared Code (commonMain)</h3><pre>class Greeting {<br>    fun greet(name: String): String {<br>        return &quot;Hello, $name! Welcome to KMP 🚀&quot;<br>    }<br>}</pre><h3>Android Usage</h3><pre>val greeting = Greeting()<br>println(greeting.greet(&quot;Android Developer&quot;))</pre><h3>iOS Usage (Swift)</h3><pre>let greeting = Greeting()<br>print(greeting.greet(name: &quot;iOS Developer&quot;))</pre><p>Same logic. Multiple platforms. Zero duplication.</p><h3>What Is Compose Multiplatform (CMP)?</h3><p><strong>Compose Multiplatform</strong> lets you write <strong>UI using Kotlin</strong> for:</p><ul><li>Android</li><li>Desktop</li><li>Web</li><li>(iOS support is improving rapidly)</li></ul><p>If you’ve used <strong>Jetpack Compose</strong>, you already know CMP.</p><h3>Your First CMP UI</h3><pre>@Composable<br>fun GreetingScreen(name: String) {<br>    Text(<br>        text = &quot;Hello $name 👋&quot;,<br>        fontSize = 24.sp<br>    )<br>}</pre><p>Same UI code can run on Android and Desktop.</p><h3>Project Setup: Your First KMP + CMP App</h3><h3>1: Create the Project</h3><ol><li>Open <strong>Android Studio</strong></li><li>New Project → <strong>Kotlin Multiplatform</strong></li><li>Select <strong>KMP App</strong></li><li>Enable:Android, Desktop, iOS</li><li>Finish</li></ol><h3>Step 2: Project Structure Explained</h3><pre>shared/<br> ├── commonMain/<br> ├── androidMain/<br> ├── desktopMain/<br>androidApp/<br>desktopApp/</pre><ul><li>commonMain → shared logic (most important)</li><li>Platform folders → platform-specific code</li></ul><h3>Step 3: Add Shared Logic</h3><pre>class Greeting {<br>    fun greet(name: String): String {<br>        return &quot;Hello $name! Welcome to KMP 🚀&quot;<br>    }<br>}</pre><h3>Step 4: Use Shared UI</h3><h3>Android</h3><pre>setContent {<br>    GreetingScreen(&quot;Android Developer&quot;)<br>}</pre><h3>Desktop</h3><pre>Window(onCloseRequest = ::exitApplication) {<br>    GreetingScreen(&quot;Desktop Developer&quot;)<br>}</pre><p>Run both. Same UI. Same behavior.</p><h3>KMP Architecture Patterns (Beginner-Friendly)</h3><p>This is where most developers get confused — and where KMP truly shines.</p><p>Let’s simplify it.</p><h3>The Golden Rule of KMP Architecture</h3><blockquote><strong><em>Share what doesn’t change.<br>Keep platform-specific things platform-specific.</em></strong></blockquote><h3>Recommended KMP Architecture (Clean &amp; Simple)</h3><pre>shared/<br> ├── domain/<br> │   ├── model/<br> │   ├── repository/<br> │   └── usecase/<br> ├── data/<br> │   ├── api/<br> │   ├── datasource/<br> │   └── repositoryImpl/<br> ├── presentation/<br> │   └── ViewModel</pre><p>This is <strong>Clean Architecture</strong>, adapted for KMP.</p><h3>Domain Layer (Pure Kotlin)</h3><p>This layer knows <strong>nothing</strong> about platforms, UI, or frameworks.</p><h3>Model</h3><pre>data class User(<br>    val id: String,<br>    val name: String<br>)</pre><h3>Repository Contract</h3><pre>interface UserRepository {<br>    suspend fun getUser(): User<br>}</pre><h3>Use Case</h3><pre>class GetUserUseCase(<br>    private val repository: UserRepository<br>) {<br>    suspend operator fun invoke(): User {<br>        return repository.getUser()<br>    }<br>}</pre><p>✅ 100% shared<br>✅ Easy to test<br>✅ Platform-independent</p><h3>Data Layer (Still Shared)</h3><p>Handles APIs, databases, and logic.</p><pre>class UserRepositoryImpl : UserRepository {<br>    override suspend fun getUser(): User {<br>        return User(<br>            id = &quot;1&quot;,<br>            name = &quot;KMP Developer&quot;<br>        )<br>    }<br>}</pre><p>You can plug in:</p><ul><li>Ktor</li><li>SQLDelight</li><li>REST / GraphQL</li></ul><p>All shared.</p><h3>Presentation Layer (Shared ViewModel)</h3><h3>Shared ViewModel</h3><pre>class UserViewModel(<br>    private val getUserUseCase: GetUserUseCase<br>) {<br>    suspend fun loadUser(): User {<br>        return getUserUseCase()<br>    }<br>}</pre><p>This ViewModel can be used by:</p><ul><li>Android Compose</li><li>Desktop Compose</li><li>iOS (via Swift wrappers)</li></ul><h3>Platform UI Layer (Minimal)</h3><h3>Android UI</h3><pre>@Composable<br>fun UserScreen(viewModel: UserViewModel) {<br>    val user = remember { mutableStateOf&lt;User?&gt;(null) }</pre><pre>    LaunchedEffect(Unit) {<br>        user.value = viewModel.loadUser()<br>    }</pre><pre>    Text(text = user.value?.name ?: &quot;Loading...&quot;)<br>}</pre><p>The UI is thin. Logic lives in shared code.</p><h3>Why This Architecture Feels Revolutionary</h3><p>Because suddenly:</p><ul><li>One bug fix fixes multiple platforms</li><li>One feature reaches multiple users</li><li>One mental model replaces many</li></ul><p>You’re not fighting platforms anymore.<br>You’re <strong>designing systems</strong>.</p><h3>Welcome to the KMP/CMP revolution.</h3><p>Follow me for more : <a href="https://www.linkedin.com/in/goyaljai/?originalSubdomain=in">https://www.linkedin.com/in/goyaljai/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=841428c8379c" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/i-was-afraid-of-kmp-cmp-now-i-dont-want-to-build-apps-without-them-841428c8379c">I Was Afraid of KMP &amp; CMP — Now I Don’t Want to Build Apps Without Them</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building & Flashing a Custom AOSP GSI on Pixel (ARM64) || Android 16]]></title>
            <link>https://proandroiddev.com/building-flashing-a-custom-aosp-gsi-on-pixel-arm64-android-16-1313b4211c53?source=rss-90534ad9d452------2</link>
            <guid isPermaLink="false">https://medium.com/p/1313b4211c53</guid>
            <category><![CDATA[android-16]]></category>
            <category><![CDATA[aosp]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Jai Goyal]]></dc:creator>
            <pubDate>Wed, 18 Jun 2025 18:26:30 GMT</pubDate>
            <atom:updated>2025-06-19T08:23:52.016Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0qQzSVyiBL_bZom--zINVA.png" /><figcaption>AI Generated</figcaption></figure><p>Here’s a complete <strong>step-by-step article-style guide</strong> for building and flashing a <strong>custom AOSP GSI</strong> (arm64) onto any bootloader-unlocked device, we will do it for Pixel here. This article includes build setup, flashing, key dos and don’ts, and common pitfalls.</p><p>Running a <strong>Generic System Image (GSI)</strong> on an Android device is a powerful way (way more powerful than an emulator) to test AOSP across hardware, vendors, and configurations. This guide walks you through:</p><ol><li>Building your GSI (system.img and vbmeta.img)</li><li>Flashing the device with stock firmware (where you can unlock the bootloader) — many OEMs don’t allow users to unlock the bootloader. We are using Pixel anyway, and we can unlock the bootloader in a Pixel.</li><li>Replacing the system partition with your custom-made GSI</li></ol><h3>Prerequisites</h3><ul><li>An Android phone with the <strong>bootloader unlocked</strong></li><li>Ubuntu or Debian-based Linux host machine</li><li>adb, fastboot, and repo installed</li><li>Read the last section of this article <strong>(</strong>DOs and DON’Ts<strong>)</strong></li></ul><h3>Step 1: Set up the AOSP Build Environment</h3><pre>sudo apt-get update<br>sudo apt-get install git openjdk-17-jdk python3 \<br>    repo make bc bison curl flex g++ gperf \<br>    libncurses5-dev libssl-dev libxml2-utils \<br>    unzip zip zlib1g-dev ccache lzop</pre><p>Create a working directory:</p><pre>mkdir ~/aosp-gsi &amp;&amp; cd ~/aosp-gsi<br>repo init -u https://android.googlesource.com/platform/manifest -b android-16.0.0_r1<br>repo sync -c -j$(nproc)</pre><h3>Step 2: Build the GSI</h3><h3>🔹 Source the environment</h3><pre>source build/envsetup.sh</pre><h3>🔹 Choose the correct target</h3><p>For 64-bit A/B devices (most modern Pixels):</p><pre>lunch aosp_arm64-bp2a-userdebug</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gfnlDrGJSNzLj81rwE7EQA.png" /><figcaption>lunch — help</figcaption></figure><h3>🔹 Build the system image</h3><pre>make -j$(nproc) systemimage</pre><h3>🔹 Build vbmeta</h3><pre>make -j$(nproc) vbmetaimage</pre><h3>✅ Output location</h3><ul><li>out/target/product/generic_arm64/system.img</li><li>out/target/product/generic_arm64/vbmeta.img</li></ul><h3>Step 3: Flash Stock Factory Image (with vendor, boot, etc.)</h3><p>Visit: <a href="https://flash.android.com/">https://flash.android.com</a></p><ol><li>Connect your Pixel via USB (enable USB debugging)</li><li>Follow the site instructions</li><li>Unlock the bootloader if prompted</li><li>Select the correct factory image</li><li>Flash with <strong>--wipe enabled</strong></li></ol><p>💡 This step <strong>resets your device and installs factory boot, vendor, and recovery partitions</strong> — crucial for GSI stability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ve6nMGcXscfSkPliF1qJnA.png" /><figcaption>This should look like this</figcaption></figure><h3>Step 4: Replace with Your own GSI</h3><p>Now that the Pixel has factory vendor/boot, you’re ready to flash your own GSI.</p><h3>🔹 Reboot to fastboot mode</h3><pre>adb reboot bootloader</pre><h3>🔹 Flash vbmeta.img with AVB disabled</h3><pre>fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img</pre><p>⚠️ This step is <strong>essential</strong>. Without this, GSI may fail to boot due to AVB integrity checks.</p><h3>🔹 Flash system.img</h3><pre>fastboot flash system system.img</pre><h3>🔹 (Optional) Wipe data for clean GSI boot</h3><pre>fastboot -w</pre><h3>🔹 Reboot</h3><pre>fastboot reboot</pre><p>Now you should boot into your custom GSI!</p><h3>DOs and DON’Ts</h3><p>This is the last section of the article, but it should be read first.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dUXpP2OCgYTAMd4_LNADUg.png" /></figure><p>Thank you for taking the time to read this article. I’ve spent considerable time working with AOSP and tackling its challenging build errors.</p><p>I’m committed to supporting anyone facing issues, so we can grow together and contribute more to the AOSP community.</p><p>Feel free to drop me a message on LinkedIn and follow me for more AOSP-focused content. : <a href="https://in.linkedin.com/in/goyaljai">https://in.linkedin.com/in/goyaljai</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1313b4211c53" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/building-flashing-a-custom-aosp-gsi-on-pixel-arm64-android-16-1313b4211c53">Building &amp; Flashing a Custom AOSP GSI on Pixel (ARM64) || Android 16</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Modern Developer Terminal Setup on macOS (2025 Edition)]]></title>
            <link>https://blog.stackademic.com/modern-developer-terminal-setup-on-macos-2025-edition-748e19f0b753?source=rss-90534ad9d452------2</link>
            <guid isPermaLink="false">https://medium.com/p/748e19f0b753</guid>
            <category><![CDATA[developer-experience]]></category>
            <category><![CDATA[developer-productivity]]></category>
            <category><![CDATA[mac]]></category>
            <category><![CDATA[developer-tools]]></category>
            <category><![CDATA[macos]]></category>
            <dc:creator><![CDATA[Jai Goyal]]></dc:creator>
            <pubDate>Wed, 14 May 2025 11:59:00 GMT</pubDate>
            <atom:updated>2025-05-23T02:52:38.966Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Ultimate Terminal Setup for Developers on macOS (2025 Edition)</h3><h3>The default Terminal app on macOS is fine — but it’s missing many modern conveniences that boost developer speed, visibility, and comfort.</h3><h3>What we are going to do?</h3><p><strong>Warp</strong> Modern terminal with IDE-like UX (autocomplete, blocks, tabs, themes). <strong>zsh</strong> An advanced shell (replaces Bash) with better scripting and plugins. <strong>starship</strong> Fast, cross-shell prompt with Git info, icons, and customization. <strong>tmux</strong> Terminal multiplexer — split panes, tabs, persistent sessions. <strong>fzf</strong> Fuzzy finder — fast file search, history search, Git commits, etc. <strong>bat</strong> Modern cat – shows file content with syntax highlighting. <strong>ripgrep</strong> Blazing fast search – replaces grep, ideal for large codebases. <strong>eza</strong> Modern ls with icons, Git info, better formatting (replaces exa).</p><h3>✅ 1. Install Homebrew (If Not Installed)</h3><p>Homebrew is the package manager we’ll use to install everything:</p><pre>/bin/bash -c &quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)&quot;</pre><h3>✅ 2. Install Warp (Your Terminal)</h3><pre>brew install --cask warp</pre><p>➡️ Open Warp from Launchpad or Applications folder.</p><h3>✅ 3. Set zsh as Your Default Shell</h3><p>Check your shell:</p><pre>echo $SHELL</pre><p>If it’s not /bin/zsh, set it:</p><pre>chsh -s /bin/zsh</pre><p>Then close and reopen Warp.</p><h3>✅ 4. Install Starship (Modern Prompt)</h3><pre>brew install starship</pre><p>Then add this to your ~/.zshrc:</p><pre>eval &quot;$(starship init zsh)&quot;</pre><p>Reload with:</p><pre>source ~/.zshrc</pre><h3>✅ 5. Install CLI Power Tools</h3><pre>brew install tmux fzf bat ripgrep eza</pre><blockquote><em>🛑 </em><em>exa is deprecated — </em><em>eza is the drop-in replacement.</em></blockquote><h3>✅ 6. Configure Your Shell (~/.zshrc)</h3><p>Open your Zsh config:</p><pre>nano ~/.zshrc</pre><p>Paste the following content:</p><pre># --- Starship Prompt ---<br>eval &quot;$(starship init zsh)&quot;</pre><pre># --- Aliases: File Navigation ---<br>alias ls=&#39;eza --icons --group-directories-first&#39;<br>alias ll=&#39;eza -lah --icons&#39;<br>alias la=&#39;eza -a --icons&#39;<br>alias l=&#39;eza -l --icons&#39;<br>alias ..=&#39;cd ..&#39;<br>alias ...=&#39;cd ../..&#39;<br>alias ....=&#39;cd ../../..&#39;<br>alias ~=&#39;cd ~&#39;<br>alias c=&#39;clear&#39;</pre><pre># --- Aliases: File Preview &amp; Search ---<br>alias cat=&#39;bat&#39;<br>alias findf=&#39;fzf&#39;<br>alias grep=&#39;rg&#39;<br>alias search=&#39;rg&#39;<br>alias f=&#39;rg --files | fzf&#39;<br>alias ff=&#39;rg --no-heading --line-number&#39;</pre><pre># --- Aliases: System ---<br>alias updatebrew=&#39;brew update &amp;&amp; brew upgrade &amp;&amp; brew cleanup&#39;<br>alias ports=&#39;lsof -i -P -n | grep LISTEN&#39;<br>alias ip=&#39;ipconfig getifaddr en0&#39;<br>alias myip=&#39;curl ifconfig.me&#39;<br>alias please=&#39;sudo $(fc -ln -1)&#39;<br>alias usage=&#39;du -sh * | sort -h&#39;</pre><pre># --- Aliases: Git ---<br>alias gs=&#39;git status&#39;<br>alias ga=&#39;git add .&#39;<br>alias gc=&#39;git commit -m&#39;<br>alias gp=&#39;git push&#39;<br>alias gpl=&#39;git pull&#39;<br>alias gl=&#39;git log --oneline --graph --decorate&#39;<br>alias gco=&#39;git checkout&#39;<br>alias gb=&#39;git branch&#39;<br>alias gcb=&#39;git checkout -b&#39;<br>alias gstash=&#39;git stash&#39;<br>alias gstashpop=&#39;git stash pop&#39;<br>alias gd=&#39;git diff&#39;</pre><pre># --- Aliases: Dev Env ---<br>alias serve=&#39;python3 -m http.server&#39;<br>alias reload=&#39;source ~/.zshrc&#39;<br>alias editz=&#39;nano ~/.zshrc&#39;<br>alias editsh=&#39;nano ~/.bashrc&#39;<br>alias mkd=&#39;mkdir -p&#39;<br>alias tree=&#39;eza --tree&#39;</pre><pre># --- Aliases: Docker ---<br>alias dps=&#39;docker ps&#39;<br>alias dpa=&#39;docker ps -a&#39;<br>alias di=&#39;docker images&#39;<br>alias dstart=&#39;docker start&#39;<br>alias dstop=&#39;docker stop&#39;<br>alias drm=&#39;docker rm&#39;<br>alias drmi=&#39;docker rmi&#39;<br>alias dexec=&#39;docker exec -it&#39;</pre><pre># --- Aliases: Cleanup ---<br>alias cl=&#39;clear &amp;&amp; echo &quot;📦 Clean and ready!&quot;&#39;<br>alias flushdns=&#39;sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder&#39;<br>alias cleanupnode=&#39;rm -rf node_modules &amp;&amp; rm package-lock.json &amp;&amp; npm install&#39;<br>alias cleanupgit=&#39;git clean -fd &amp;&amp; git reset --hard&#39;</pre><pre># --- Aliases: Networking ---<br>alias pingg=&#39;ping google.com&#39;<br>alias speed=&#39;curl -s <a href="https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py">https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py</a> | python3 -&#39;<br>alias httpserver=&#39;python3 -m http.server 8000&#39;</pre><pre># --- Aliases: Productivity ---<br>alias now=&#39;date +&quot;%T&quot;&#39;<br>alias today=&#39;date +&quot;%A, %B %d, %Y&quot;&#39;<br>alias wttr=&#39;curl wttr.in&#39;<br>alias cal=&#39;cal -3&#39;<br>alias stopwatch=&#39;time read -p &quot;Press enter to stop...&quot;&#39;</pre><pre># --- Aliases: NPM / Node ---<br>alias ni=&#39;npm install&#39;<br>alias nr=&#39;npm run&#39;<br>alias ns=&#39;npm start&#39;<br>alias nt=&#39;npm test&#39;<br>alias nb=&#39;npm run build&#39;</pre><pre># --- Aliases: Yarn ---<br>alias yi=&#39;yarn install&#39;<br>alias ys=&#39;yarn start&#39;<br>alias yt=&#39;yarn test&#39;<br>alias yb=&#39;yarn build&#39;</pre><pre># --- Aliases: Java ---<br>alias javacompile=&#39;javac *.java&#39;<br>alias javarun=&#39;java Main&#39;</pre><pre># --- Reload Shell ---<br>alias restart-shell=&#39;exec $SHELL -l&#39;</pre><pre># --- fzf Config ---<br>export FZF_DEFAULT_COMMAND=&#39;rg --files --hidden --glob &quot;!.git/*&quot;&#39;<br>export FZF_CTRL_T_COMMAND=&quot;$FZF_DEFAULT_COMMAND&quot;</pre><p>Then reload:</p><pre>source ~/.zshrc</pre><h3>✅ 7. Enhance fzf</h3><pre>&quot;$(brew --prefix)/opt/fzf/install&quot; --all</pre><h3>✅ 8. Configure starship.toml (Optional)</h3><pre>mkdir -p ~/.config<br>nano ~/.config/starship.toml</pre><p>Paste:</p><pre>format = &quot;&quot;&quot;<br>$directory$git_branch$git_status$nodejs$python$rust<br>$character<br>&quot;&quot;&quot;<br><br>add_newline = true<br><br>[directory]<br>truncation_length = 3<br><br>[character]<br>success_symbol = &quot;[➜](bold green)&quot;<br>error_symbol = &quot;[✗](bold red)&quot;</pre><h3>✅ 9. Try It Out</h3><pre>ls           # Pretty icons with eza<br>cat ~/.zshrc # Highlighted preview with bat<br>fzf          # Fuzzy file picker<br>tmux         # Opens tmux session<br>gs           # git status</pre><p>Thanks a lot for reading this, Hope this will help you become a better and productive developer.</p><p>Follow me on Linkedin for more such articles and updates. <a href="https://in.linkedin.com/in/goyaljai">https://in.linkedin.com/in/goyaljai</a></p><h3>Thank you for being a part of the community</h3><p><em>Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏<strong>️️</strong></li><li>Follow us: <a href="https://x.com/inPlainEngHQ"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/inplainenglish/"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/@InPlainEnglish"><strong>YouTube</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a> | <a href="https://open.spotify.com/show/7qxylRWKhvZwMz2WuEoua0"><strong>Podcast</strong></a> | <a href="https://differ.blog/inplainenglish"><strong>Differ</strong></a> | <a href="https://twitch.tv/inplainenglish"><strong>Twitch</strong></a></li><li><a href="https://differ.blog/"><strong>Start your own free AI-powered blog on Differ</strong></a> 🚀</li><li><a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Join our content creators community on Discord</strong></a> 🧑🏻‍💻</li><li>For more content, visit <a href="https://plainenglish.io/"><strong>plainenglish.io</strong></a> + <a href="https://stackademic.com/"><strong>stackademic.com</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=748e19f0b753" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/modern-developer-terminal-setup-on-macos-2025-edition-748e19f0b753">Modern Developer Terminal Setup on macOS (2025 Edition)</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enhancing App Performance: A Practical Approach at Glance]]></title>
            <link>https://engg.glance.com/enhancing-app-performance-a-practical-approach-at-glance-0abe9ee24449?source=rss-90534ad9d452------2</link>
            <guid isPermaLink="false">https://medium.com/p/0abe9ee24449</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[performance]]></category>
            <dc:creator><![CDATA[Jai Goyal]]></dc:creator>
            <pubDate>Mon, 27 Nov 2023 11:34:15 GMT</pubDate>
            <atom:updated>2023-11-30T10:15:18.563Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y2Vrfl-qasccMtl8FSaLBw.png" /></figure><h3>What Makes Glance Android Apps Different?</h3><p>We’re proud of our robust integration with a multitude of industry-leading Original Equipment Manufacturers (OEMs) across diverse regions (India, Indonesia, Latin America and Japan), leading to a broad and varied user base.</p><p>Distinguishing ourselves from conventional applications, we collaborate with OEMs to showcase our content on <strong>Lockscreen (initial user encounter)</strong>, a feature uncommon in typical applications on PlayStore. Our uniqueness lies in our need for expertise at the core framework level of Android.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*DjvL2A48I9vndBgfv0Brog.png" /><figcaption><strong>Lockscreen (initial user encounter)</strong></figcaption></figure><h3>What to Expect from this article — We can’t tolerate Lag</h3><p>Beyond that, given that our content surfaces as the <strong>Lockscreen (initial user encounter)</strong>, there is zero tolerance for lag and failures. Therefore, our application must exemplify robustness, ensuring a seamless and smooth performance. Let’s delve into the details of this article to explore these key aspects further.</p><p>In this article, we lift the hood on the intricate process of enhancing Android app performance, shedding light on profiling and benchmarking — two cornerstones of our strategy.</p><h3><em>Our Objective</em></h3><p><strong>At Glance</strong>, our dedication to excellence extends beyond feature-rich applications to the very core of user interaction. The objective of this article is to provide you with a glimpse into our methodologies and ways to improve the app’s performance. We want you to understand not only the ‘<strong>what</strong>’ but, more importantly, the ‘<strong>how</strong>’ behind our efforts.</p><h4>As we unravel the intricacies of profiling, and benchmarking, Let us first start with Passive performance inspection</h4><h3>A. Passive performance inspection</h3><p>Here in Glance, our initial step involves a meticulous examination to gauge any decline in performance or identify potential issues affecting our system’s efficiency. This proactive approach allows us to swiftly address and rectify performance-related concerns, ensuring seamless functionality and optimal user experience.</p><p><strong>Checkpoint:</strong> Observable Issues — Keep an eye out for dropped or frozen frames, as well as instances of Application Not Responding (ANR).</p><h3>Keywords for Logcat filter:</h3><ul><li><strong>Slow frames</strong> (&gt;30 frames dropped): <strong>package:mine tag: Choreographer</strong></li><li><strong>Frozen frames </strong>(&gt;700ms to render): <strong>package:mine tag: OpenGLRenderer</strong></li><li><strong>ANR</strong> (&gt;5 seconds)</li><li><strong>App launch durations (0.5 seconds are desirable)</strong>: <strong>ActivityTaskManager<br>— </strong><strong>Displayed</strong>: Time to Initial Display<br>— <strong>Fully Drawn</strong>: Time to Fully Display</li></ul><h4>Let us now discuss The Profiling — Our first cornerstone</h4><h3>B. Profiling</h3><p>Following the preliminary examination discussed above, we delve into foundational profiling procedures.</p><p><strong>Profiler</strong> on Android Studio is what we need — it can inspect the following:</p><ul><li>CPU, Memory, or Network usage</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*YCnD83iWPaN9u19oqHFRXg.png" /></figure><p>For more information on the Android Profiler tool, please refer to the following link: <a href="https://developer.android.com/studio/profile">https://developer.android.com/studio/profile</a>. If you are unfamiliar with this tool, this resource provides comprehensive insights.</p><h3>Changes in AndroidManifest.xml</h3><p>To enable the profiler to scrutinize activities within a production build, it’s essential to incorporate the following:</p><pre>&lt;manifest...<br>    &lt;application&gt;<br>        &lt;profileable android:shell=&quot;true&quot; /&gt;<br>    &lt;/application&gt;<br>&lt;/manifest&gt;</pre><h3>C. JankStats</h3><h4><strong>Our company has recently adopted JankStats to monitor and analyze UI performance.</strong></h4><p>JankStats offers additional features beyond the platform, including heuristics to identify the cause of frame drops, interface states for more context in reports, and report callbacks for uploading data for analysis.</p><p>refer : <a href="https://developer.android.com/topic/performance/jankstats">https://developer.android.com/topic/performance/jankstats</a></p><p>Let’s delve into the three main functions of JankStats:</p><ol><li>Identify Lags:</li></ol><ul><li>JankStats uses built-in heuristics to pinpoint when lags occur and issues lag reports. This helps developers gather information to analyze and resolve these issues effectively.</li></ul><p>2. Provide Interface Context:</p><ul><li>JankStats enhances the usability of jank reports by allowing developers to track the current interface and user status. When a report is logged, it facilitates the identification of problematic areas in the app for future fixes. While some of this state is automatically provided by Jetpack libraries, developers are encouraged to add their application-specific state.</li></ul><p>3. Reporting Results:</p><ul><li>With each frame, the JankStats client receives a notification through the listener containing information about the frame, including its completion time, whether it was considered stuck, and the interface context during the frame display. Clients are encouraged to aggregate and upload data suitable for analysis, contributing to the identification and debugging of overall performance issues.</li></ul><h4>Let us now discuss the Benchmarking of our app — Our second cornerstone</h4><h3>D. Benchmarking</h3><p>Following the 1. initial inspection and 2. subsequent profiling, the next step involves a thorough examination of specific libraries.</p><h3><a href="https://developer.android.com/topic/performance/benchmarking/macrobenchmark-overview">Macrobenchmark</a> and <a href="https://developer.android.com/topic/performance/benchmarking/microbenchmark-overview">Microbenchmark</a>.</h3><p>Jetpack Benchmark offers us two libraries as we have two different approaches to benchmarking: <a href="https://developer.android.com/topic/performance/benchmarking/macrobenchmark-overview">Macrobenchmark</a> and <a href="https://developer.android.com/topic/performance/benchmarking/microbenchmark-overview">Microbenchmark</a>.</p><blockquote><strong>Micro-benchmarks</strong>, consist of repeatable code sections, can be informative but <strong>may not accurately reflect real-world </strong>behavior. Variables such as Java virtual machine warm-up time and global code interactions can influence micro-benchmark performance.</blockquote><blockquote><strong>Macro-benchmarks</strong> involve repeatable test sequences from the user’s perspective, providing a more holistic assessment of your system by simulating how actual end users would experience it.</blockquote><p><strong>The philosophy</strong> of our Engineering team is to prioritize the user’s perspective, considering it a paramount factor. This emphasis is reflected in our approach to performance evaluation, where we meticulously assess critical aspects such as the app’s startup performance, UI frame timing, and simulate tests that mirror the actual experience of end users.</p><blockquote>The above philosophy can be handled by Macrobenchmark library</blockquote><h4>Let&#39;s deep dive into Setting up Macrobenchmark module</h4><ol><li><strong>Project</strong> -&gt; <strong>New</strong> -&gt; <strong>New Module</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I4SBc4sphQ-LJx7kquaqHA.png" /></figure><p>2. All essential configurations will be handled automatically, including the addition of a new build type, ‘benchmark,’ in the <strong>build.gradle</strong>. Additionally, we have the flexibility to tailor our Gradle builds further, enabling the fine-tuning of microbenchmarks across various build flavors.</p><h3>2 Points to take care of after the Macrobenchmark module setup.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7XM35aAqFL1-qVCxovblpg.png" /></figure><ol><li>You need to create a separate build type for <strong>benchmark</strong>. Neither release nor debug build type will do. We need all the optimizations that are in the release build type (<em>in our case, we have a </em><strong><em>aosp</em></strong><em> build variant</em>) and signing with debug keys. Therefore, when generating a benchmark module, it automatically creates a new build type — <strong>benchmark</strong>. <em>In our case, it will be </em><strong><em>aospBenchmark</em></strong>. We make it a copy of the release build type using the initWith keyword.</li></ol><p>2. We need to set the <strong>debuggable</strong> flag to false.</p><h4>The below gradle snippet comes from our production deployed app. Refer below.</h4><pre>android {<br>    ...<br>    <br>    buildTypes {<br>        debug {<br>            debuggable true<br>            zipAlignEnabled false<br>            minifyEnabled false<br>            shrinkResources false<br>            signingConfig signingConfigs.debug<br>        }<br>        release {<br>            zipAlignEnabled true<br>            minifyEnabled true<br>            shrinkResources true<br>            signingConfig signingConfigs.debug<br>            proguardFiles getDefaultProguardFile(&#39;proguard-android-optimize.txt&#39;), &#39;proguard-rules.pro&#39;<br>        }<br>        preRelease {<br>            initWith release<br>            matchingFallbacks = [&#39;release&#39;]<br>        }<br>        perf {<br>            initWith release<br>            matchingFallbacks = [&#39;release&#39;]<br>        }<br>        benchmark {<br>            initWith release<br>            matchingFallbacks = [&#39;release&#39;]<br>            debuggable false<br>        }<br>    }<br>    <br>    ...<br>}</pre><p>Please take note of the following:</p><ol><li>It is imperative to execute the application on an actual device to avoid encountering a runtime error, as opposed to running it on an emulator.</li><li>Keep in mind that the test results, formatted in JSON, are stored in <strong><em>benchmark/build/outputs/connected_android_test_additional_output</em></strong> for processing in the continuous integration (CI) pipeline.</li></ol><h4>Create benchmark tests</h4><p>Write them in a manner similar to regular instrumentation tests.. If you’re not acquainted with this concept, you can consult the associated documentation available at: <a href="https://developer.android.com/topic/performance/benchmarking/macrobenchmark-overview">https://developer.android.com/topic/performance/benchmarking/macrobenchmark-overview</a>.</p><p>Nevertheless, I’ll explain the fundamental components of benchmark tests below.</p><pre>import android.content.Context<br>import androidx.benchmark.macro.Macrobenchmark<br>import androidx.test.platform.app.InstrumentationRegistry<br>import androidx.test.ext.junit.runners.AndroidJUnit4<br>import org.junit.Before<br>import org.junit.Test<br>import org.junit.runner.RunWith<br><br>@RunWith(AndroidJUnit4::class)<br>class LoginBenchmark {<br><br>    private lateinit var context: Context<br><br>    @Before<br>    fun setup() {<br>        context = InstrumentationRegistry.getInstrumentation().targetContext<br>        // Additional setup logic if needed<br>    }<br><br>    @Macrobenchmark<br>    @Test<br>    fun benchmarkLoginPerformance() {<br>        // Benchmark logic for the Login Module<br>        // Measure and record relevant performance metrics<br>    }<br>}</pre><h4>Explanation</h4><ol><li><strong>Imports</strong>: Import necessary classes for Android testing and benchmarking.</li></ol><p>2. <strong>Class and Setup:</strong></p><ul><li>@RunWith(AndroidJUnit4::class): Specifies the use of the AndroidJUnit4 test runner.</li><li>class LoginBenchmark: Declares a class for testing the login module&#39;s performance.</li><li>private lateinit var context: Context: Declares a property for the application context.</li><li>@Before: Annotates a setup method executed before each test.</li><li>fun setup() { ... }: Initializes the context property with the target context.</li></ul><p>3. <strong>Benchmark Method:</strong></p><ul><li>@Macrobenchmark: Annotates the benchmark method, marking it as a macrobenchmark.</li><li>@Test: Annotates the method as a test.</li><li>fun benchmarkLoginPerformance() { ... }: Defines the benchmark method. Implement the logic here to benchmark the login module&#39;s performance, including measuring and recording relevant metrics.</li></ul><p>Here is the full working example for your reference.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/20caa898f751a46989741eaee185bc55/href">https://medium.com/media/20caa898f751a46989741eaee185bc55/href</a></iframe><h4>Let us discuss Power Profiler, our crucial ally providing real-time insights into power consumption patterns</h4><h3>4. Battery!! Power Consumption: New Power Profiler</h3><p>In Glance, using the <strong>Power Profiler </strong>of Android Studio plays a pivotal role in monitoring power consumption on devices. Within the On Device Power Rails Monitor (ODPM), a feature of our workflow, this tool effectively segments data into subsystems known as Power Rails. Refer to the “Profileable power rails” documentation for a comprehensive list of supported subsystems.</p><p>The integration of the System Trace, embedded in the CPU profiler, is another noteworthy aspect of our approach. This feature records and presents power consumption data, allowing us to visually correlate the device’s power usage with the specific actions unfolding in our app. The Power Profiler, a key visualization tool within our toolkit, facilitates a clear understanding of this power consumption data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LXisSqEp3aPGfXL9-iMNKw.png" /></figure><p>To view the data from the new Power Profiler, for example, take a system trace on a Pixel 6+ device:</p><ol><li>Select <strong>View &gt; Tool Windows &gt; Profiler</strong>.</li><li>Click anywhere in the <strong>CPU timeline</strong> to open the CPU Profiler and start a system trace.</li></ol><p>This Power profiler acts as a crucial ally for our development team here at Glance, providing dynamic, real-time insights into power consumption patterns. It allows us to pinpoint and refine energy-intensive components.</p><p><strong>Thank you for joining me on this exploration of <em>Improving Android App Performance</em>, let&#39;s look forward to the exciting advancements that lie ahead. Happy coding!</strong></p><p>Follow me for more such interesting topics:</p><p><a href="https://www.linkedin.com/in/goyaljai">https://www.linkedin.com/in/goyaljai</a></p><p><a href="https://goyaljai.medium.com/">https://goyaljai.medium.com/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0abe9ee24449" width="1" height="1" alt=""><hr><p><a href="https://engg.glance.com/enhancing-app-performance-a-practical-approach-at-glance-0abe9ee24449">Enhancing App Performance: A Practical Approach at Glance</a> was originally published in <a href="https://engg.glance.com/">Glance</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Open Source Platform (AOSP) Build Systems]]></title>
            <link>https://proandroiddev.com/android-open-source-platform-aosp-build-systems-c98abb390d2d?source=rss-90534ad9d452------2</link>
            <guid isPermaLink="false">https://medium.com/p/c98abb390d2d</guid>
            <category><![CDATA[aosp]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-framework]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Jai Goyal]]></dc:creator>
            <pubDate>Fri, 24 Feb 2023 15:26:29 GMT</pubDate>
            <atom:updated>2023-02-27T22:44:37.059Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l_WHWNTEyLDy-mIFcWl7aA.jpeg" /></figure><h3><strong>Ever wondered how the Android Pre-built Apps were made, and what was the build system behind it?</strong></h3><p>One common pain point that most Android developers face is finding quality resources on the core and internal functioning of the Android Operating System.</p><p>Framework development is not easy and on top of it, building a framework app along with its intricacies can be confusing.</p><blockquote>Over the last two years, I have accumulated a wealth of knowledge about the Android Build System and its integration with original equipment manufacturers (OEMs).</blockquote><p>This article aims to share these learnings and simplify the process of understanding AOSP’s complex mechanisms. Instead of manually going through various files and their internal workflows, this can act as a quick guide to entering the realm of the AOSP build system.</p><blockquote>We are not discussing gradle build system here, Android Platform build system is very different from the Android Application build system which is based on gradle.</blockquote><h3>What will you learn here?</h3><p>By the end of this article, you’ll understand and be aware of all the intricacies, functionalities, definitions, and linkages around Android’s Platform Build System. In the following four points, we would be discussing in deep detail one by one.</p><ol><li><strong>Setting up the environment</strong><br>- <em>source build/envsetup.sh</em></li><li><strong>Choose a target product to build with</strong><br>- <em>lunch &lt;option&gt;</em></li><li><strong>Building the code</strong><br>- <em>make &lt;module-name&gt;</em> or <em>m &lt;module-name&gt;</em></li><li><strong>Run/flash/install on the device</strong><br>- <em>Push the apk via adb push</em><br>- <em>Flash the image via fastboot</em></li></ol><blockquote>But before we deep dive into above mentioned 4 steps, there are some pre-requisites :</blockquote><blockquote>A. Evolution of the Android build System</blockquote><blockquote>B.Android.bp and blueprinting</blockquote><blockquote>C.Download AOSP Source</blockquote><h3>A. Evolution of the Android build System</h3><h4>- Before Android N(v7.0),</h4><p>The compilation was done by a tool <a href="https://www.gnu.org/software/make/"><strong>GNU make</strong></a>. All rules were written in a configuration file called <strong>Makefile </strong>and<strong> </strong>the<strong> make </strong>tool will compile the code according to the instructions in the <strong>Makefile</strong>.</p><p><strong>What is </strong><a href="https://www.gnu.org/software/make/"><strong>make</strong></a><strong>?</strong> make is an automated build tool, make automatically builds the source code into executable programs and library files by reading Makefile.</p><p><strong>What is </strong><a href="https://opensource.com/article/18/8/what-how-makefile"><strong>Makefile</strong></a><strong> or .mk File?</strong> The Makefile defines the dependencies of the target program and the relevant rules for generating the target program.</p><blockquote>Just like Gradle has build.gradle, make has Makefile (main.mk).</blockquote><h4>- After Android N(v7.0)</h4><p>at the Android level, <a href="https://www.gnu.org/software/make/">GNU Make</a> compilation was becoming slow, error-prone, non-scalable, and difficult to test, so<strong><em>, </em></strong>Google introduced the <a href="https://ninja-build.org/"><strong>Ninja</strong></a><strong> build system</strong> which provided flexibility to the Android build system, as the <strong><em>.ninja</em></strong> files were humanly readable.</p><p><strong>What is </strong><a href="https://ninja-build.org/"><strong>ninja</strong></a><strong>?</strong> It is a compilation framework, which will be compiled according to the <strong>.bp(blueprint)</strong> file in the corresponding <strong>.ninja</strong> file. Generally, <strong>.ninja</strong> file will not be modified manually rather <strong>.ninja</strong> is compiled by converting the <strong>.bp(blueprint)</strong> into a <strong>.ninja</strong> file.</p><p><strong>What is </strong><a href="https://android.googlesource.com/platform/build/soong/"><strong>soong</strong></a><strong> and .bp File? </strong>To generate .ninja files, Google introduced <a href="https://android.googlesource.com/platform/build/soong/"><strong>soong</strong></a> build system with a tool called <strong>blueprint</strong> that parses Android.bp files to .ninja files, and also introduced <a href="https://android.googlesource.com/platform/build/kati/">kati</a> tool to convert Android.mk files to .ninja files.</p><p><strong>What is </strong><a href="https://android.googlesource.com/platform/build/kati/"><strong>kati</strong></a><strong>? </strong>A tool based on <strong>Golang and C++</strong>, the main function is to convert complex <strong>Android.mk</strong> files into <strong>ninja</strong> files</p><p><strong><em>P.S.: Soong also compiles and generates an </em>androidmk <em>command that converts Android.mk file to an Android.bp file</em></strong></p><blockquote>Just like Gradle has build.gradle, ninja has build.ninja.</blockquote><h4>- During the Release notes of Android in 2020, Google said that they will start migrating the build system to <a href="https://bazel.build/">Bazel</a>.</h4><h3>B. We have to know about Android.bp and blueprinting in detail</h3><p>In Android.bp, we will build what we need based on the module type.</p><p><strong>The commonly used types and methods are as follows:</strong></p><ul><li><strong>android_app: </strong>It is used to build apk, which has the same function as Android.mk BUILD_PACKAGE.</li><li><strong>java_library: </strong>It produces a .jar bundle from .class files. The resulting jar is not suitable for direct installation on the device, rather it will be used as a static_libs dependency.</li><li><strong>static_libs: </strong>libraries resolved in a caller at compile-time and copied into a target application by the compiler</li><li><strong>android_library: </strong>Build and link the source code with the Android resource files into the device’s .jar file.<br>android_library has a different variant that produces a .jar bundle from .class files. and a file named package-res.apk generated from aapt2. The generated apk file cannot be installed directly on the device but can be used as <strong>android_app</strong> module‘s <strong>static_libs</strong> dependency.</li><li><strong>platform_apis:</strong> Compile with SDK’s hide api</li><li><strong>certificate:</strong> Specifies what signature is used, as above, the platform signature is used.</li><li><strong>android_library_import : </strong>Imports a android archive (aar) to android_app which must be used as a android_app module ‘s static_libs dependency.</li></ul><p><strong>Let’s try to create a random sample App called GlanceApp, </strong>Below is the Sample Android.bp file<strong> </strong>where in the <strong><em>GlanceApp</em></strong> module, <strong><em>glance_android_library</em></strong> is introduced as a static dependency, which in turn has <strong><em>glance_java_library</em></strong> and <strong><em>content_aar_plugin</em></strong> as the dependency to make <strong>GlanceApp.apk</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/23dd9f49f9ab7042fba4c184309dbe18/href">https://medium.com/media/23dd9f49f9ab7042fba4c184309dbe18/href</a></iframe><blockquote>so <strong>content_aar_plugin</strong> is added to your app with <strong>glance_android_library</strong>. I have added <strong>glide</strong> (third party library) as a dependency too.</blockquote><blockquote>since we have specified <strong>privileged</strong> to <strong>true</strong> and <strong>certificate</strong> to the <strong>platform</strong>, GlanceApp will act as a system-privileged app.</blockquote><h3>C. Download AOSP Source, If you haven’t done already</h3><p>We will use Pixel 6a (codenamed “bluejay”) as the device example. We will walk through it in a succinct manner without detailed explanations.</p><pre>mkdir android-13.0.0_r12<br>cd android-13.0.0_r12<br>repo init --depth=1 -u https://android.googlesource.com/platform/manifest -b android-13.0.0_r12<br>repo sync  --force-sync --no-clone-bundle --no-tags -j$(nproc)</pre><p>Read for the <strong>complete AOSP setup</strong>. <a href="https://medium.com/@goyaljai/build-aosp-co-180bb3995dbc"><em>https://medium.com/@goyaljai/build-aosp-co-180bb3995dbc</em></a></p><h4>Now that you have learned about almost all of the prerequisites…</h4><h3>Wait !! Have a look at the high level diagram first.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OHur4M4reJGWzrH20_puiA.png" /><figcaption>Existing Android.mk and existing Android.bp will be converted to Ninja respectively.</figcaption></figure><p><strong>What does this flow diagram say?</strong></p><p>From <strong><em>Android.mk</em></strong> and other Makefiles, <strong><em>out/build-aosp_bluejay.ninja</em></strong> files will be generated.</p><p>From <strong><em>Android.bp</em></strong>, <strong><em>out/soong/build.ninja</em></strong> will be generated. In addition, a smaller <strong><em>out/combined-aosp_bluejay.ninja</em></strong> file will be generated, which is responsible for connecting the two as the execution entry.</p><p>In the end, Ninja files are the tools that really directly control source code compilation and are responsible for generating apk, aar, and dex files. The signing of the APK is also done using ninja rules and then once this all is done, *.imgs are created.</p><blockquote>Finally, The time has come. Let’s State the detailed discussed on these 3 steps.</blockquote><ol><li><em>source build/envsetup.sh</em></li><li><em>lunch &lt;option&gt;</em></li><li><em>make &lt;module-name&gt;</em> or <em>m &lt;module-name&gt;</em></li></ol><h3>The First Step of Android Compilation</h3><p><strong><em>source build/envsetup.sh</em></strong>.</p><p>This paves the way for subsequent compilation steps. It is essential to understand what envsetup.sh corresponds to our analysis.</p><p>so the envsetup.sh script defines many functions. After executing this script, you can directly execute these functions in the current console using Linux commands, such as <strong>lunch</strong>, <strong>mm</strong>, <strong>mmm</strong>, etc. (<em>use </em><strong><em>hmm</em></strong><em> to see all available commands</em>). So <strong>lunch</strong>, <strong>mmm</strong> are essentially a shell function, which is equivalent to a shell script. Let’s discuss the implementation principles of these commands in <strong><em>build/envsetup.sh</em></strong>.</p><h3>The Second Step of the Android Compilation</h3><p><strong><em>lunch</em></strong></p><p>lunch() function in <strong><em>envsetup.sh </em></strong>script sets the environment for building the images (*.imgs) and other artifacts like apk, jar, .so, etc. It reads a list of target devices from a list of files called AndroidProducts.mk.list. It takes COMMON_LUNCH_CHOICES variables from AndroidProducts.mk.list and shows to the user when print_lunch_menu() is called, from this function, get_build_var() is called which in turn calls <strong><em>build/soong/soong_ui.bash — dumpvar-mode</em></strong></p><p><strong><em>soong_ui.bash</em></strong> calls <strong><em>/build/soong/cmd/soong_ui/main.go</em></strong> into the <strong>main()</strong> function which calls <strong>build.FindSources(buildCtx, config, f)</strong> which finds all the <strong>AndroidProducts.mk</strong> and makes <strong>AndroidProducts.mk.list</strong> with a single <strong>COMMON_LUNCH_CHOICES. Check the snippets below …</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d3d1799f33ae43d06d78b627a6342954/href">https://medium.com/media/d3d1799f33ae43d06d78b627a6342954/href</a></iframe><h4>I want to discuss some less discussed yet important commands here.</h4><p><strong>1. set_stuff_for_environment: </strong>Its function is to add some paths to the PATH environment variable so that we can use some more tools in the Android source code in the console that has executed lunch. for eg. <strong>emulator</strong></p><p><strong>2. tapas:</strong> It sets up the build environment for building unbundled apps or rather APKs i.e. Normal Android Packages. You can choose chip architecture, and build variants and apps needed for the module to be built. eg : <strong>tapas SystemUI arm eng</strong><br><br><strong>3. banchan:</strong> It sets up the build environment for building unbundled modules or rather APEXs i.e. native services, libraries, HALs, etc. You can choose chip architecture, and build variants and apps needed for the module to be built. eg: <strong>banchan com.android.boinic SystemUI arm eng</strong></p><p><strong>4. make commands</strong></p><p>If you understood the principle of the lunch command, these commands will be very easy.</p><ul><li><strong>m</strong>: Makes from the top of the tree. <strong>eg: m or m &lt;module-name&gt;</strong></li><li><strong>mm</strong>: Builds and installs all of the modules in the current directory and their dependencies.</li><li><strong>mmm</strong>: Builds and installs all of the modules in the supplied directories and their dependencies. To limit the modules being built, use the syntax: mmm dir/:target1,target2. <strong>eg: mmm packages/apps/Launcher3</strong></li></ul><blockquote>There are several more commands supported, use <strong>hmm</strong> command to see the list.</blockquote><h3>The Third Step of Android Compilation</h3><p><strong><em>make </em></strong>or<strong><em> m</em></strong></p><h4>Previously (before Android N)</h4><p><strong><em>m</em></strong> or <strong><em>make</em></strong> command was equivalent to <strong><em>make -f build/core/main.mk </em></strong>(built via GNU make)</p><h4>Currently</h4><p><strong><em>m</em></strong> or <strong><em>make</em></strong> command is equivalent to <strong><em>build/soong/soong_ui.bash — make- mode </em></strong>which means that <strong><em>soong_ui.bash </em></strong>is the main heart of the Android Platform Build Systems.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/353738a364b5b9351ae5c766e5ea226d/href">https://medium.com/media/353738a364b5b9351ae5c766e5ea226d/href</a></iframe><p>It can be seen that the main logic of <strong>soong_ui.bash has 4</strong> parts</p><ol><li>run <strong>microfactory</strong> to set up the environment for building go scripts. helps us to use soong_build_go to build the requested binary.</li><li><strong>soong_build_go soong_ui </strong>prepares the shell function calls and executes <strong>the entrance of soong i.e. main.go</strong></li><li><strong>soong_build_go mk2rbc and rbcrun </strong>execute the entrance of <a href="https://bazel.build/">bazel</a> build system and converts different makefiles to <a href="https://bazel.build/rules/language">Starlark</a></li><li>finally executes <strong>soong_ui</strong></li></ol><blockquote>so from <strong>point 2</strong>, we understand that <strong>the entrance of soong i.e. main.go</strong></blockquote><blockquote><strong>please note : point 3</strong>, is out of scope of this article</blockquote><p>in main.go, one of the following 4 parameters must be taken:</p><ul><li><strong>— dumpvar-mode</strong></li><li><strong>— dumpvars-mode</strong></li><li><strong>— make-mode</strong></li><li><strong>— build-mode</strong></li></ul><p>The first two are not much used and are not used for building/making so we will skip these and discuss — make-mode and — build-mode below.</p><pre>func main() {<br> ...<br> if os.Args[1] == &quot; --dumpvar-mode&quot; {<br> dumpVar(buildCtx, config, os.Args[2:])<br> } else if os.Args[1] == &quot; --dumpvars-mode&quot; {<br> dumpVars(buildCtx, config, os.Args[2:])<br> } else {<br>   //build --make-mode and --build-mode<br>   if inList(&quot;clean&quot;, config.Arguments()) || inList(&quot;clobber&quot;, config.Arguments()) {<br>     clean(ctx, config)<br>     return<br>   }<br>   if inList(&quot;help&quot;, config.Arguments())) {<br>     help(ctx, config)<br>     return<br>   }<br>   ...<br> }<br>}</pre><p>There are several other parameters like <strong>clobber/clean</strong> and <strong>help </strong>which calls <strong><em>cleanbuild.go</em></strong> and <strong><em>help.sh</em></strong>. <strong>clobber/clean</strong> is to delete the output folder and <strong>help</strong> is used to display the user manual for command.</p><h4>Let’s deep dive into — — make — mode and — — build — mode below.</h4><p>This is the High-level flow for the build process, we will discuss every junction one by one now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L29u25KBuz8W1gC-fqV68g.png" /><figcaption>High level flow for the build process</figcaption></figure><p><strong>main.go</strong> sets up the config via <strong>config.go </strong>with passed parameters like skip etc. then FindSources function finds the sources to combine the mk files for <strong>kati.go</strong> and bp files for <strong>soong.go</strong> to process and convert to ninja files with the help of <strong>ninja.go</strong>. <strong>bp2build.go</strong> is only needed if bazel is enabled, then .bp files need to be converted to <a href="https://bazel.build/rules/lib/File">BAZEL</a> files. For this article, we <strong>assume that bazel is not enabled</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b235e2813efdb2f4cc89c6fac87346c2/href">https://medium.com/media/b235e2813efdb2f4cc89c6fac87346c2/href</a></iframe><p>Config will send the args to build.go’s to decide what to run and in which sequence. For example if we run the command like:</p><pre>build/soong/soong_ui.bash --make-mode --skip-ninja </pre><p>Config’s <strong>skipNinja</strong> will be true. And follow-on:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/85b1b21b8fe3109b3f76c7e97bbc58e7/href">https://medium.com/media/85b1b21b8fe3109b3f76c7e97bbc58e7/href</a></iframe><p>Once the config is set, in Build flow, the variable “<em>what</em>” by default is set to “<em>runAll</em>”</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1fc5a2440e56a7831682453f4600151b/href">https://medium.com/media/1fc5a2440e56a7831682453f4600151b/href</a></iframe><p>Once all the meta filters are complete, like skip Kati, skip Ninja, etc, the soong process will start.</p><h4>Soong’s Flow</h4><p>There is a tool called <strong>bootstrap</strong> that reads the Blueprint files that describe itself and emits <strong>.bootstrap/build.ninja</strong> that describes how to build its full version and use that to produce the final Ninja file that Soong emits.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5201de43f8a526d5ca58be36a37dd2eb/href">https://medium.com/media/5201de43f8a526d5ca58be36a37dd2eb/href</a></iframe><p>If <strong>Bp2Build</strong> is true which means that if <strong>Bazel</strong> build system is needed, <strong>bp2build.go</strong> needs to be executed. <strong>It writes .bzl files that are equivalent to Android.bp files</strong> that are capable of being built with Bazel.</p><blockquote>Google wants to hand over all compilation-related tasks to bazel. It’s a big project, and the Android code is too huge. I don’t know when it will be completed.</blockquote><p>from Android.bp, <strong>out/soong/build.ninja</strong> will be generated. After this, Kati is executed to parse the Makefiles, but that’s not part of bootstrapping Soong.</p><h3>Kati’s Flow</h3><p><strong>Android.mk loading</strong><br>in build.go runKati is executed. which calls the flow in the file (core/main.mk), including each subdirectory in the following way for Android.mk</p><pre>subdir_makefiles := $(SOONG_OUT_DIR)/installs-$(TARGET_PRODUCT).mk $(SOONG_ANDROID_MK)<br># Android.mk files are only used on Linux builds, Mac only supports Android.bp<br>ifeq ($(HOST_OS),linux)<br>  subdir_makefiles += $(file &lt;$(OUT_DIR)/.module_paths/Android.mk.list)<br>endif<br>subdir_makefiles += $(SOONG_OUT_DIR)/late-$(TARGET_PRODUCT).mk<br>subdir_makefiles_total := $(words int $(subdir_makefiles) post finish)<br>.KATI_READONLY := subdir_makefiles_total<br><br>$(foreach mk,$(subdir_makefiles),$(info [$(call inc_and_print,subdir_makefiles_inc)/$(subdir_makefiles_total)] including $(mk) ...)$(eval include $(mk)))</pre><p>Because of this logic, we can often see [<strong><em>xxx/xxx</em></strong>] including <strong><em>xxx</em></strong> at compile time. Search for files in the Android source code, Android.mk, and put the corresponding file path into the Android.mk.list file and then generate the ninja file for it. It uses ckati to do it.</p><p><strong>eg : command: <em>ckati, -f build/make/core/main.mk</em></strong></p><p>From Android.mk and other Makefiles, out/build-&lt;product_name&gt;.ninja files will be generated.</p><p>Let’s discuss what a generated ninja file looks like. Taking Example for SystemUI-core</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c10476e235cdda5fa24d977a3515b1d9/href">https://medium.com/media/c10476e235cdda5fa24d977a3515b1d9/href</a></iframe><p><strong>rule &lt;rule-name&gt;:</strong> a rule with &lt;<strong><em>rule-name&gt;</em></strong> can be defined for reuse with command</p><p><strong>m.&lt;module&gt;-&lt;variant&gt;-*: </strong>&lt;<strong><em>module</em></strong>&gt; and &lt;<strong><em>variant</em></strong>&gt; will be defined in Android.bp/Android.mk and <strong>*</strong> can be thought of as the different flags like javacFlags or kotlincFlags.</p><p><strong>build $ &lt;function&gt;: </strong>&lt;function&gt; is basically the commands for 1. conversion of XML files, Java files using aapt2 and Java Compiler to create .class files, and then 2. .class files to .dex files to create .apk finally.</p><p>It has other rules as well, to copy all the generated artifacts to the corresponding directories. The directory <strong>‘out/target/product/bluejay/&lt;</strong>obj<strong>&gt;’</strong> is used for staging “object” files, which are intermediate binary images used for building the final programs. Stuff that actually lands in the file system of the target is stored in the directories <strong>root, system, and data</strong>, under <strong>‘out/target/product/bluejay’</strong>. Usually, these are bundled up into image files called <strong>vbmeta.img, system.img, ramdisk.img, and userdata.img.</strong></p><p>Let me know if you want one more article, discussing the above flow of how different images get generated, apk’s gets signed and vbmeta.img is verified.</p><p>The making, packing, and zipping of these imgs is also part of ninja files that were generated by Kati.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3febe49fce2be8e36a6694925dd86bcb/href">https://medium.com/media/3febe49fce2be8e36a6694925dd86bcb/href</a></iframe><h3>Conclusion</h3><p>This article has been kept to a level where it is not only informative and useful but also dives into finer details. Hopefully, this has given you a decent learning of the Android platform build systems and AOSP in general.</p><p>As you might have observed, I have mentioned <a href="https://bazel.build/">Bazel Build System</a> 2–3 times in this article. It has started to gain traction, and will potentially be replacing the current build system.</p><p>I would love to talk more about <a href="https://bazel.build/">Bazel Build System</a> in another article as and when things unfold.</p><p>Do drop me a follow on <a href="https://www.linkedin.com/in/goyaljai/">LinkedIn</a>!!</p><p>Cheers !!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c98abb390d2d" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/android-open-source-platform-aosp-build-systems-c98abb390d2d">Android Open Source Platform (AOSP) Build Systems</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>