---
title: "R8 Optimization: Value Assumption"
url: https://daily.dev/posts/r8-optimization-value-assumption-ij3ww9tmx
source_url: https://jakewharton.com/r8-optimization-value-assumption
type: article
source: "Jake Wharton"
published: 2026-07-05T07:14:14.987Z
updated: 2026-07-05T07:18:56.485Z
tags: ["android"]
reading_time: 13
upvotes: 0
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# R8 Optimization: Value Assumption

**[Jake Wharton](https://daily.dev/sources/jakewharton)** · 13 min read · 0 upvotes · 0 comments

## Summary

R8's `-assumevalues` flag lets developers declare the expected value range of fields or method return values, enabling dead-code elimination of impossible branches. The most impactful use case is `Build.VERSION.SDK_INT` in Android: by specifying the minimum API level as the lower bound, R8 can strip out all compatibility code paths that will never execute on the app's minimum supported OS version. AndroidX 'core' alone has over 850 such SDK_INT checks, and eliminating unreachable branches reduces APK size and improves runtime performance. Starting with R8 1.4.22 (AGP 3.4 beta 1), this rule is automatically applied based on the `--min-api` flag, so developers get smaller APKs without manual configuration. The post also covers the distinction between `-assumevalues` and `-assumenosideeffects`, and why field reads are retained even after branch elimination.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://jakewharton.com/r8-optimization-value-assumption>

## Similar posts on daily.dev

- [Android Developers Blog: Configure and troubleshoot R8 Keep Rules](https://daily.dev/posts/android-developers-blog-configure-and-troubleshoot-r8-keep-rules-93owf7hzc) · Android Developers Blog · 1 upvotes · 0 comments
- [Android Developers Blog: Use R8 to shrink, optimize, and fast-track your app](https://daily.dev/posts/android-developers-blog-use-r8-to-shrink-optimize-and-fast-track-your-app-phr0xzn6m) · Android Developers Blog · 0 upvotes · 0 comments

---

Tags: [#android](https://daily.dev/tags/android)

[View this post on daily.dev](https://daily.dev/posts/r8-optimization-value-assumption-ij3ww9tmx)
