[{"data":1,"prerenderedAt":165},["ShallowReactive",2],{"public-settings":3,"post-android-performance-baseline-profiles":15,"article-code-bsod7i":164},{"site_title":4,"tagline":5,"site_url":6,"footer_text":5,"social_twitter":7,"social_github":7,"social_youtube":7,"social_linkedin":7,"social_mastodon":7,"og_image":8,"comments_enabled":9,"ads_mode":10,"ads_publisher_id":7,"ads_adtest":11,"ads_in_article_enabled":9,"ads_in_article_slot":7,"ads_in_article_paragraph":12,"ads_end_of_post_enabled":9,"ads_end_of_post_slot":7,"ads_feed_enabled":9,"ads_feed_slot":7,"ads_feed_every":13,"ads_sidebar_enabled":9,"ads_sidebar_slot":7,"ads_consent_enabled":11,"seo_enabled":9,"llms_enabled":9,"verification_google":7,"verification_bing":7,"performance_lcp_preload":9,"pwa_enabled":9,"bookmarks_enabled":9,"comments_moderation":9,"home_carousel_featured":9,"home_carousel_latest":9,"home_carousel_latest_mode":14,"home_carousel_series":9,"home_carousel_topics":9},"Android Learner","Practical Android development, explained clearly.","https:\u002F\u002Fwww.androidlearner.com","","\u002Fmedia\u002Fseed\u002Fcover-llm.webp","1","demo","0","2","3","latest",{"post":16,"comments":145},{"id":17,"title":18,"slug":19,"path":20,"excerpt":21,"cover_image":22,"cover_media_id":23,"status":24,"publish_at":25,"reading_time":23,"seo_title":26,"seo_description":21,"og_image":22,"canonical_url":27,"noindex":28,"featured":28,"faq":29,"howto":30,"review_note":30,"submitted_at":30,"reviewed_at":30,"category":31,"series":30,"tags":35,"author":42,"created_at":47,"updated_at":48,"body_md":49,"body_html":50,"related":51},5,"Android app performance with Baseline Profiles","android-performance-baseline-profiles","\u002Fposts\u002Fandroid-performance-baseline-profiles","Ship a Baseline Profile, measure cold start with Macrobenchmark, and let ART ahead-of-time compile the journeys your users actually take.","\u002Fmedia\u002Fseed\u002Fcover-baseline.webp",3,"published","2026-11-06 03:14:13","Android performance: Baseline Profiles and Macrobenchmark","https:\u002F\u002Fwww.androidlearner.com\u002Fposts\u002Fandroid-performance-baseline-profiles",false,[],null,{"id":17,"name":32,"slug":33,"description":34},"Performance","performance","Startup, frames, and profiles.",[36,40],{"id":37,"name":38,"slug":39,"description":30},11,"Baseline Profiles","baseline-profiles",{"id":41,"name":32,"slug":33,"description":30},12,{"id":43,"name":44,"username":45,"avatar":30,"profile_path":46},1,"Super Admin","superadmin","\u002Fu\u002Fsuperadmin","2026-11-20 05:18:17","2026-11-22 03:14:13","The fastest Android performance win that is still under-used is a **Baseline Profile**. It tells Cloud Profile (Play \u002F ART) which methods and classes your app actually uses on a cold start or a critical user journey, so ART can ahead-of-time compile them instead of interpreting or JIT-ing them on the first run.\n\nThis is not a micro-benchmark of a tight loop. It is a way to make first frames and first navigations feel like a second-session app.\n\n## What a Baseline Profile is\n\nA Baseline Profile is a human-readable list of methods and classes, shipped in the APK or AAB as `baseline-prof.txt` (and compiled into `baseline.prof`). On install or first use, ART uses it to pre-compile those methods. Android 7 and later can use profiles; the modern toolchain (AGP, Jetpack `baselineprofile`, Macrobenchmark) is what you want on current apps.\n\nGoogle's documented results are typically in the **10–30%** range for startup and frame timing on first runs, depending on the app. Treat those as a reason to measure *your* app, not as a guarantee.\n\n## The two modules you add\n\nThe current Jetpack recommendation is a **Macrobenchmark** module plus a **Baseline Profile** generator module that exercises the same journeys.\n\n```kotlin\n\u002F\u002F baselineprofile\u002Fbuild.gradle.kts (simplified)\nplugins {\n    id(\"com.android.test\")\n    id(\"androidx.baselineprofile\")\n}\n\nandroid {\n    defaultConfig {\n        minSdk = 28\n    }\n    targetProjectPath = \":app\"\n}\n\ndependencies {\n    implementation(\"androidx.benchmark:benchmark-macro-junit4:1.3.3\")\n    implementation(\"androidx.test.uiautomator:uiautomator:2.3.0\")\n}\n```\n\nThe generator test looks like a UI Automator script:\n\n```kotlin\n@RunWith(AndroidJUnit4::class)\nclass BaselineProfileGenerator {\n    @get:Rule\n    val rule = BaselineProfileRule()\n\n    @Test\n    fun startupAndOpenArticle() {\n        rule.collect(packageName = \"com.example.androidlearner\") {\n            startActivityAndWait()\n            device.findObject(By.text(\"Compose\")).click()\n            device.wait(Until.hasObject(By.res(\"article-body\")), 5_000)\n        }\n    }\n}\n```\n\n`BaselineProfileRule.collect` starts the app, runs your block, and records the classes and methods that were loaded. Keep the journey honest: cold start, then the two or three screens a new user actually opens. Do not click every debug menu you have.\n\n## Measure first, then claim a win\n\nA profile you never measure is a hope. Use Macrobenchmark's `StartupTimingMetric` and `FrameTimingMetric`:\n\n```kotlin\n@RunWith(AndroidJUnit4::class)\nclass ColdStartBenchmark {\n    @get:Rule\n    val benchmark = MacrobenchmarkRule()\n\n    @Test\n    fun coldStartup() {\n        benchmark.measureRepeated(\n            packageName = \"com.example.androidlearner\",\n            metrics = listOf(StartupTimingMetric()),\n            iterations = 8,\n            startupMode = StartupMode.COLD,\n            compilationMode = CompilationMode.Partial(\n                baselineProfileMode = BaselineProfileMode.Require,\n            ),\n        ) {\n            startActivityAndWait()\n        }\n    }\n}\n```\n\nRun the same test with `CompilationMode.None()` (or `CompilationMode.Ignore()` on newer libraries) as a control so you can see what the profile actually changed. Do this on a real device. Emulators will not give you numbers you can ship a blog post with.\n\n## Things people miss\n\n- **Ship the profile.** The `androidx.baselineprofile` Gradle plugin (and `BaselineProfileConsumer` on the app module in current AGP) packages the generated `baseline-prof.txt`. If it is not in the AAB, Play cannot use it.\n- **Keep journeys short and representative.** A 40-step generator that wanders into settings will bloat the profile and dilute the benefit for startup.\n- **R8 \u002F minification and the profile work together.** Baseline Profiles complement, they do not replace, shrinking and the usual startup hygiene (do less in `Application.onCreate()`, defer work, watch for disk I\u002FO on the main thread).\n- **Cloud Profiles still matter.** Play collects real-user profiles and can improve compilation further after install. Your Baseline Profile is the first-run safety net, not a replacement for that system.\n- **Compose and libraries.** If you use Compose, Navigation, and Hilt, include a journey that first-composes a typical screen. Those libraries are large; precompiling the path you actually use is most of the win.\n\n## A practical rollout\n\n1. Add a Macrobenchmark module and measure cold start as it is today.\n2. Add a Baseline Profile generator for startup plus one critical journey.\n3. Generate the profile on a pinned, representative device or in CI with a managed device.\n4. Re-run the benchmark with `CompilationMode.Partial` and keep the profile only if the metric moved in the right direction.\n5. Regenerate the profile when you change that journey significantly (a new home screen, a new login graph).\n\nBaseline Profiles are not a substitute for fixing a 400 ms main-thread database query. They *are* the cheapest way to make a well-behaved app feel compiled on the first launch. Measure, generate, ship, measure again.\n","\u003Cp>The fastest Android performance win that is still under-used is a \u003Cstrong>Baseline Profile\u003C\u002Fstrong>. It tells Cloud Profile (Play \u002F ART) which methods and classes your app actually uses on a cold start or a critical user journey, so ART can ahead-of-time compile them instead of interpreting or JIT-ing them on the first run.\u003C\u002Fp>\n\u003Cp>This is not a micro-benchmark of a tight loop. It is a way to make first frames and first navigations feel like a second-session app.\u003C\u002Fp>\n\u003Ch2 id=\"what-a-baseline-profile-is\">What a Baseline Profile is\u003C\u002Fh2>\n\u003Cp>A Baseline Profile is a human-readable list of methods and classes, shipped in the APK or AAB as \u003Ccode>baseline-prof.txt\u003C\u002Fcode> (and compiled into \u003Ccode>baseline.prof\u003C\u002Fcode>). On install or first use, ART uses it to pre-compile those methods. Android 7 and later can use profiles; the modern toolchain (AGP, Jetpack \u003Ccode>baselineprofile\u003C\u002Fcode>, Macrobenchmark) is what you want on current apps.\u003C\u002Fp>\n\u003Cp>Google's documented results are typically in the \u003Cstrong>10–30%\u003C\u002Fstrong> range for startup and frame timing on first runs, depending on the app. Treat those as a reason to measure \u003Cem>your\u003C\u002Fem> app, not as a guarantee.\u003C\u002Fp>\n\u003Ch2 id=\"the-two-modules-you-add\">The two modules you add\u003C\u002Fh2>\n\u003Cp>The current Jetpack recommendation is a \u003Cstrong>Macrobenchmark\u003C\u002Fstrong> module plus a \u003Cstrong>Baseline Profile\u003C\u002Fstrong> generator module that exercises the same journeys.\u003C\u002Fp>\n\u003Cpre class=\"code-block\" data-lang=\"kotlin\">\u003Ccode class=\"language-kotlin\">\u002F\u002F baselineprofile\u002Fbuild.gradle.kts (simplified)\nplugins {\n    id(&quot;com.android.test&quot;)\n    id(&quot;androidx.baselineprofile&quot;)\n}\n\nandroid {\n    defaultConfig {\n        minSdk = 28\n    }\n    targetProjectPath = &quot;:app&quot;\n}\n\ndependencies {\n    implementation(&quot;androidx.benchmark:benchmark-macro-junit4:1.3.3&quot;)\n    implementation(&quot;androidx.test.uiautomator:uiautomator:2.3.0&quot;)\n}\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>The generator test looks like a UI Automator script:\u003C\u002Fp>\n\u003Cpre class=\"code-block\" data-lang=\"kotlin\">\u003Ccode class=\"language-kotlin\">@RunWith(AndroidJUnit4::class)\nclass BaselineProfileGenerator {\n    @get:Rule\n    val rule = BaselineProfileRule()\n\n    @Test\n    fun startupAndOpenArticle() {\n        rule.collect(packageName = &quot;com.example.androidlearner&quot;) {\n            startActivityAndWait()\n            device.findObject(By.text(&quot;Compose&quot;)).click()\n            device.wait(Until.hasObject(By.res(&quot;article-body&quot;)), 5_000)\n        }\n    }\n}\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>\u003Ccode>BaselineProfileRule.collect\u003C\u002Fcode> starts the app, runs your block, and records the classes and methods that were loaded. Keep the journey honest: cold start, then the two or three screens a new user actually opens. Do not click every debug menu you have.\u003C\u002Fp>\n\u003Ch2 id=\"measure-first-then-claim-a-win\">Measure first, then claim a win\u003C\u002Fh2>\n\u003Cp>A profile you never measure is a hope. Use Macrobenchmark's \u003Ccode>StartupTimingMetric\u003C\u002Fcode> and \u003Ccode>FrameTimingMetric\u003C\u002Fcode>:\u003C\u002Fp>\n\u003Cpre class=\"code-block\" data-lang=\"kotlin\">\u003Ccode class=\"language-kotlin\">@RunWith(AndroidJUnit4::class)\nclass ColdStartBenchmark {\n    @get:Rule\n    val benchmark = MacrobenchmarkRule()\n\n    @Test\n    fun coldStartup() {\n        benchmark.measureRepeated(\n            packageName = &quot;com.example.androidlearner&quot;,\n            metrics = listOf(StartupTimingMetric()),\n            iterations = 8,\n            startupMode = StartupMode.COLD,\n            compilationMode = CompilationMode.Partial(\n                baselineProfileMode = BaselineProfileMode.Require,\n            ),\n        ) {\n            startActivityAndWait()\n        }\n    }\n}\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>Run the same test with \u003Ccode>CompilationMode.None()\u003C\u002Fcode> (or \u003Ccode>CompilationMode.Ignore()\u003C\u002Fcode> on newer libraries) as a control so you can see what the profile actually changed. Do this on a real device. Emulators will not give you numbers you can ship a blog post with.\u003C\u002Fp>\n\u003Ch2 id=\"things-people-miss\">Things people miss\u003C\u002Fh2>\n\u003Cul>\n\u003Cli>\u003Cstrong>Ship the profile.\u003C\u002Fstrong> The \u003Ccode>androidx.baselineprofile\u003C\u002Fcode> Gradle plugin (and \u003Ccode>BaselineProfileConsumer\u003C\u002Fcode> on the app module in current AGP) packages the generated \u003Ccode>baseline-prof.txt\u003C\u002Fcode>. If it is not in the AAB, Play cannot use it.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Keep journeys short and representative.\u003C\u002Fstrong> A 40-step generator that wanders into settings will bloat the profile and dilute the benefit for startup.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>R8 \u002F minification and the profile work together.\u003C\u002Fstrong> Baseline Profiles complement, they do not replace, shrinking and the usual startup hygiene (do less in \u003Ccode>Application.onCreate()\u003C\u002Fcode>, defer work, watch for disk I\u002FO on the main thread).\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Cloud Profiles still matter.\u003C\u002Fstrong> Play collects real-user profiles and can improve compilation further after install. Your Baseline Profile is the first-run safety net, not a replacement for that system.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Compose and libraries.\u003C\u002Fstrong> If you use Compose, Navigation, and Hilt, include a journey that first-composes a typical screen. Those libraries are large; precompiling the path you actually use is most of the win.\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Ch2 id=\"a-practical-rollout\">A practical rollout\u003C\u002Fh2>\n\u003Col>\n\u003Cli>Add a Macrobenchmark module and measure cold start as it is today.\u003C\u002Fli>\n\u003Cli>Add a Baseline Profile generator for startup plus one critical journey.\u003C\u002Fli>\n\u003Cli>Generate the profile on a pinned, representative device or in CI with a managed device.\u003C\u002Fli>\n\u003Cli>Re-run the benchmark with \u003Ccode>CompilationMode.Partial\u003C\u002Fcode> and keep the profile only if the metric moved in the right direction.\u003C\u002Fli>\n\u003Cli>Regenerate the profile when you change that journey significantly (a new home screen, a new login graph).\u003C\u002Fli>\n\u003C\u002Fol>\n\u003Cp>Baseline Profiles are not a substitute for fixing a 400 ms main-thread database query. They \u003Cem>are\u003C\u002Fem> the cheapest way to make a well-behaved app feel compiled on the first launch. Measure, generate, ship, measure again.\u003C\u002Fp>\n",[52,90,117],{"id":53,"title":54,"slug":55,"path":56,"excerpt":57,"cover_image":58,"cover_media_id":59,"status":24,"publish_at":60,"reading_time":61,"seo_title":62,"seo_description":63,"og_image":58,"canonical_url":64,"noindex":28,"featured":28,"faq":65,"howto":30,"review_note":30,"submitted_at":30,"reviewed_at":30,"category":72,"series":30,"tags":73,"author":87,"created_at":88,"updated_at":89},22,"Google Play's 16 KB Page Size Rule: What to Fix Before 1 February 2027","android-16kb-page-size-google-play-deadline","\u002Fposts\u002Fandroid-16kb-page-size-google-play-deadline","Apps that target API 35+ and ship native code must support 16 KB pages before 1 February 2027 or Play will block updates. Pure Kotlin and Java apps are already compatible.","\u002Fmedia\u002F2026\u002F11\u002F723c07ce07ee95c5.webp",62,"2026-11-25 02:00:00",8,"Android 16 KB page size: Play deadline 1 February 2027","If your app targets API 35+ and ships native code, Google Play will block updates after 1 February 2027 unless you support 16 KB pages. How to check, rebuild, and test.","https:\u002F\u002Fwww.androidlearner.com\u002Fposts\u002Fandroid-16kb-page-size-google-play-deadline",[66,69],{"question":67,"answer":68},"Does a pure Kotlin or Java app need a native rebuild?","No. Android Developers say that if the app and all of its libraries are written only in Java or Kotlin, it already supports 16 KB devices. They still recommend testing on a 16 KB emulator image.",{"question":70,"answer":71},"Will Google remove my app from Play on 1 February 2027 if I miss the deadline?","The official compatibility section says you will not be able to release updates that do not support 16 KB pages. It does not say existing listings are removed. Check Play Console for the wording on your own app, and re-read the page-sizes guide for the current date.",{"id":17,"name":32,"slug":33,"description":34},[74,78,82,86],{"id":75,"name":76,"slug":77,"description":30},28,"Android","android",{"id":79,"name":80,"slug":81,"description":30},49,"Google Play","google-play",{"id":83,"name":84,"slug":85,"description":30},50,"NDK","ndk",{"id":41,"name":32,"slug":33,"description":30},{"id":43,"name":44,"username":45,"avatar":30,"profile_path":46},"2026-11-24 19:51:51","2026-11-24 19:53:15",{"id":91,"title":92,"slug":93,"path":94,"excerpt":95,"cover_image":96,"cover_media_id":97,"status":24,"publish_at":98,"reading_time":17,"seo_title":99,"seo_description":100,"og_image":96,"canonical_url":101,"noindex":28,"featured":28,"faq":102,"howto":30,"review_note":30,"submitted_at":30,"reviewed_at":30,"category":103,"series":30,"tags":104,"author":115,"created_at":116,"updated_at":116},15,"WebGPU on Android: Jetpack Bindings for Games and Compute","webgpu-on-android-games-and-compute","\u002Fposts\u002Fwebgpu-on-android-games-and-compute","Android 17 adds WebGPU bindings over Vulkan. The current Jetpack artifact is androidx.webgpu:webgpu:1.0.0-alpha06 (7 October 2026), and the minimum SDK is now API 26.","\u002Fmedia\u002F2026\u002F11\u002Fb2625633ecdb1014.webp",47,"2026-11-24 04:30:00","WebGPU on Android with Jetpack androidx.webgpu","A fact-checked guide to WebGPU on Android 17: the alpha06 Jetpack library, the API 26 minimum, Vulkan 1.1, and what Google says this API is — and is not.","https:\u002F\u002Fwww.androidlearner.com\u002Fposts\u002Fwebgpu-on-android-games-and-compute",[],{"id":17,"name":32,"slug":33,"description":34},[105,106,110,111],{"id":75,"name":76,"slug":77,"description":30},{"id":107,"name":108,"slug":109,"description":30},38,"Graphics","graphics",{"id":41,"name":32,"slug":33,"description":30},{"id":112,"name":113,"slug":114,"description":30},37,"WebGPU","webgpu",{"id":43,"name":44,"username":45,"avatar":30,"profile_path":46},"2026-11-24 06:24:51",{"id":118,"title":119,"slug":120,"path":121,"excerpt":122,"cover_image":123,"cover_media_id":124,"status":24,"publish_at":125,"reading_time":126,"seo_title":127,"seo_description":128,"og_image":123,"canonical_url":129,"noindex":28,"featured":28,"faq":130,"howto":30,"review_note":30,"submitted_at":30,"reviewed_at":30,"category":131,"series":30,"tags":132,"author":143,"created_at":144,"updated_at":144},14,"Android 17 Memory Limits, App Budgets, and the NPU Feature Flag","android-17-memory-limits-npu-qpr3","\u002Fposts\u002Fandroid-17-memory-limits-npu-qpr3","Don’t confuse Android 17’s platform Memory Limiter with optional app memory budgets in QPR2. This guide separates both, plus the NPU feature flag and QPR3 Beta 4.","\u002Fmedia\u002F2026\u002F11\u002F5509a93a7fd693d2.webp",43,"2026-11-24 04:00:00",7,"Android 17 memory limits vs app memory budgets (QPR2)","Platform Memory Limiter, optional QPR2 app memory budgets (docs updated 21 November 2026), the NPU feature flag, and what QPR3 Beta 4 means for testers.","https:\u002F\u002Fwww.androidlearner.com\u002Fposts\u002Fandroid-17-memory-limits-npu-qpr3",[],{"id":17,"name":32,"slug":33,"description":34},[133,134,138,142],{"id":75,"name":76,"slug":77,"description":30},{"id":135,"name":136,"slug":137,"description":30},35,"Android 17","android-17",{"id":139,"name":140,"slug":141,"description":30},36,"Memory","memory",{"id":41,"name":32,"slug":33,"description":30},{"id":43,"name":44,"username":45,"avatar":30,"profile_path":46},"2026-11-24 06:24:50",[146,158],{"id":147,"parent_id":30,"author_name":148,"body":149,"created_at":150,"replies":151},93,"Grace Park","We added a Baseline Profile last month and cold start dropped about 22% on a low-end Samsung. The Macrobenchmark setup was the painful part, not the profile itself.","2026-11-18 21:14:13",[152],{"id":153,"parent_id":147,"author_name":154,"body":155,"created_at":156,"replies":157},94,"Theo Muller","Tip: generate the profile on a user-build close to production. I wasted a day capturing one on a debug build that did not match the traces.","2026-11-19 09:14:13",[],{"id":159,"parent_id":30,"author_name":160,"body":161,"created_at":162,"replies":163},95,"Sofia Ramos","The startup journey in the post matches what Android Studio’s App Startup profiler showed us — especially the ContentProvider cost.","2026-11-21 05:14:13",[],"\u003Cp>The fastest Android performance win that is still under-used is a \u003Cstrong>Baseline Profile\u003C\u002Fstrong>. It tells Cloud Profile (Play \u002F ART) which methods and classes your app actually uses on a cold start or a critical user journey, so ART can ahead-of-time compile them instead of interpreting or JIT-ing them on the first run.\u003C\u002Fp>\n\u003Cp>This is not a micro-benchmark of a tight loop. It is a way to make first frames and first navigations feel like a second-session app.\u003C\u002Fp>\n\u003Ch2 id=\"what-a-baseline-profile-is\">What a Baseline Profile is\u003C\u002Fh2>\n\u003Cp>A Baseline Profile is a human-readable list of methods and classes, shipped in the APK or AAB as \u003Ccode>baseline-prof.txt\u003C\u002Fcode> (and compiled into \u003Ccode>baseline.prof\u003C\u002Fcode>). On install or first use, ART uses it to pre-compile those methods. Android 7 and later can use profiles; the modern toolchain (AGP, Jetpack \u003Ccode>baselineprofile\u003C\u002Fcode>, Macrobenchmark) is what you want on current apps.\u003C\u002Fp>\n\u003Cp>Google's documented results are typically in the \u003Cstrong>10–30%\u003C\u002Fstrong> range for startup and frame timing on first runs, depending on the app. Treat those as a reason to measure \u003Cem>your\u003C\u002Fem> app, not as a guarantee.\u003C\u002Fp>\n\u003Ch2 id=\"the-two-modules-you-add\">The two modules you add\u003C\u002Fh2>\n\u003Cp>The current Jetpack recommendation is a \u003Cstrong>Macrobenchmark\u003C\u002Fstrong> module plus a \u003Cstrong>Baseline Profile\u003C\u002Fstrong> generator module that exercises the same journeys.\u003C\u002Fp>\n\u003Cdiv class=\"code-block\" data-lang=\"kotlin\">\u003Cdiv class=\"code-block__header\">\u003Cspan class=\"code-block__lang\">kotlin\u003C\u002Fspan>\u003Cbutton type=\"button\" class=\"code-block__copy\" aria-label=\"Copy code\">Copy\u003C\u002Fbutton>\u003C\u002Fdiv>\u003Cdiv class=\"code-block__body\">\u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"color:#6A737D\">\u002F\u002F baselineprofile\u002Fbuild.gradle.kts (simplified)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">plugins\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">    id\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"com.android.test\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">    id\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"androidx.baselineprofile\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">}\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">android\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">    defaultConfig\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        minSdk \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 28\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    targetProjectPath \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> \":app\"\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">}\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">dependencies\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">    implementation\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"androidx.benchmark:benchmark-macro-junit4:1.3.3\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">    implementation\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"androidx.test.uiautomator:uiautomator:2.3.0\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">}\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\u003C\u002Fdiv>\u003C\u002Fdiv>\n\u003Cp>The generator test looks like a UI Automator script:\u003C\u002Fp>\n\u003Cdiv class=\"code-block\" data-lang=\"kotlin\">\u003Cdiv class=\"code-block__header\">\u003Cspan class=\"code-block__lang\">kotlin\u003C\u002Fspan>\u003Cbutton type=\"button\" class=\"code-block__copy\" aria-label=\"Copy code\">Copy\u003C\u002Fbutton>\u003C\u002Fdiv>\u003Cdiv class=\"code-block__body\">\u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">@RunWith\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(AndroidJUnit4::\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">class\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">class\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> BaselineProfileGenerator\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">    @get\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">:\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">Rule\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    val\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> rule \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> BaselineProfileRule\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">()\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">    @Test\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    fun\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> startupAndOpenArticle\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">() {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        rule.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">collect\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(packageName \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> \"com.example.androidlearner\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">            startActivityAndWait\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">()\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">            device.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">findObject\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(By.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">text\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"Compose\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">)).\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">click\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">()\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">            device.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">wait\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(Until.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">hasObject\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(By.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">res\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"article-body\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">)), \u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">5_000\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">}\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\u003C\u002Fdiv>\u003C\u002Fdiv>\n\u003Cp>\u003Ccode>BaselineProfileRule.collect\u003C\u002Fcode> starts the app, runs your block, and records the classes and methods that were loaded. Keep the journey honest: cold start, then the two or three screens a new user actually opens. Do not click every debug menu you have.\u003C\u002Fp>\n\u003Ch2 id=\"measure-first-then-claim-a-win\">Measure first, then claim a win\u003C\u002Fh2>\n\u003Cp>A profile you never measure is a hope. Use Macrobenchmark's \u003Ccode>StartupTimingMetric\u003C\u002Fcode> and \u003Ccode>FrameTimingMetric\u003C\u002Fcode>:\u003C\u002Fp>\n\u003Cdiv class=\"code-block\" data-lang=\"kotlin\">\u003Cdiv class=\"code-block__header\">\u003Cspan class=\"code-block__lang\">kotlin\u003C\u002Fspan>\u003Cbutton type=\"button\" class=\"code-block__copy\" aria-label=\"Copy code\">Copy\u003C\u002Fbutton>\u003C\u002Fdiv>\u003Cdiv class=\"code-block__body\">\u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">@RunWith\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(AndroidJUnit4::\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">class\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">class\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> ColdStartBenchmark\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">    @get\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">:\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">Rule\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    val\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> benchmark \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> MacrobenchmarkRule\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">()\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">    @Test\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    fun\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> coldStartup\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">() {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        benchmark.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">measureRepeated\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">            packageName \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\"> \"com.example.androidlearner\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">            metrics \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> listOf\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">StartupTimingMetric\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">()),\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">            iterations \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 8\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">            startupMode \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> StartupMode.COLD,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">            compilationMode \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> CompilationMode.\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\">Partial\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">                baselineProfileMode \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> BaselineProfileMode.Require,\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">            ),\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        ) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#B392F0\">            startActivityAndWait\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">()\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">}\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\u003C\u002Fdiv>\u003C\u002Fdiv>\n\u003Cp>Run the same test with \u003Ccode>CompilationMode.None()\u003C\u002Fcode> (or \u003Ccode>CompilationMode.Ignore()\u003C\u002Fcode> on newer libraries) as a control so you can see what the profile actually changed. Do this on a real device. Emulators will not give you numbers you can ship a blog post with.\u003C\u002Fp>\n\u003Ch2 id=\"things-people-miss\">Things people miss\u003C\u002Fh2>\n\u003Cul>\n\u003Cli>\u003Cstrong>Ship the profile.\u003C\u002Fstrong> The \u003Ccode>androidx.baselineprofile\u003C\u002Fcode> Gradle plugin (and \u003Ccode>BaselineProfileConsumer\u003C\u002Fcode> on the app module in current AGP) packages the generated \u003Ccode>baseline-prof.txt\u003C\u002Fcode>. If it is not in the AAB, Play cannot use it.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Keep journeys short and representative.\u003C\u002Fstrong> A 40-step generator that wanders into settings will bloat the profile and dilute the benefit for startup.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>R8 \u002F minification and the profile work together.\u003C\u002Fstrong> Baseline Profiles complement, they do not replace, shrinking and the usual startup hygiene (do less in \u003Ccode>Application.onCreate()\u003C\u002Fcode>, defer work, watch for disk I\u002FO on the main thread).\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Cloud Profiles still matter.\u003C\u002Fstrong> Play collects real-user profiles and can improve compilation further after install. Your Baseline Profile is the first-run safety net, not a replacement for that system.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Compose and libraries.\u003C\u002Fstrong> If you use Compose, Navigation, and Hilt, include a journey that first-composes a typical screen. Those libraries are large; precompiling the path you actually use is most of the win.\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Ch2 id=\"a-practical-rollout\">A practical rollout\u003C\u002Fh2>\n\u003Col>\n\u003Cli>Add a Macrobenchmark module and measure cold start as it is today.\u003C\u002Fli>\n\u003Cli>Add a Baseline Profile generator for startup plus one critical journey.\u003C\u002Fli>\n\u003Cli>Generate the profile on a pinned, representative device or in CI with a managed device.\u003C\u002Fli>\n\u003Cli>Re-run the benchmark with \u003Ccode>CompilationMode.Partial\u003C\u002Fcode> and keep the profile only if the metric moved in the right direction.\u003C\u002Fli>\n\u003Cli>Regenerate the profile when you change that journey significantly (a new home screen, a new login graph).\u003C\u002Fli>\n\u003C\u002Fol>\n\u003Cp>Baseline Profiles are not a substitute for fixing a 400 ms main-thread database query. They \u003Cem>are\u003C\u002Fem> the cheapest way to make a well-behaved app feel compiled on the first launch. Measure, generate, ship, measure again.\u003C\u002Fp>\n",1795550404301]