Reducing React Native App Size with Spotify Ruler & ProGuard

Sep 24, 2025

Reducing React Native App Size with Spotify Ruler & ProGuard

Learn how to reduce React Native app size using Spotify Ruler, ProGuard, and resource shrinking for faster installs, better performance, and higher user adoption.

Reducing App Size in React Native: A Deep Dive with Spotify Ruler & Proguard

One of the most important aspects of building a mobile app is ensuring that the final packaged application is lightweight, efficient, and optimized for distribution. Large app sizes can negatively affect user acquisition, as potential users are often discouraged from downloading apps that take up significant storage space. Moreover, smaller apps typically load faster, consume fewer resources, and provide an overall smoother user experience.

In this blog, Iโ€™ll walk you through some changes I implemented in a React Native app that successfully reduced both the download size and the install size. The methods discussed here are production-tested and make use of tools such as the Spotify Ruler plugin, ProGuard, resource shrinking, and Gradle configurations.

Why App Size Matters

Before diving into the technical implementation, letโ€™s quickly touch upon why app size optimization is critical:

  1. User Retention and Acquisition: According to studies, users are less likely to download apps above a certain size threshold, especially in regions where data plans are expensive or network connectivity is slow.
  2. Performance: A leaner app often results in faster installs, reduced memory consumption, and improved runtime performance.
  3. Play Store and App Store Ranking: Optimized apps are more likely to get recommended, as both stores track app performance metrics.
  4. Update Adoption: Smaller update packages mean that users can quickly upgrade to the latest version without hesitation.

Step 1: Analyzing App Size with Spotify Ruler

The first step in optimizing app size is measurement. Without visibility into what contributes to the appโ€™s bulk, it is nearly impossible to optimize effectively. This is where the Spotify Ruler Gradle plugin comes into play.

The Ruler plugin provides insights into your APK or AAB (Android App Bundle) size. It breaks down the contribution of Java bytecode, resources, assets, and even external libraries. By using this tool, you can identify exactly which modules or dependencies are consuming unnecessary space.

To get started, add the following dependency in your android/build.gradle:

buildscript {
    dependencies {
        classpath("com.spotify.ruler:ruler-gradle-plugin:2.0.0-beta-3")
    }
}

Then, apply the plugin in your android/app/build.gradle:

apply plugin: "com.spotify.ruler"
apply plugin: "com.android.application"

Once configured, youโ€™ll be able to generate size reports after building your release bundle.

Step 2: Enabling ProGuard for Bytecode Optimization

Next, we need to optimize the compiled Java/Kotlin bytecode. ProGuard is a powerful tool that shrinks, optimizes, and obfuscates code. By removing unused classes and methods, ProGuard reduces the overall size of your APK or AAB.

In android/app/build.gradle, enable ProGuard by setting:

def enableProguardInReleaseBuilds = true

This ensures that when you build your release version, ProGuard minifies the code and strips away any unused logic, resulting in a smaller build.

Step 3: Shrinking Resources

Another contributor to app size is unused resources such as images, layouts, and XML files. Android provides a resource shrinker that works hand-in-hand with ProGuard to remove unused resources from your final build.

Update your buildTypes block in android/app/build.gradle as follows:

buildTypes {
    debug {
        signingConfig signingConfigs.debug
    }
    release {
        signingConfig signingConfigs.debug
        minifyEnabled enableProguardInReleaseBuilds
        shrinkResources enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
}

Hereโ€™s what each line does:

  • minifyEnabled: Enables ProGuard to shrink bytecode.
  • shrinkResources: Removes unused resources.
  • proguardFiles: Uses the default ProGuard configuration along with a custom rules file to fine-tune optimizations.

This combination ensures that only essential code and resources make it into your final build.

Step 4: Configuring Ruler for Custom Analysis

You can further customize Ruler to simulate different runtime environments. Add the following configuration at the end of your android/app/build.gradle:

ruler {
    abi.set("arm64-v8a")
    locale.set("en")
    screenDensity.set(480)
    sdkVersion.set(rootProject.ext.compileSdkVersion)
}

Hereโ€™s what these parameters mean:

  • abi: Specifies the CPU architecture (e.g., ARM64).
  • locale: Sets the language/region (e.g., English).
  • screenDensity: Simulates the pixel density of the target device.
  • sdkVersion: Matches the compile SDK version of your project.

By tweaking these settings, you can better understand how your app behaves in different environments and how resources contribute to size.

Step 5: Running the Analysis Command

Once youโ€™ve set up the Ruler plugin and Gradle configurations, you can generate a size report for your release bundle. Navigate to the android folder of your project and run:

cd android
./gradlew analyzeReleaseBundle

This command generates a detailed report highlighting the size contribution of different modules, libraries, and resources. With this report, you can identify heavy dependencies or unused assets and take corrective measures. Below is the evidence which showcases the difference in install and download size with a detailed breakdown of the components.


Before: -

React Native app size before optimization with Spotify Ruler โ€“ 7.8MB download, 21MB install

After:-

React Native app size after ProGuard & Spotify Ruler โ€“ 5.5MB download, 14.5MB install

A Closer Look at Spotify Ruler

According to the official Spotify Ruler GitHub documentation, the plugin provides:

  1. Size Breakdown: Categorizes app size into code, resources, assets, and native libraries.
  2. Change Tracking: Helps you see how app size evolves over multiple builds.
  3. Configuration Options: Allows customization for ABI, locale, and screen density.
  4. CI/CD Integration: Can be integrated into your continuous integration pipeline to prevent sudden spikes in app size.

These features make Ruler not just a one-time analyzer but a continuous monitoring tool that helps maintain size discipline across versions.

Additional Strategies for Reducing App Size

While ProGuard, resource shrinking, and Ruler form the backbone of optimization, here are some additional strategies you can adopt:

  1. Use Vector Drawables Instead of PNGs
    Vector graphics scale better and consume less space than multiple PNG assets.
  2. Load Large Assets Dynamically
    Instead of bundling heavy media files in your app, consider fetching them from a CDN on-demand.
  3. Remove Unused Dependencies
    Audit your package.json and Gradle dependencies to remove unnecessary libraries.
  4. Use Android App Bundles (AAB)
    AAB allows the Play Store to deliver only the resources and binaries required for a specific device, reducing the installed size.
  5. Enable Hermes Engine
    For React Native apps, enabling the Hermes JavaScript engine can reduce the APK size and improve runtime performance.
Additional Strategies for Reducing React Native App Size

Business Impact of App Size Reduction

Reducing app size is not just a technical exerciseโ€”it directly impacts business outcomes:

  • Increased Downloads: A smaller app is more attractive to users with limited storage.
  • Reduced Uninstall Rate: Users are less likely to uninstall apps that donโ€™t hog device storage.
  • Cost Efficiency: Smaller apps reduce bandwidth costs for both developers (distribution) and users (downloads/updates).
  • Improved App Store Ratings: A smoother, faster app often results in higher ratings and reviews.

Conclusion

Optimizing app size in React Native is an iterative process that involves analysis, configuration, and continuous monitoring. By using tools like the Spotify Ruler plugin, enabling ProGuard, shrinking resources, and following best practices, you can significantly reduce both the download and install sizes of your app.

The key takeaway is that app size optimization is not just about technical performanceโ€”it also drives business value by improving user experience, increasing adoption rates, and lowering churn.

If you havenโ€™t already, integrate these practices into your development workflow and start monitoring app size today. Small changes at the build level can have a huge impact on your appโ€™s success in the market.

Subscribe to Our Newsletter

More from the engineering frontline.

Dive deep into our research and insights on design, development, and the impact of various trends to businesses.
Insight
Why Legacy Systems Make Business Growth More Expensive: Navigate A Smarter Path to Legacy Modernization
Sep 23, 2026

Why Legacy Systems Make Business Growth More Expensive: Navigate A Smarter Path to Legacy Modernization

Learn how legacy systems make business growth more expensive and how edge-first modernization can remove constraints without replacing the existing system.

Insight
SSO, Audit Logs and RBAC: The Enterprise Features AI Prototyping Tools Do Not Cover | Sarika Gautam
Sep 23, 2026

SSO, Audit Logs and RBAC: The Enterprise Features AI Prototyping Tools Do Not Cover | Sarika Gautam

Why AI-generated prototypes fail enterprise review: the context behind SSO, the cost of skipping audit logs, and how role explosion makes RBAC a product of its own.

Insight
Feature Flags as Technical Debt: The Cleanup Nobody Schedules
Sep 21, 2026

Feature Flags as Technical Debt: The Cleanup Nobody Schedules

This blog explains how unmanaged feature flags create technical debt and how teams can detect, manage, and remove them safely.

Insight
Building AI-First Enterprises: Why System Design Matters More Than AI Adoption
Sep 21, 2026

Building AI-First Enterprises: Why System Design Matters More Than AI Adoption

This blog explores how system design, architecture, and validation shape AI-first enterprises, while examining AIโ€™s impact on software engineering and human decision-making.

Insight
The Product Studio in the AI Era: What Actually Changes | Sarika Gautam
Sep 21, 2026

The Product Studio in the AI Era: What Actually Changes | Sarika Gautam

What changes in product development when AI writes the code: the shift to architecture, the token cost of unplanned builds, and why juniors still matter.

Insight
AI and the Future of Digital Customer Experience: Where Technology Meets Human Creativity
Sep 18, 2026

AI and the Future of Digital Customer Experience: Where Technology Meets Human Creativity

A discussion on how AI, human creativity, research, and cross-functional collaboration are shaping the future of digital customer experience.

Insight
Scaling Down Before Scaling Up: Why Bigger Servers Donโ€™t Fix Bad Architecture
Sep 17, 2026

Scaling Down Before Scaling Up: Why Bigger Servers Donโ€™t Fix Bad Architecture

This blog explores how inefficient backend architecture can cause performance issues even under low traffic, covering practical ways to reduce database load, API latency, and resource usage before scaling infrastructure.

The Right Conversation Can

Save You Six Months.

Book a call