explaingit

krschultz/android-proguard-snippets

4,546IDLAudience · developerComplexity · 1/5Setup · easy

TLDR

A collection of copy-paste ProGuard configuration rules for popular Android libraries, preventing runtime crashes in release builds caused by code shrinking.

Mindmap

mindmap
  root((ProGuard Rules))
    What it does
      Prevent crashes
      Library keep rules
      Copy-paste config
    Libraries covered
      Gson and Retrofit
      OkHttp and Picasso
      Firebase and Facebook
      Realm and EventBus
    How to use
      Add to Gradle build
      One file per library
    Status
      No longer maintained
      Historical reference
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Copy ProGuard rules for Gson, Retrofit, or OkHttp into your Android project to fix release build crashes.

USE CASE 2

Use as a reference when adding a library that does not bundle its own ProGuard configuration.

USE CASE 3

Maintain an older Android project that relies on libraries without built-in keep rules.

Tech stack

AndroidProGuardGradle

Getting it running

Difficulty · easy Time to first run · 5min
No license specified.

In plain English

When Android developers build a release version of their app, they often run a tool called ProGuard that shrinks the code by removing unused parts and renames variables and classes to shorter names. This makes the app smaller and harder to reverse-engineer. The problem is that ProGuard sometimes removes or renames code that a third-party library still needs, causing crashes at runtime. To prevent this, each library requires specific configuration rules that tell ProGuard what to leave alone. This repository is a collection of those configuration rules for dozens of popular Android libraries. Instead of every developer having to research and write these rules themselves, they can just copy the appropriate file from this project and add it to their build. The collection covers libraries that were widely used during the height of Android development in the early-to-mid 2010s, including Gson, Retrofit, OkHttp, Picasso, EventBus, Facebook, Google Play Services, Crashlytics, Realm, and many others. The setup is straightforward. You add the relevant configuration files to your Android project and reference them in your Gradle build file, which is the configuration file Android projects use. Each file contains only the rules needed for that specific library, so you include one file per library rather than one large combined file. The files are designed to sit alongside the official default ProGuard configuration that Google provides for Android. The project is no longer actively maintained and the library list reflects what was current several years ago. Many modern Android libraries now bundle their own ProGuard rules inside the library package itself, reducing the need for a repository like this one. However, it remains a useful reference for older projects or for libraries that still do not include their own rules. Contributions and requests for additional library configurations were accepted via pull requests and issues when the project was active.

Copy-paste prompts

Prompt 1
I'm using Retrofit and Gson in my Android app. Give me the ProGuard rules to prevent crashes in the release build.
Prompt 2
How do I add ProGuard rules from android-proguard-snippets to my Android Gradle build file?
Prompt 3
My Android release build crashes with a ClassNotFoundException. Help me write a ProGuard rule to keep the missing class.
Prompt 4
What ProGuard rules do I need for Firebase Crashlytics in an Android release build?
Open on GitHub → Explain another repo

← krschultz on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.