Gradle Plugin that removes unused resources in Android projects.
Switch branches/tags
Nothing to show
Clone or download
konifar Merge pull request #31 from kiuchikeisuke/master
add Optional usage(hook to clean project)
Latest commit b643680 Jun 13, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Fixed circle config May 6, 2018
.github/ISSUE_TEMPLATE Added issue template May 19, 2018
.idea Modified sample May 4, 2018
art Update README May 15, 2018
example-module Created test module Apr 28, 2018
example Fixed example May 15, 2018
gradle/wrapper Created project Apr 28, 2018
plugin Bump up version May 19, 2018
.gitignore Added project settings May 3, 2018
LICENSE Initial commit Apr 28, 2018 add Optional usage(hook to clean project) Jun 13, 2018
build.gradle Bump up version May 19, 2018 Modified project May 3, 2018
gradlew Created project Apr 28, 2018
gradlew.bat Created project Apr 28, 2018
settings.gradle Removed instant app May 6, 2018

Unused Resources Remover for Android


Gradle Plugin that removes unused resources in Android projects.


  • Easy to remove unused resources by simple gradle command
  • Customize extra/exclude files configuration
  • Support DataBinding & Multi module project

Simple usage


buildscript {
  repositories {
    maven { url "" }
  dependencies {
    classpath ""

NOTE: If your gradle version is 2.1 and later, you can use new snippet for plugins DSL. If you want to know more details, see plugin page.


apply plugin: "com.github.konifar.gradle.unused-resources-remover"


$ ./gradlew removeUnusedResources

Hook to Clean Project(Optional)

If you want to hook to Clean Project, add following code at the end.



Advanced usage

This plugin checks some basic resource files below.

   |  |--*.xml
   |  |--*.xml
   |  |--*.xml
   |  |--*.png
   |  |--*.jpg
   |  |--*.9.png // 9-patch
   |  |--*.xml
   |  |--*.xml
   |  |--*.xml
   |  |--*.png

If you want to check other files, you can add custom remover settings in app/build.gradle.

Here is two example.

  • fonts.xml (actually same format with strings.xml)
  • text_appearance.xml (actually same format with styles.xml)
unusedResourcesRemover { 
  extraRemovers = [
    createXmlValueRemover("fonts", "string", "string"), // fonts.xml
    createXmlValueRemover("text_appearance", "style", "style", "style") // text_appearance.xml

There are other optional configuration below

unusedResourcesRemover {
  // Write file or directory names
  excludeNames = [
    "strings.xml", // strings.xml is never checked
    "res/drawable" // drawable* dirs are never checked
  // When dryRun option is true, unused files are not removed.
  dryRun = true // default false

To know more, See UnusedResourcesRemoverExtension


This project is under development.

I'm always welcome your contribution! Feel free to report Issue or send Pull Request!

Project structure

plugin/         - The main module of Gradle plugin
example/        - An example android project that uses this plugin
example-module/ - An example module that are used in example

Download repository

$ git clone
$ cd gradle-unused-resources-remover-plugin

Edit build.gradle

dependencies {
    classpath ''
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

+//    classpath ""
-    classpath ""
    // For mavenLocal
+    classpath 'com.github.konifar.gradle:unused-resources-remover:0.3.3'
-//    classpath 'com.github.konifar.gradle:unused-resources-remover:0.3.3'

Install to local maven

$ cd plugin
$ ./../gradlew assemble install

Run example

$ cd example
$ ./../gradlew removeUnusedResources
$ > Task :example:removeUnusedResources 
$ extraRemovers:
$   fileType: font, resourceName: string, type: DEFAULT
$   fileType: text_appearance, resourceName: style, type: STYLE
$ excludeNames:
$   fonts.xml
$ dryRun: false
$ [layout] ======== Start layout checking ========
$ [layout] example
$ [layout]   Remove unused_layout.xml
$ [layout]   Complete to remove files.
$ [layout] example-module
$ [layout]   No unused layout files.
$ [layout] plugin


If this plugin helps you, I would be so happy.

I'm welcome your tip by Kyash! My account name is konifar.


Copyright 2018 Yusuke Konishi

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.