Proguard configurations for common Android libraries

Overview

android-proguard-snippets

Example Proguard configurations for common Android libraries.

This project assumes that your ProGuard configuration is based off of the latest official proguard-android.txt config as shown below. Each library configuration should only be the rules required for that specific library, not a complete Android ProGuard configuration. The various library configurations are combined by the Gradle build system. The library rules should be universal, any app specific rules (such as preserving model classes) should be added in a custom proguard-project.pro file.

Request additional libraries through issues. Pull requests are welcome.

Android Arsenal

Usage

android {
  buildTypes {
    release {
      minifyEnabled true
      // Library specific proguard files
      proguardFile 'proguard-google-play-services.pro'
      proguardFile 'proguard-gson.pro'
      ...
      // Default proguard files & project app specific rules,
      //  see examples folder for more information
      proguardFile 'proguard-project-app.pro'
      proguardFile getDefaultProguardFile('proguard-android.txt')
      // As of Gradle Android plugin 1.1.0, the test APK has a separate config
      testProguardFile 'proguard-project-test.pro'
    }
  }
}

Instead of declaring each configuration file manually, you could also store them in a seperate directory and include them all at once:

FileCollection proGuardFileCollection = files { file('./proguard').listFiles() }
proguardFiles(proGuardFileCollection)

Libraries

ProGuard tip for android libraries developers

The android libraries developers can include the proguard directives in the libraries. The Android Plugin for Gradle automatically appends ProGuard configuration files in an AAR (Android ARchive) package and appends that package to your ProGuard configuration

The developers only need to specify the Proguard file with consumerProguardFiles instead of proguardFiles:

defaultConfig {
    consumerProguardFiles 'proguard-file.pro'
}
Comments
  • Adds Retrofit2 ProGuard rules

    Adds Retrofit2 ProGuard rules

    As per https://square.github.io/retrofit/

    Note that it is intended that these don't replace those for Retrofit 1.x as both should be able to coexist within the same project (https://github.com/square/retrofit/releases/tag/parent-2.0.0-beta3).

    opened by stoyicker 3
  • Doesn't work with Build Tools 2.2.3

    Doesn't work with Build Tools 2.2.3

    The thrown message when syncing the gradle project is

    Error:(110, 0) Cannot convert the provided notation to a File or URI: file collection.
    The following types/formats are supported:
      - A String or CharSequence path, for example 'src/main/java' or '/usr/include'.
      - A String or CharSequence URI, for example 'file:/usr/include'.
      - A File instance.
      - A URI or URL instance.
    <a href="openFile:/Users/roc/Projects/AndroidStudio/bluejobs-app/app/build.gradle">Open File</a>
    
    opened by rocboronat 2
  • Butterknife config is updated.

    Butterknife config is updated.

    • Butterknife config for version above 7.x is updated. I've kept the old $$ViewInjector line for the people using the old version of the library. Extra 1 line won't hurt. This way it will cover both versions.
    • Added a header.
    opened by tasomaniac 2
  • Fix for ButterKnife 7.0

    Fix for ButterKnife 7.0

    ButterKnife 7.0 comes with some changes in syntax such as @Bind replaces @InjectView and this PR reflects accordingly. It's mentioned on the website too.

    opened by yelinaung 2
  • Add Parceler

    Add Parceler

    Library name: Parceler Library url: https://github.com/johncarl81/parceler

    # Parcel library
    -keep class * implements android.os.Parcelable {
      public static final android.os.Parcelable$Creator *;
    }
    
    -keep class org.parceler.Parceler$$Parcels
    
    opened by StErMi 1
  • ProGuard tip for android libraries developers

    ProGuard tip for android libraries developers

    A lot of android libraries (*.aar) don't include their proguard directives and the developers need to search for those configurations on the web and in some cases the information is outdated or incorrect. The Android Plugin for Gradle automatically appends the ProGuard configuration files in an AAR (Android ARchive) package and appends that package to the application ProGuard configuration, looks like most of the developers don't know this. This pull request adds this information to the README.md of this project.

    opened by SandroMachado 1
  • Update proguard-square-retrofit.pro

    Update proguard-square-retrofit.pro

    The proguard file for retrofit is incomplete. It does not support rest service interfaces with callbacks and error handling. This PR adds support for that.

    opened by SandroMachado 1
  • What If we have an aar regarding to this?

    What If we have an aar regarding to this?

    Libraries built with gradle can have consumerProguardFiles, which will be added in application itself. Google Play Services does that (as per Ian Lake's google+ post, when Google play services 7.5 are added). I have added consumer proguard line in one of my libraries here

    How about having an aar built around these files? people don't have to download all the files separately and adding manually? Just add a library as dependency and it should take care of keep classes in proguard. In my knowledge it won't add anything to final apk, as we're not adding any code into the library, just build logic. I am proposing aar because I am familiar with developing gradle plugins and on the other hand I am not aware about adding consumerProguardFiles programatically from plugins.

    Only downside I can see is the library size itself is too big provided there are too many files. But as I have stated above it should not add any footprint to final apk size. So, are we going to have aar library around that?

    opened by PrashamTrivedi 1
  • Add Stetho rules

    Add Stetho rules

    Official source: https://github.com/facebook/stetho/wiki/FAQ#nothing-is-shown-in-chrome-devtools-and-i-see-many-method-not-implemented-messages-in-logcat

    opened by ChaitanyaPramod 1
  • Update proguard-logback-android.pro

    Update proguard-logback-android.pro

    • Updating rules for version 2.0.0 of loggback-android.
    • Adding additional 'dontwarn' on javax.mail preventing build.
    • Removing also com.github.tony19:logback-android-classic ( deprecated? )
    opened by anis-campos 0
  • After Applying Proguard Cannot take build

    After Applying Proguard Cannot take build

    `org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesAndResourcesWithProguardForRc'. at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70) at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51) at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62) at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54) at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60) at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97) at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87) at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54) at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328) at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98) at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626) at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.RuntimeException: Job failed, see logs for details at com.android.build.gradle.internal.transforms.ProGuardTransform.transform(ProGuardTransform.java:196) at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:221) at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:217) at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102) at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:212) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73) at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:46) at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39) at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328) at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92) ... 32 more Caused by: java.io.IOException: Please correct the above warnings first. at proguard.Initializer.execute(Initializer.java:473) at proguard.ProGuard.initialize(ProGuard.java:233) at proguard.ProGuard.execute(ProGuard.java:98) at com.android.build.gradle.internal.transforms.BaseProguardAction.runProguard(BaseProguardAction.java:61) at com.android.build.gradle.internal.transforms.ProGuardTransform.doMinification(ProGuardTransform.java:253) at com.android.build.gradle.internal.transforms.ProGuardTransform.access$000(ProGuardTransform.java:63) at com.android.build.gradle.internal.transforms.ProGuardTransform$1.run(ProGuardTransform.java:173) at com.android.builder.tasks.Job.runTask(Job.java:47) at com.android.build.gradle.tasks.SimpleWorkQueue$EmptyThreadContext.runTask(SimpleWorkQueue.java:41) at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:282) ... 1 more

    `

    opened by mohanrajsambath 0
Owner
Kevin Schultz
Software engineer focused on Android @facebook. Previously @gilt, @getlua, @buglabs
Kevin Schultz
A sample Android app which showcases advanced usage of Dagger among other open source libraries.

U+2020 A sample Android app which showcases advanced usage of Dagger among other open source libraries. Watch the corresponding talk or view the slide

Jake Wharton 5.7k Dec 22, 2022
A simple app demonstrates using Jetpack compose with other Jetpack libraries.

Android Pokemon Compose This repository is a simple app that make request to https://pokeapi.co and display them in the paginated lists. It demonstrat

BenBoonya 56 May 21, 2022
Quality-Tools-for-Android 7.5 0.0 L5 Java This is an Android sample app + tests that will be used to work on various project to increase the quality of the Android platform.

Quality Tools for Android This is an Android sample app + tests that will be used to work on various project to increase the quality of the Android pl

Stéphane Nicolas 1.3k Dec 27, 2022
A simple app to showcase Androids Material Design and some of the cool new cool stuff in Android Lollipop. RecyclerView, CardView, ActionBarDrawerToggle, DrawerLayout, Animations, Android Compat Design, Toolbar

#Android-LollipopShowcase This is a simple showcase to show off Android's all new Material Design and some other cool new stuff which is (new) in Andr

Mike Penz 1.8k Nov 10, 2022
A simple app to showcase Androids Material Design and some of the cool new cool stuff in Android Lollipop. RecyclerView, CardView, ActionBarDrawerToggle, DrawerLayout, Animations, Android Compat Design, Toolbar

#Android-LollipopShowcase This is a simple showcase to show off Android's all new Material Design and some other cool new stuff which is (new) in Andr

Mike Penz 1.8k Nov 10, 2022
simple android grocery app using kotlin and android studio

Project Idea The idea of this project is to make a grocery android app that users can use to order the groceries they want. It doesn't contain any bac

null 0 Nov 29, 2021
Beetlebug is an open source insecure Android application with CTF challenges built for Android Penetration Testers and Bug Bounty hunters.

Beetlebug Beetlebug is a beginner-friendly Capture the Flag Android application that aims to inspire interest in Mobile Application Security. It is ge

Hafiz Abdulaziz 60 Oct 11, 2022
Do's and Don'ts for Android development, by Futurice developers

Best practices in Android development Avoid reinventing the wheel by following these guidelines. Lessons learned from Android developers in Futurice.

Futurice 20.2k Dec 31, 2022
Learning RxJava for Android by example

Learning RxJava for Android by example This is a repository with real-world useful examples of using RxJava with Android. It usually will be in a cons

Kaushik Gopal 7.6k Dec 30, 2022
Examples of Android applications

Android Demos This is a collection of basic android examples created by Novoda. CarouselFragment CompassExample ContactSelector CustomActivityTransiti

Novoda 2k Jan 3, 2023
A simple chat demo for socket.io and Android

socket.io-android-chat This is a simple chat demo for socket.io and Android. You can connect to https://socket-io-chat.now.sh using this app. Installa

Naoyuki Kanezawa 1.9k Dec 30, 2022
Google Play game services - Android samples

Google Play game services - Android Samples Copyright (C) 2014 Google Inc. Contents These are the Android samples for Google Play game services. Colle

Google Play Game Services 952 Dec 27, 2022
Cheat Sheet for Android Interviews

Android-Cheat-sheet Cheat Sheet for Android Interviews Topics Common Coding Programs Data Structure Coding Programs Android Interview Questions Java I

Anitaa Murthy 2k Dec 31, 2022
RxJava architecture library for Android

Reference Architecture for Android using RxJava This is an ambitious reference project of what can be done with RxJava to create an app based on strea

Reark 2.1k Dec 17, 2022
📚 Sample Android Components Architecture on a modular word focused on the scalability, testability and maintainability written in Kotlin, following best practices using Jetpack.

Android Components Architecture in a Modular Word Android Components Architecture in a Modular Word is a sample project that presents modern, 2020 app

Madalin Valceleanu 2.3k Dec 30, 2022
Collection of Small Android Projects

AndroidDemoProjects ActivityRecognition: Example of using Google Play Services to recognize a user's activity, such as running, walking, or riding a b

Paul Ruiz 601 Dec 9, 2022
Sample material transition animations for Android

See ListOfThings for a newer implementation. Android Material Transitions This Android project samples some Material Design-ish transitions for list i

Todd Way 1.2k Dec 7, 2022
[] Explorations around Android custom layouts

android-layout-samples Explorations around Android custom layouts, including off main thread View measure/layout passes. Sample code for: Composite Vi

Lucas Rocha 796 Nov 15, 2022