startup https://theinshotproapk.com/category/app/startup/ Download InShot Pro APK for Android, iOS, and PC Sun, 23 Nov 2025 12:00:37 +0000 en-US hourly 1 https://theinshotproapk.com/wp-content/uploads/2021/07/cropped-Inshot-Pro-APK-Logo-1-32x32.png startup https://theinshotproapk.com/category/app/startup/ 32 32 Get your app on the fast track with Android Performance Spotlight Week! https://theinshotproapk.com/get-your-app-on-the-fast-track-with-android-performance-spotlight-week/ Sun, 23 Nov 2025 12:00:37 +0000 https://theinshotproapk.com/get-your-app-on-the-fast-track-with-android-performance-spotlight-week/ Posted by Ben Weiss – Senior Developer Relations Engineer, Performance Paladin When working on new features, app performance often takes ...

Read more

The post Get your app on the fast track with Android Performance Spotlight Week! appeared first on InShot Pro.

]]>

Posted by Ben Weiss – Senior Developer Relations Engineer, Performance Paladin

When working on new features, app performance often takes a back seat. However, while it’s not always top of mind for developers, users can see exactly where your app’s performance lags behind. When that new feature takes a long time to load or is slow to render, your users can become frustrated. And unhappy users are more likely to abandon the feature you spent so much time on.

App performance is a core part of user experience and app quality, and recent studies and research shows that it’s highly correlated with increased user satisfaction, higher retention, and better review scores.

And we’re here to help… Welcome to Android Performance Spotlight Week! All week long, we’re providing you with low-effort, high-impact tools and guidance to get your app on the fast track to better performance. We help you lay the foundation and then dive deeper into helping your app become a better version of itself.

The R8 optimizer and Profile Guided Optimizations are foundational tools to improve overall app performance. And that’s why we just released significant improvements to Android Studio tooling for performance and with the Android Gradle Plugin 9.0 we’re introducing new APIs to make it easier for you to do the right thing when configuring the R8 Android app optimizer. Jetpack Compose version 1.10, which is now in beta, ships with several features that improve app rendering performance. In addition to these updates, we’re bringing you a refresher on improving app health and performance monitoring. Some of our partners are going to tell their performance improvement stories as well.


Stay tuned to the blog all week as we’ll be updating this post with a digest of all the content released. We’re excited to share these updates and help you improve your app’s performance.

Here’s a closer look at what we’ll be covering:

Monday: Deliberate performance optimization with R8

November 17, 2025

We’re kicking off with a deep dive into the R8 optimizer. It’s not just about shrinking your app’s size, it’s about gaining a fundamental understanding of how the R8 optimizer can improve performance in your app and why you should use it right away. We just published the largest overhaul of new technical guidance to date. The guides cover how to enable, configure and troubleshoot the R8 optimizer. On Monday you’ll also see case studies from top partners showing the real-world gains they achieved.



Read the blog post and developer guide.

Tuesday: Debugging and troubleshooting R8

November 18, 2025

We tackle the “Why does my app crash after enabling R8?” question head-on. We know advanced optimization can sometimes reveal edge cases, so we’re focusing on debugging and troubleshooting R8 related issues. We’ll show you how to use new features in Android Studio to de-obfuscate stack traces, identify common configuration problems, and implement best practices to get the most out of R8. We want you to feel confident, not just hopeful, when you flip the switch.



Read the blog post and developer guide on testing and troubleshooting R8.

Wednesday: Deeper performance considerations

November 19, 2025

Mid-week, we explore high-impact performance offerings beyond the R8 optimizer. We’ll show you how to supercharge your app’s startup and interactions using Profile Guided Optimization with Baseline Profiles and Startup Profiles. They are ready and proven to deliver another massive boost. We also have exciting news on Jetpack Compose rendering performance improvements. Plus, we’ll share how to optimize your app’s health by managing background work effectively.

Read the blog post.

Thursday: Measure and improve

November 20, 2025

It’s not an improvement if you can’t prove it. Thursday is dedicated to performance measurement. We’ll share our complete guide, starting from local measurement and debugging with tools like Jetpack Macrobenchmark and the new UiAutomator API to capture jank and startup times, all the way to monitoring your app in the wild. You’ll learn about Play Vitals and other new APIs to understand your real user performance and quantify your success.

Read the blog post.

Friday: Ask Android Live

November 21, 2025

We cap off the week with an in-depth, live conversation. This is your chance to talk directly with the engineers and Developer Relations team who build and use these tools every day. We’ll have a panel of experts from the R8 and other performance teams ready to answer your toughest questions live. Get your questions ready!

Content coming on November 21, 2025

Get notified when we go live on YouTube



📣 Take the Performance Challenge!

We’re not just sharing guidance. We’re challenging you to put it into action!

Here’s our challenge for you this week: Enable R8 full mode for your app.

  1. Follow our developer guides to get started: Enable app optimization.

  2. Then, measure the impact. Don’t just feel the difference, verify it. Measure your performance gains by using or adapting the code from our Macrobenchmark sample app on GitHub to measure your startup times before and after.

We’re confident you’ll see a meaningful improvement in your app’s performance.

While you’re at it, use the social tags #AskAndroid to bring your questions. Throughout the week our experts are monitoring and answering your questions.


The post Get your app on the fast track with Android Performance Spotlight Week! appeared first on InShot Pro.

]]>
Deeper Performance Considerations https://theinshotproapk.com/deeper-performance-considerations/ Fri, 21 Nov 2025 12:04:53 +0000 https://theinshotproapk.com/deeper-performance-considerations/ Posted by Ben Weiss – Senior Developer Relations Engineer, Breana Tate – Developer Relations Engineer, Jossi Wolf – Software Engineer ...

Read more

The post Deeper Performance Considerations appeared first on InShot Pro.

]]>

Posted by Ben Weiss – Senior Developer Relations Engineer,
Breana Tate – Developer Relations Engineer,
Jossi Wolf – Software Engineer on Compose

Compose
yourselves and let us guide you through more background on performance.

Welcome
to day 3 of Performance Spotlight Week. Today we’re continuing to share details and guidance on
important
areas of app performance. We’re covering Profile Guided Optimization, Jetpack Compose
performance
improvements and considerations on working behind the scenes. Let’s dive right in.

Profile
Guided Optimization

Baseline
Profiles

and
Startup
Profiles

are foundational to improve an Android app’s startup and runtime performance. They are part of a
group of
performance optimizations called Profile Guided Optimization.

When
an app is packaged, the d8 dexer takes classes and methods and populates your app’s
classes.dex
files. When a user opens the app, these dex files are loaded, one after the other until the app
can start.
By providing a
Startup
Profile

you let d8 know which classes and methods to pack in the first
classes.dex
files. This structure allows the app to load fewer files, which in turn improves startup
speed.

Baseline
Profiles effectively move the Just in Time (JIT) compilation steps away from user devices and
onto developer
machines. The generated Ahead Of Time (AOT) compiled code has proven to reduce startup time and
rendering
issues alike.

Trello
and Baseline Profiles

We
asked engineers on the Trello app how Baseline Profiles affected their app’s performance. After
applying
Baseline Profiles to their main user journey, Trello saw a significant 25 % reduction in app
startup
time.

Trello
was able to improve their app’s startup time by 25 % by using baseline
profiles.

Baseline
Profiles at Meta

Also,
engineers at Meta recently published an article on how they are
accelerating
their Android apps with Baseline Profiles
.

Across
Meta’s apps the teams have seen various critical metrics improve by up to 40 % after
applying Baseline
Profiles.


Technical
improvements like these help you improve user satisfaction and business success as well. Sharing
this with
your product owners, CTOs and decision makers can also help speed up your app’s
performance.

Get
started with Baseline Profiles

To
generate either a Baseline or Startup Profile, you write a
macrobenchmark
test that exercises the app. During the test profile data is collected which will be used during
app
compilation. The tests are written using the new
UiAutomator
API
,
which we’ll cover tomorrow.

Writing
a benchmark like this is straightforward and you can see the full sample on
GitHub.

@Test

fun profileGenerator() {

    rule.collect(

        packageName = TARGET_PACKAGE,

        maxIterations = 15,

        stableIterations = 3,

        includeInStartupProfile = true

    ) {

        uiAutomator {

            startApp(TARGET_PACKAGE)

        }

    }

}

Considerations

Start
by writing a macrobenchmark tests Baseline Profile and a Startup Profile for the path most
traveled by your
users. This means the main entry point that your users take into your app which usually is
after
they logged in
.
Then continue to write more test cases to capture a more complete picture only for Baseline
Profiles. You do
not need to cover everything with a Baseline Profile. Stick to the most used paths and measure
performance
in the field. More on that in tomorrow’s post.

Get
started with Profile Guided Optimization

To
learn how Baseline Profiles work under the hood, watch this video from the Android Developers
Summit:




And
check out the Android Build Time episode on Profile Guided Optimization for another in-depth
look: 




We
also have extensive guidance on
Baseline
Profiles

and
Startup
Profiles

available for further reading.

Jetpack
Compose performance improvements

The
UI framework for Android has seen the performance investment of the engineering team pay off.
From version
1.9 of Jetpack Compose, scroll jank has dropped to 0.2 % during an internal long scrolling
benchmark
test. 

These
improvements were made possible because of several features packed into the most recent
releases.

Customizable
cache window

By
default, lazy layouts only compose one item ahead of time in the direction of scrolling, and
after something
scrolls off screen it is discarded. You can now customize the amount of items to retain through
a fraction
of the viewport or dp size. This helps your app perform more work upfront, and after enabling
pausable
composition in between frames, using the available time more efficiently.

To
start using customizable cache windows, instantiate a
LazyLayoutCacheWindow
and pass it to your lazy list or lazy grid. Measure your app’s performance using different cache
window
sizes, for example 50% of the viewport. The optimal value will depend on your content’s
structure and item
size.

val
dpCacheWindow = LazyLayoutCacheWindow(ahead =
150.dp,
behind =
100.dp)

val
state = rememberLazyListState(cacheWindow = dpCacheWindow)

LazyColumn(state
= state) {

    //
column contents

}

Pausable
composition

This
feature allows compositions to be paused, and their work split up over several frames. The APIs
landed in
1.9 and it is now used by default in 1.10 in lazy layout prefetch. You should see the most
benefit with
complex items with longer composition times. 


More
Compose performance optimizations

In
the versions 1.9 and 1.10 of Compose the team also made several optimizations that are a bit
less
obvious.

Several
APIs that use coroutines under the hood have been improved. For example, when using
Draggable
and
Clickable,
developers should see faster reaction times and improved allocation counts.

Optimizations
in layout rectangle tracking have improved performance of Modifiers like
onVisibilityChanged()
and
onLayoutRectChanged().
This speeds up the layout phase, even when not explicitly using these APIs.

Another
performance improvement is using cached values when observing positions via
onPlaced().

Prefetch
text in the background

Starting
with version 1.9, Compose adds the ability to prefetch text on a background thread. This enables
you to
pre-warm caches to enable faster text layout and is relevant for app rendering performance.
During layout,
text has to be passed into the Android framework where a word cache is populated. By default
this runs on
the Ui thread. Offloading prefetching and populating the word cache onto a background thread can
speed up
layout, especially for longer texts. To prefetch on a background thread you can pass a custom
executor to
any composable that’s using
BasicText
under the hood by passing a
LocalBackgroundTextMeasurementExecutor
to a
CompositionLocalProvider
like so.

val defaultTextMeasurementExecutor = Executors.newSingleThreadExecutor()

CompositionLocalProvider(

    LocalBackgroundTextMeasurementExecutor provides DefaultTextMeasurementExecutor

) {

    BasicText(“Some text that should be measured on a background thread!”)

}

Depending
on the text, this can provide a performance boost to your text rendering. To make sure that it
improves your
app’s rendering performance, benchmark and compare the results.

Background
work performance considerations

Background
Work is an essential part of many apps. You may be using libraries like WorkManager or
JobScheduler to
perform tasks like:

  • Periodically
    uploading analytical events

  • Syncing
    data between a backend service and a database

  • Processing
    media (i.e. resizing or compressing images)

A
key challenge while executing these tasks is balancing performance and power efficiency.
WorkManager allows
you to achieve this balance. It’s designed to be power-efficient, and allow work to be deferred
to an
optimal execution window influenced by a number of factors, including constraints you specify or
constraints
imposed by the system. 

WorkManager
is not a one-size-fits-all solution, though. Android also has a number of power-optimized APIs
that are
designed specifically with certain common Core User Journeys (CUJs) in
mind.  

Reference
the
Background
Work landing page

for a list of just a few of these,  including updating a widget and getting location in the
background.

Local
Debugging tools for Background Work: Common Scenarios

To
debug Background Work and understand why a task may have been delayed or failed, you need
visibility into
how the system has scheduled your tasks. 

To
help with this, WorkManager has several related

tools to help you debug locally

and optimize performance (some of these work for JobScheduler as well)! Here are some common
scenarios you
might encounter when using WorkManager, and an explanation of tools you can use to debug
them.

Debugging
why scheduled work is not executing

Scheduled
work being delayed or not executing at all can be due to a number of factors, including
specified
constraints not being met or constraints having been
imposed
by the system

The
first step in investigating why scheduled work is not running is to
confirm
the work was successfully scheduled

After confirming the scheduling status, determine whether there are any unmet constraints or
preconditions
preventing the work from executing.

There
are several tools for debugging this scenario.

Background
Task Inspector

The
Background Task Inspector is a powerful tool integrated directly into Android Studio. It
provides a visual
representation of all WorkManager tasks and their associated states (Running, Enqueued, Failed,
Succeeded). 

To
debug why scheduled work is not executing with the Background Task Inspector, consult the listed
Work
status(es). An ‘Enqueued’ status indicates your Work was scheduled, but is still waiting to
run.

Benefits:
Aside from providing an easy way to view all tasks, this tool is especially useful if you have
chained work.
The Background Task inspector offers a graph view that can visualize if a previous task failing
may have
impacted the execution of the following task.

Background
Task Inspector list view



Background
Task Inspector graph view

adb
shell dumpsys jobscheduler

This
command
returns a list of all active JobScheduler jobs (which includes WorkManager Workers) along with
specified
constraints, and system-imposed constraints. It also returns job
history. 

Use
this if you want a different way to view your scheduled work and associated constraints. For
WorkManager
versions earlier than WorkManager 2.10.0,
adb
shell dumpsys jobscheduler

will return a list of Workers with this name:

[package
name]/androidx.work.impl.background.systemjob.SystemJobService


If
your app has multiple workers, updating to WorkManager 2.10.0 will allow you to see Worker names
and easily
distinguish between workers:

#WorkerName#@[package
name]/androidx.work.impl.background.systemjob.SystemJobService


Benefits:
This
command is useful for understanding if there were any
system-imposed
constraints,
which
you cannot determine with the Background Task Inspector. For example, this will return your
app’s
standby bucket
,
which can affect the window in which scheduled work completes.

Enable
Debug logging

You
can enable
custom
logging

to see verbose WorkManager logs, which will have
WM—
attached. 

Benefits:
This allows you to gain visibility into when work is scheduled, constraints are fulfilled, and
lifecycle
events, and you can consult these logs while developing your app.

WorkInfo.StopReason

If
you notice unpredictable performance with a specific worker, you can programmatically observe
the reason
your worker was stopped on the previous run attempt with
WorkInfo.getStopReason

It’s
a good practice to configure your app to observe WorkInfo using getWorkInfoByIdFlow to identify
if your work
is being affected by background restrictions, constraints, frequent timeouts, or even stopped by
the
user.

Benefits:
You can use WorkInfo.StopReason to collect field data about your workers’
performance.

Debugging
WorkManager-attributed high wake lock duration flagged by Android vitals

Android
vitals features an excessive partial wake locks metric, which highlights wake locks contributing
to battery
drain. You may be surprised to know that
WorkManager
acquires wake locks to execute tasks
,
and if the wake locks exceed the threshold set by Google Play, can have impacts to your app’s
visibility.
How can you debug why there is so much wake lock duration attributed to your work? You can use
the following
tools.

Android
vitals dashboard

First
confirm in the
Android
vitals excessive wake lock dashboard

that the high wake lock duration
is
from WorkManager and not an alarm or other wake lock. You can use the
Identify
wake locks created by other APIs

documentation to understand which wake locks are held due to WorkManager. 

Perfetto

Perfetto
is a tool for analyzing system traces. When using it for debugging WorkManager specifically, you
can view
the “Device State” section to see when your work started, how long it ran, and how it
contributes to power
consumption. 

Under
“Device State: Jobs” track,  you can see any workers that have been executed and their
associated wake
locks.

 

Device
State section in Perfetto, showing CleanupWorker and BlurWorker execution.

Resources

Consult
the
Debug
WorkManager page

for an overview of the available debugging methods for other scenarios you might
encounter.

And
to try some of these methods hands on and learn more about debugging WorkManager, check out
the

Advanced WorkManager and Testing

codelab.

Next
steps

Today
we moved beyond code shrinking and explored how the Android Runtime and Jetpack Compose actually
render your
app. Whether it’s pre-compiling critical paths with Baseline Profiles or smoothing out scroll
states with
the new Compose 1.9 and 1.10 features, these tools focus on the
feel
of your app. And we dove deep into best practices on debugging background work.

Ask
Android

On
Friday we’re hosting a live AMA on performance. Ask your questions now using #AskAndroid and get
them
answered by the experts. 



The
challenge

We
challenged you on Monday to enable R8. Today, we are asking you to
generate
one Baseline Profile

for your app.

With
Android
Studio Otter
,
the Baseline Profile Generator module wizard makes this easier than ever. Pick your most
critical user
journey—even if it’s just your app startup and login—and generate a profile.

Once
you have it, run a Macrobenchmark to compare
CompilationMode.None
vs.
CompilationMode.Partial.

Share
your startup time improvements on social media using
#optimizationEnabled.

Tune
in tomorrow

You
have shrunk your app with R8 and optimized your runtime with Profile Guided Optimization. But
how do you
prove
these wins to your stakeholders? And how do you catch regressions before they hit
production?

Join
us tomorrow for
Day
4: The Performance Leveling Guide
,
where we will map out exactly how to measure your success, from field data in Play Vitals to
deep local
tracing with Perfetto.

The post Deeper Performance Considerations appeared first on InShot Pro.

]]>
Configure and troubleshoot R8 Keep Rules https://theinshotproapk.com/configure-and-troubleshoot-r8-keep-rules/ Tue, 18 Nov 2025 17:00:00 +0000 https://theinshotproapk.com/configure-and-troubleshoot-r8-keep-rules/ Posted by Ajesh R Pai – Developer Relations Engineer & Ben Weiss – Senior Developer Relations Engineer In modern Android ...

Read more

The post Configure and troubleshoot R8 Keep Rules appeared first on InShot Pro.

]]>

Posted by Ajesh R Pai – Developer Relations Engineer & Ben Weiss – Senior Developer Relations Engineer


In modern Android development, shipping a small, fast, and secure application is a fundamental user expectation. The Android build system’s primary tool for achieving this is the
R8 optimizer, the compiler that handles dead code and resource removal for shrinking, code renaming or minification, and app optimization.

Enabling R8 is a critical step in preparing an app for release, but it requires developers to provide guidance in the form of “Keep Rules.”

After reading this article, check out the Performance Spotlight Week video on enabling, debugging and troubleshooting the R8 optimizer on YouTube.

Why Keep Rules are needed

The need to write Keep Rules stems from a core conflict: R8 is a static analysis tool, but Android apps often rely on dynamic execution patterns like reflection or calls in and out of native code using the JNI (Java Native Interface).

R8 builds a graph of used code by analyzing direct calls. When code is accessed in a dynamic way, R8’s static analysis cannot predict that and it will identify that code as unused and remove it, leading to runtime crashes.

A keep rule is an explicit instruction to the R8 compiler, stating: “This specific class, method, or field is an entry point that will be accessed dynamically at runtime. You must keep it, even if you cannot find a direct reference to it.”

See the official guide for more details on Keep Rules.

Where to write Keep Rules

Custom Keep Rules for an application are written in text file. By convention, this file is named proguard-rules.pro and is located in the root of the app or library module. This file is then specified in your module’s build.gradle.kts file’s release build type.

release {

    isShrinkResources = true

    isMinifyEnabled = true

    proguardFiles(

        getDefaultProguardFile(“proguard-android-optimize.txt”),

        “proguard-rules.pro”,

    )

}


Use the correct default file

The getDefaultProguardFile method imports a default set of rules provided by the Android SDK. When using the wrong file your app might not be optimized. Make sure to use proguard-android-optimize.txt. This file provides the default Keep Rules for standard Android components and enables R8’s code optimizations. The outdated proguard-android.txt only provides the Keep Rules but does not enable R8’s optimizations.

Since this is a serious performance problem, we are starting to warn developers about using the wrong file, starting in Android Studio Narwhal 3 Feature Drop. And starting with the Android Gradle Plugin Version 9.0 we’re no longer supporting the outdated proguard-android.txt file. So make sure you upgrade to the optimized version.

How to write Keep Rules

A keep rule consists of three main parts:

  1. An option like -keep or -keepclassmembers

  2. Optional modifiers like allowshrinking

  3. A class specification that defines the code to match

For the complete syntax and examples, refer to the guidance to add Keep Rules.

Keep Rule anti-patterns

It’s important to know about best practices, but also about anti-patterns. These anti-patterns often arise from misunderstandings or troubleshooting shortcuts and can be catastrophic for a production build’s performance.

Global options

These flags are global toggles that should never be used in a release build. They are only for temporary debugging to isolate a problem.

Using -dontotptimize effectively disables R8’s performance optimizations leading to a slower app.

When using -dontobfuscate you disable all renaming and using -dontshrink turns off dead code removal. Both of these global rules increase app size.

Avoid using these global flags in a production environment wherever possible for a more performant app user experience.

Overly broad keep rules

The easiest way to nullify R8’s benefits is to write overly-broad Keep Rules. Keep rules like the one below instruct the R8 optimizer to not shrink, not obfuscate, and not optimize any class in this package or any of its sub-packages. This completely removes R8’s benefits for that entire package. Try to write narrow and specific Keep Rules instead.


-keep class com.example.package.** { *;} // WIDE KEEP RULES CAUSE PROBLEMS


The inversion operator (!)

The inversion operator (!) seems like a powerful way to exclude a package from a rule. But it’s not that simple. Take this example:


-keep class !com.example.my_package.** { *; } // USE WITH CAUTION

You might think that this rule means “do not keep classes in com.example.package.” But it actually means “keep every class, method and property in the entire application that is not in com.example.package.” If that came as a surprise to you, best check for any negations in your R8 configuration.

Redundant rules for Android components

Another common mistake is to manually add Keep Rules for your app’s Activities, Services, or BroadcastReceivers. This is unnecessary. The default proguard-android-optimize.txt file already includes the relevant rules for these standard Android components to work out of the box.

Also many libraries bring their own Keep Rules. So you should not have to write your own rules for these. In case there is a problem with Keep Rules from a library you’re using, it is best to reach out to the library author to see what the problem is.

Keep Rule best practices

Now that you know what not to do, let’s talk about best practices.

Write narrow Keep Rules

Good Keep Rules should be as narrow and specific as possible. They should preserve only what is necessary, allowing R8 to optimize everything else.

Rule

Quality

-keep class com.example.** { ; }

Low: Keeps an entire package and its subpackages

-keep class com.example.MyClass { ; }

Low: Keeps an entire class which is likely still too wide

-keepclassmembers class com.example.MyClass {

    private java.lang.String secretMessage;

    public void onNativeEvent(java.lang.String);

}

High: Only relevant methods and properties from a specific class are kept


Use common ancestors

Instead of writing separate Keep Rules for multiple different data models, write one rule that targets a common base class or interface. The below rule tells R8 to keep any members of classes that implement this interface and is highly scalable.


# Keep all fields of any class that implements SerializableModel

-keepclassmembers class * implements com.example.models.SerializableModel {

    <fields>;

}


Use Annotations to target multiple classes

Create a custom annotation (e.g., @Serialize) and use it to “tag” classes that need their fields preserved. This is another clean, declarative, and highly scalable pattern. You can create Keep Rules for already existing annotations from frameworks you’re using as well.

# Keep all fields of any class annotated with @Serialize

-keepclassmembers class * {

    @com.example.annotations.Serialize <fields>;

}

Choose the right Keep Option

The Keep Option is the most critical part of the rule. Choosing the wrong one can needlessly disable optimization.

Keep Option

What It Does

-keep

Prevents the class and members mentioned in the declaration from being removed or renamed.

-keepclassmembers

Prevents the specified members from being removed or renamed, but allows the class itself to be removed but only on classes which are not otherwise removed.

-keepclasseswithmembers

A combination: Keeps the class and its members, only if all the specified members are present.


You can find more about the keep option in our
documentation for Keep Options.

Allow optimization with Modifiers

Modifiers like allowshrinking and allowobfuscation relax a broad -keep rule, giving optimization power back to R8. For example, if a legacy library forces you to use -keep on an entire class, you might be able to reclaim some optimization by allowing shrinking and obfuscation:


# Keep this class, but allow R8 to remove it if it’s unused and allow R8 to rename it.

-keep,allowshrinking,allowobfuscation class com.example.LegacyClass


Add global options for additional optimization

Beyond Keep Rules, you can add global flags to your R8 configuration file to encourage even more optimization.

-repackageclasses is a powerful option that instructs R8 to move all obfuscated classes into a single package. This saves significant space in the DEX file by removing redundant package name strings.

-allowaccessmodification allows R8 to widen access (e.g., private to public) to enable more aggressive inlining. This is now enabled by default when using proguard-android-optimize.txt.

Warning: Library authors must never add these global optimization flags to their consumer rules, as they would be forcibly applied to the entire app.

And to make it even more clear, in version 9.0 of the Android Gradle Plugin we’re going to start ignoring global optimization flags from libraries altogether. 

Best practices for libraries

Every Android app relies on libraries one way or another. So let’s talk about best practices for libraries.

For library developers

If your library uses reflection or JNI, you have the responsibility to provide the necessary Keep Rules to its consumers. These rules are placed in a consumer-rules.pro file, which is then automatically bundled inside the library’s AAR file.

android {

    defaultConfig {

        consumerProguardFiles(“consumer-rules.pro”)

    }

    

}


For library consumers

Filter out problematic Keep Rules

If you must use a library that includes problematic Keep Rules, you can filter them out in your build.gradle.kts file starting with AGP 9.0 This tells R8 to ignore the rules coming from a specific dependency.


release {

    optimization.keepRules {

        // Ignore all consumer rules from this specific library

        it.ignoreFrom(“com.somelibrary:somelibrary”)

    }

}


The best Keep Rule is no Keep Rule

The ultimate R8 configuration strategy is to remove the need to write Keep Rules altogether. For many apps can be achieved by choosing modern libraries that favor code generation over reflection. With code generation, the optimizer can more easily determine what code is actually used at runtime and what code can be removed. Also not using any dynamic reflection means no “hidden” entry points, and therefore, no Keep Rules are needed. When choosing a new library, always prefer a solution that uses code generation over reflection.

For more information about how to choose libraries, check choose library wisely.

Debugging and troubleshooting your R8 configuration

When R8 removes code it should have kept, or your APK is larger than expected, use these tools to diagnose the problem.

Find duplicate and global Keep Rules

Because R8 merges rules from dozens of sources, it can be hard to know what the “final” ruleset is. Adding this flag to your proguard-rules.pro file generates a complete report:

# Outputs the final, merged set of rules to the specified file

-printconfiguration build/outputs/logs/configuration.txt


You can search this file to find redundant rules or trace a problematic rule (like -dontoptimize) back to the specific library that included it.

Ask R8: Why are you keeping this?

If a class you expected to be removed is still in your app, R8 can tell you why. Just add this rule:

# Asks R8 to explain why it’s keeping a specific class

class com.example.MyUnusedClass

-whyareyoukeeping 



During the build, R8 will print the exact chain of references that caused it to keep that class, allowing you to trace the reference and adjust your rules.

For a full guide, check out the troubleshoot R8 section.

Next steps

R8 is a powerful tool for enhancing Android app performance. Its effectiveness, depends on a correct understanding of its operation as a static analysis engine.

By writing specific, member-level rules, leveraging ancestors and annotations, and carefully choosing the right keep options, you can preserve exactly what is necessary. The most advanced practice is to eliminate the need for rules entirely by choosing modern, codegen-based libraries over their reflection-based predecessors.

As you’re following along Performance Spotlight Week, make sure to check out today’s Spotlight Week video on YouTube and continue with our R8 challenge. Use #optimizationEnabled for any questions on enabling or troubleshooting R8. We’re here to help.

It’s time to see the benefits for yourself.

We challenge you to enable R8 full mode for your app today.

  1. Follow our developer guides to get started: Enable app optimization.

  2. Check if you still use proguard-android.txt and replace it with proguard-android-optimize.txt.

  3. Then, measure the impact. Don’t just feel the difference, verify it. Measure your performance gains by adapting the code from our Macrobenchmark sample app on GitHub to measure your startup times before and after.

We’re confident you’ll see a meaningful improvement in your app’s performance.

While you’re at it, use the social tag #AskAndroid to bring your questions. Throughout the week our experts are monitoring and answering your questions.

Stay tuned for tomorrow, where we’ll talk about Profile Guided Optimization with Baseline and Startup Profiles, share how Compose rendering performance improved over the past releases and share performance considerations for background work.


The post Configure and troubleshoot R8 Keep Rules appeared first on InShot Pro.

]]>
How Reddit used the R8 optimizer for high impact performance improvements https://theinshotproapk.com/how-reddit-used-the-r8-optimizer-for-high-impact-performance-improvements/ Mon, 17 Nov 2025 18:01:00 +0000 https://theinshotproapk.com/how-reddit-used-the-r8-optimizer-for-high-impact-performance-improvements/ Posted by Ben Weiss – Senior Developer Relations Engineer In today’s world of mobile applications, a seamless user experience is ...

Read more

The post How Reddit used the R8 optimizer for high impact performance improvements appeared first on InShot Pro.

]]>

Posted by Ben Weiss – Senior Developer Relations Engineer

In today’s world of mobile applications, a seamless user experience is not just a feature—it’s a necessity. Slow load times, unresponsive interfaces, and instability can be significant barriers to user engagement and retention. During their work with the Android Developer Relations team, the engineering team at Reddit used the App Performance Score to evaluate their app. After assessing their performance, they identified significant improvement potential and decided to take the steps to enable the full power of R8, the Android app optimizer. This focused initiative led to remarkable improvements in startup times, reductions in slow or frozen frames and ANRs, and an overall increase in Play Store ratings. This case study breaks down how Reddit achieved these impressive results.


How the R8 Optimizer helped Reddit

The R8 Optimizer is a foundational tool for performance optimization on Android. It takes various steps to improve app performance.Let’s take a quick look at the most impactful ones.


  • Tree shaking is the most important step to reduce an app’s size. Here, unused code from app dependencies and the app itself is removed.

  • Method inlining replaces method calls with the actual code, making the app more performant.

  • Class merging, and other strategies are applied to make the code more compact. At this point it’s not about human readability of source code any more, but making compiled code work fast. So abstractions, such as interfaces or class hierarchies don’t matter here and will be removed.

  • Identifier minification changes the names of classes, fields, and methods to shorter, meaningless names. So instead of MyDataModel you might end up with a class called a

  • Resource shrinking removes unused resources such as xml files and drawables to further reduce app size.


Caption: Main stages of R8 Optimization


From hard data to user satisfaction: Identifying success in production

Reddit saw improved performance results immediately after a new version of the app was rolled out to users. By using Android Vitals and Crashlytics, Reddit was able to capture performance metrics on real devices with actual users, allowing them to compare the new release against previous versions.

Caption: How R8 improved Reddit’s app performance


The team observed a 40% faster cold startup, a 30% reduction in “Application Not Responding” (ANR) errors, a 25% improvement in frame rendering, and a 14% reduction in app size.

These enhancements are crucial for user satisfaction. A faster startup means less waiting and quicker access to content. Fewer ANRs lead to a more stable and reliable app, reducing user frustration. Smoother frame rendering removes UI jank, making scrolling and animations feel fluid and responsive. This positive technical impact was also clearly visible in user sentiment.

User satisfaction indicators of the optimization’s success were directly visible on the Google Play Store. Following the rollout of the R8-optimized version, the team saw a dramatic and positive shift in user sentiment and engagement.


Drew Heavner: “Enabling R8’s full potential tool less than 2 weeks”


Most impressively, this was accomplished with a focused effort. Drew Heavner, the Staff Software Engineer at Reddit who worked on this initiative, noted that implementing the changes to enable R8’s full potential took less than two weeks.

Confirming the gains: A deep dive with macrobenchmarks

After observing the significant real-world improvements, Reddit’s engineering team and the Android Developer Relations team at Google conducted detailed benchmarks to scientifically confirm the gains and experiment with further optimizations. For this analysis, Reddit engineering provided two versions of their app: one without optimizations and another that applied R8 and two more foundational performance optimization tools: Baseline Profiles, and Startup Profiles.

Baseline Profiles effectively move the Just in Time (JIT) compilation steps away from user devices and onto developer machines. The generated Ahead Of Time (AOT) compiled code has proven to reduce startup time and rendering issues alike.

When an app is packaged, the d8 dexer takes classes and methods and constructs your app’s
classes.dex files. When a user opens the app, these dex files are loaded, one after the other until the app can start. By providing a Startup Profile you let d8 know which classes and methods to pack in the first classes.dex files. This structure allows the app to load fewer files, which in turn improves startup speed.

Jetpack Macrobenchmark was the core tool for this phase, allowing for precise measurement of user interactions in a controlled environment. To simulate a typical user journey, they used the UIAutomator API to create a test that opened the app, scrolled down three times, and then scrolled back up.

In the end all that was needed to write the benchmark was this:

uiAutomator {

  startApp(REDDIT)

  repeat(3) {

    onView { isScrollable }.fling(Direction.DOWN) }

  repeat(3) {

    onView {isScrollable }.fling(Direction.UP)

  }

}

The benchmark data confirmed the field observations and provided deeper insights. The fully optimized app started 55% faster and users could begin to browse 18% sooner. The optimized app also showed a two-thirds reduction in Just in Time (JIT) compilation occurrences and a one-third decrease in JIT compilation time. Frame rendering improved, resulting in 19% more frames being rendered over the benchmarked user journey. Finally, the app’s size was reduced by over a third.

Caption: Reddit’s overall performance improvements

You can measure the JIT compilation time with a custom Macrobenchmark trace section metric like this:

val jitCompilationMetric = TraceSectionMetric(“JIT Compiling %”, label = “JIT compilation”)


Enabling the technology behind the transformation: R8

To enable R8 in full mode, you configure your app/build.gradle.kts file by setting minifyEnabled and shrinkResources to true in the release build type.

android {

    …

    buildTypes {

        release {

            isMinifyEnabled = true

            isShrinkResources = true

            proguardFiles(

                getDefaultProguardFile(“proguard-android-optimize.txt”),

                “keep-rules.pro”,

            )

        }

    }

}


This step has to be followed by holistic end to end testing, as performance optimizations can lead to unwanted behavior, which you better catch before your users do.

As shown earlier in this article, R8 performs extensive optimizations in order to maximize your performance benefits. R8 makes substantial modifications to the code including renaming, moving, and removing classes, fields and methods. If you observe that these modifications cause errors, you need to specify which parts of the code R8 shouldn’t modify by declaring those in keep rules.

Follow Reddit’s example in your app

Reddit’s success with R8 serves as a powerful case study for any development team looking to make a significant, low-effort impact on their app’s performance. The direct correlation between the technical improvements and the subsequent rise in user satisfaction underscores the value of performance optimization.

By following the blueprint laid out in this case study—using tools like the App Performance Score to identify opportunities, enabling R8’s full optimization potential, monitoring real-world data, and using benchmarks to confirm and deepen understanding—other developers can achieve similar gains.

To get started with R8 in your own app, refer to the freshly updated official documentation and guidance on enabling, configuring and troubleshooting the R8 optimizer.


The post How Reddit used the R8 optimizer for high impact performance improvements appeared first on InShot Pro.

]]>
Use R8 to shrink, optimize, and fast-track your app https://theinshotproapk.com/use-r8-to-shrink-optimize-and-fast-track-your-app/ Mon, 17 Nov 2025 17:00:00 +0000 https://theinshotproapk.com/use-r8-to-shrink-optimize-and-fast-track-your-app/ Posted by Ben Weiss – Senior Developer Relations Engineer Welcome to day one of Android Performance Spotlight Week! We’re kicking ...

Read more

The post Use R8 to shrink, optimize, and fast-track your app appeared first on InShot Pro.

]]>

Posted by Ben Weiss – Senior Developer Relations Engineer

Welcome to day one of Android Performance Spotlight Week!

We’re kicking things off with the single most impactful, low-effort change you can make to improve your app’s performance: enabling the R8 optimizer in full mode.

You probably already know R8 as a tool to shrink your app’s size. It does a fantastic job of removing unused code and resources, reducing your app’s size. But its real power, the one it’s really g-R8 at, is as an optimizer.

When you enable full mode and allow optimizations, R8 performs deep, whole-program optimizations, rewriting your code to be fundamentally more efficient. This isn’t just a minor tweak.

After reading this article, check out the Performance Spotlight Week introduction to the R8 optimizer on YouTube.

How R8 makes your app more performant

Let’s shine a spotlight on the largest steps that the R8 optimizer takes to improve app performance.

Tree shaking is the most important step to reduce app size. During this phase the R8 optimizer removes unused code from libraries that your app depends on as well as dead code from your own codebase.

Method inlining replaces a method call with the actual code, which improves runtime performance.

Class merging, and other strategies are applied to make the code more compact. All your beautiful abstractions, such as interfaces and class hierarchies don’t matter at this point and are likely to be removed.

Code minification is used to change the names of classes, fields, and methods to shorter, meaningless ones. So instead of MyDataModel you might end up with a class called

a. This is what causes the most confusion when reading stack traces from an R8 optimized app. (Note that we have improved this in AGP 9.0!)

Resource shrinking further reduces an app’s size by removing unused resources such as xml files and drawables.

By applying these steps the R8 optimizer improves app startup times, enables smoother UI rendering, with fewer slow and frozen frames and improves overall on-device resource usage.

Case Study: Reddit’s performance improvements with R8

As one example of the performance improvements that R8 can bring, let’s take a look at an example from Reddit. After enabling R8 in full mode, the Reddit for Android app saw significant performance improvements in various areas.

Caption: How R8 improved Reddit’s app performance


The team observed a 40% faster cold startup, a 30% reduction in “Application Not Responding” (ANR) errors, a 25% improvement in frame rendering, and a 14% reduction in app size

.


These enhancements are crucial for user satisfaction. A faster startup means less waiting and quicker access to content. Fewer ANRs lead to a more stable and reliable app, reducing user frustration. Smoother frame rendering removes UI jank, making scrolling and animations feel fluid and responsive. This positive technical impact was also clearly visible in user sentiment.

You can read more about their improvements on our blog.


Non-technical side effects of using R8

During our work with partners we have seen that these technical improvements have a direct impact on user satisfaction and can be reflected in user retention, engagement and session length. User stickiness, which can be measured with daily, weekly or monthly active users, has also been positively affected by technical performance improvements. And we’ve seen app ratings on the Play Store rise in correlation with R8 adoption. Sharing this with your product owners, CTOs and decision makers can help speed up your app’s performance.



So let’s call it what it is: Deliberate performance optimization is a virtue.

Guiding you to a more performant app

We heard that our developer guidance for R8 needed to be improved. So we went to work. The developer guidance for the R8 optimizer now is much more actionable and provides comprehensive guidance to enable and debug R8.

The documentation guides you on the high-level strategy for adoption, emphasizing the importance of choosing optimization-friendly libraries and, crucially, adopting R8’s features incrementally to ensure stability. This phased approach allows you to safely unlock the benefits of R8 while providing you with guidance on difficult-to-debug issues.

We have significantly expanded our guidance on Keep Rules, which are the primary mechanism for controlling the R8 optimizer. We now provide a section on what Keep Rules are, how to apply them and guide you with best practices for writing and maintaining them. We also provide practical and actionable use cases and examples, helping you understand how to correctly prevent R8 from removing code that is needed at runtime, such as code accessed via reflection or use of the JNI native interface.

The documentation now also covers essential follow-up steps and advanced scenarios. We added a section on testing and troubleshooting, so you can verify the performance gains and debug any potential issues that arise. The advanced configurations

section explains how to target specific build variants, customize which resources are kept or removed, and offers special optimization instructions for library authors, ensuring you can provide an optimized and R8-friendly package for other developers to use.

Enable the R8 optimizer’s full potential

The R8 optimizer defaults to using “full mode” since version 8.0 of the Android Gradle Plugin. If your project has been developed over many years, it might still include a legacy flag to disable it. Check your gradle.properties file for this line and remove it.

android.enableR8.fullMode=false // delete this line to enable R8’s full potential

Now check whether you have enabled R8 in your app’s build.gradle.kts file for the release variant. It’s enabled by setting isMinifyEnabled and isShrinkResources to true. You can also pass default and custom configuration files at this step.

release {

   isMinifyEnabled = true

   isShrinkResources = true

   proguardFiles(

       getDefaultProguardFile(“proguard-android-optimize.txt”),

       “keep-rules.pro”

   )

}


Case Study: Disney+ performance improvements

Engineers at Disney+ invest in app performance and are optimizing the app’s user experience. Sometimes even seemingly small changes can make a huge impact. While inspecting their R8 configuration, the team found that the -dontoptimize flag was being used. It was brought in by a default configuration file, which is still used in many apps today.


After replacing proguard-android.txt

with proguard-android-optimize.txt, the Disney+ team saw significant improvements in their app’s performance.

After a new version of the app containing this change was rolled out to users, Disney+ saw 30% faster app startup and 25% fewer user-perceived ANRs. 

Today many apps still use the proguard-android.txt file which contains the -dontoptimize flag. And that’s where our tooling improvements come in.

Tooling support

Starting with Android Studio Narwhal 3 Feature Drop, you will see a lint warning when using proguard-android.txt 

And from AGP 9.0 onwards we are entirely dropping support for the file. This means you will have to migrate to proguard-android-optimize.txt.

We’ve also invested in new Android Studio features

to make debugging R8-optimized code easier than ever. Starting in AGP 9.0 you can now automatically de-obfuscate stack traces within Android Studio’s logcat for R8-processed builds, helping you pinpoint the exact line of code causing an issue, even in a fully optimized app. This will be covered in more depth in tomorrow’s blog post on this Android Performance Spotlight Week.

Next Steps

Check out the Performance Spotlight Week introduction to the R8 optimizer on YouTube.


📣 Take the Performance Challenge!

It’s time to see the benefits for yourself.

We challenge you to enable R8 full mode for your app today.

  1. Follow our developer guides to get started: Enable app optimization.

  2. Check if you still use proguard-android.txt and replace it with proguard-android-optimize.txt.

  3. Then, measure the impact. Don’t just feel the difference, verify it. Measure your performance gains by adapting the code from our

    Macrobenchmark sample app on GitHub to measure your startup times before and after.

We’re confident you’ll see a meaningful improvement in your app’s performance. Use #optimizationEnabled for any questions on enabling or troubleshooting R8. We’re here to help.

Bring your questions for the Ask Android session on Friday

Use the social tag #AskAndroid to bring any performance questions. Throughout the week we are monitoring your questions and will answer several in the Ask Android session on performance on Friday, November 21. Stay tuned for tomorrow, where we’ll dive even deeper into debugging and troubleshooting. But for now, get started with R8 and get your app on the fast track.


The post Use R8 to shrink, optimize, and fast-track your app appeared first on InShot Pro.

]]>