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
Android common lib demo, include ImageCache, HttpCache, DropDownListView, DownloadManager, install apk silent and so on, you can find description

android-demo 关于我,欢迎关注 微博:Trinea 主页:trinea.cn 邮箱:trinea.cn#gmail.com 微信:codek2 依赖:trinea-android-common android-auto-scroll-view-pager viewpager-indica

Trinea 1.1k Dec 30, 2022
Warscape core library. Includes common models for sharing between platforms.

warscope-core This repository uses for sharing common models between backend and frontend sides. Implementation $version available at top of README.md

Warscape 5 Oct 8, 2021
BuildConfiguration information for use in multi-module, or Kotlin Multiplatform common code

component-build-configuration A small library supporting Kotlin Multiplatform for utilizing BuildConfiguration details from common code and across mod

Matthew Nelson 2 Mar 6, 2022
Design patterns are typical solutions to common problems in software design

Design patterns are typical solutions to common problems in software design. Each pattern is like a blueprint that you can customize to solve a particular design problem in your code.

hamid 4 Aug 30, 2022
Android playground project with modularization by feature (android libraries), unit tests, MVVM & MVI.

Movies Movies is a simple project to study and play with some android components, architecture and tools for Android development. Tech Stack This proj

Christopher Elias 333 Dec 30, 2022
🌄 Photo editor using native modules for iOS and Android. Inherit from 2 available libraries, Brightroom (iOS) and PhotoEditor (Android)

React Native Photo Editor (RNPE) ?? Image editor using native modules for iOS and Android. Inherit from 2 available libraries, Brightroom (iOS) and Ph

Baron Ha. 242 Dec 28, 2022
A sample app illustrating Android development using Kotlin with MVVM architecture, Android Jetpack, and other commonly used libraries.

Anime Facts A sample app illustrating Android development using Kotlin with MVVM architecture, Android Jetpack, and other commonly used libraries. Ani

Eugene Javiñas 0 Dec 5, 2021
An android application which shows usage of various jetpack libraries built by the android team

JetPacker JetPacker is an android application which implements various jetpack libraries created by the android team. FEATURES - (Will be updated as m

Ibrahim 14 Dec 9, 2022
A simple Android project using modern Android development tools and libraries.

A simple Android project using modern Android development tools and libraries.

Ahmed Sumeiry 0 Feb 3, 2022
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 27, 2022
One UI libraries for Android apps.

⚠️ W.I.P. For Wear OS, please look at seslw. This repo contains a collection of the libraries used by Samsung in their One UI apps. Samsung's One UI a

OneUI Project 66 Dec 17, 2022
some android libraries to speed up development.

emo - speed up android development This repository contains series of libraries for android developers: ui-core: Contain some basic components such as

cgspine 50 Dec 29, 2022
Movie application created with TMDB API, Architecture Components, Android Jetpack libraries

MovieApp Movie application created with TMDB API, Architecture Components, Android Jetpack libraries Built With ??️ • Kotlin - The language used in th

Ahmet Tufan 5 Sep 29, 2022
The application is developed using Modern tools/libraries with UI implementations with Navigation architecture

This is mobile application which actual users will interact with. The application is developed using Modern tools/libraries with UI implementations with Navigation architecture. It connects with the Dog API to retrieve data. more detail of api can be found here - https://dog.ceo/dog-api/documentation/random This project a basic example of Retrofit and mvvm

null 4 Feb 3, 2022
It is a NBAApp developed by Kotlin. It uses MVVM design pattern, Coroutines, Retrofit and JetPack libraries like Room, Lifecycle, ViewBinding, DataBinding, Hilt and Navigation.

NbaApp It is a NBAApp developed by Kotlin. It uses MVVM design pattern, Coroutines, Retrofit and JetPack libraries like Room, Lifecycle, ViewBinding,

Tuna Ateş Koç 2 Feb 26, 2022
An app to view libraries used in apps in your device.

An app to view libraries used in apps in your device.

Absinthe 9 Dec 24, 2022
WatchFaceAlphaKotlin - Demonstrates watch faces using the new androidX alpha libraries (Kotlin)

Alpha WatchFace Sample (Kotlin) Demonstrates watch faces using the new androidX

Bastiaan Quast 0 Jan 4, 2022
Native-loader - Safely load native libraries in Java

Native Loader ??️ Safe native loading in Java based off of the native-loader use

Mixtape 1 Oct 19, 2022
Project allowing to query products (languages, libraries, databases, etc) by their properties.

Products app This project allow to search products (mostly software products for now such as languages, libraries etc) based on their properties. For

null 1 May 1, 2022