A Gradle Plugin that removes unused resources in Android projects.

Overview

#Lint Cleaner Plugin Maven Central Android Arsenal

Removes unused resources reported by Android lint including strings, colors and dimensions.

Depracated

As of Android Studio 2.0+ you can use Refactor -> Remove Unused Resources

ScreenShot

Usage

Apply the plugin in your build.gradle:

buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:0.12.+'
    classpath 'com.droidtitan:lint-cleaner-plugin:0.3.0'
  }
}

apply plugin: 'android'
apply plugin: 'com.droidtitan.lintcleaner'

Finally, to remove unused resources use:

gradle lintClean

Optional Configuration using DSL

lintCleaner {
    // Exclude specific files
    exclude = ['com_crashlytics_export_strings.xml','config.xml']

    // Ability to ignore all resource files. False by default. 
    ignoreResFiles = true
    
    // Default path is build/outputs/lint-results.xml
    lintXmlFilePath = 'path/to/lint-results.xml'
}
Comments
  • Getting Declaring custom 'clean' task when using the standard Gradle lifecycle plugins is not allowed. in Gradle-4.2.1

    Getting Declaring custom 'clean' task when using the standard Gradle lifecycle plugins is not allowed. in Gradle-4.2.1

    I am migrating my project to use Multi-project structure.

    My project structure

    -root
        -Project1 
        -build.gradle
        -Project2 
        -build.gradle
            -Subproject1
            -build.gradle
            -Subproject2
            -build.gradle
            -Subproject3
            -build.gradle
    

    I have written a task clean in my subproject(Subproject1/build.gradle). I want to delete the folder build in Subproject2 and Subproject3.

    But I am getting below exception message.

    FAILURE: Build failed with an exception.
    
    * Where:
    Build file 'D:\User\workspace\root\Project2\Subproject1\build.gradle' line: 12
    
    * What went wrong:
    A problem occurred evaluating project ':Project2:Subproject1'.
    > Declaring custom 'clean' task when using the standard Gradle lifecycle plugins is not allowed.
    

    Can you please suggest me how to fix this issue and reason for this error message?

    opened by richardavinash12 1
  • install on Ubuntu

    install on Ubuntu

    Hi, i'd like to install on my Ubuntu machine.

    1. clone repo
    2. inside lint-cleaner-plugin folder i write in terminal './gradle install

    in build.gradle i put

    buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:0.12.2' classpath 'com.droidtitan:lint-cleaner-plugin:0.1.0' } }

    allprojects { repositories { jcenter() } }

    it doesn't work.

    Can you help you?

    question 
    opened by giuseppesorce 1
  • Plugin auto runs after each build

    Plugin auto runs after each build

    Does it make sense to have the plugin run by default when building an Android project? Should the user instead have to manually run "gradle lintClean" in commandline. I find that I only clean projects every couple of weeks and not after every build.

    question 
    opened by marcoRS 1
  • More robust file move, was failing on some OSs

    More robust file move, was failing on some OSs

    Silent failure of the final file move on Windows was causing problems.

    Now move failures will be reported, and the move in general is more robust and succeeds where it previously failed.

    In the case where the move does fail, the temp file is deleted, other wise it leaves the project in an unbuild-able state.

    opened by Wavesonics 0
  • what?

    what?

    app/build/outputs/lint-results.xml is not a lint xml file

    BUILD SUCCESSFUL

    Total time: 38.773 secs

    This build could be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.10/userguide/gradle_daemon.html

    opened by XTaoWang 1
  •  Declaring custom 'clean' task when using the standard Gradle lifecycle plugins is not allowed.(gradle3.0)

    Declaring custom 'clean' task when using the standard Gradle lifecycle plugins is not allowed.(gradle3.0)

    build.gradle 文件内容: `// Top-level build file where you can add configuration options common to all sub-projects/modules. apply plugin: 'android' apply plugin: 'com.droidtitan.lintcleaner' buildscript { repositories { jcenter() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:2.1.3' classpath 'com.droidtitan:lint-cleaner-plugin:0.3.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
    

    }

    allprojects { repositories { jcenter() } }

    task clean(type: Delete) { delete rootProject.buildDir } ` 输入命令: gradle lintClean 报错信息: Declaring custom 'clean' task when using the standard Gradle lifecycle plugins is not allowed.

    opened by jinzw1993 1
  • Remove unused xml incorrect

    Remove unused xml incorrect

    It didn't remove the unused drawable file(.xml), but modify it and make compile failed. After run gradle lintClean, the xml resource files would be like below: anim:

    <?xml version="1.0" encoding="utf-8"?>
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:duration="1"
        android:fromXDelta="0%"
        android:fromYDelta="0%"
        android:toXDelta="0%"
        android:toYDelta="0%"
        />
    

    selector:

    <?xml version="1.0" encoding="utf-8"?>
        <item android:drawable="@drawable/btn_border_blue_normal" android:state_checked="true"/>
        <item android:drawable="@drawable/round_white"/>
    </selector>
    

    style:

    <resources>
    
        <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
            <item name="android:windowContentOverlay">@null</item>
            <item name="android:textColor">@color/text_default</item>
            <item name="android:textColorHint">@color/text_grey_light</item>
            <item name="android:actionBarStyle">@style/CustomActionBar</item>
            <item name="android:windowBackground">@null</item>
            <item name="android:activityOpenEnterAnimation">@anim/activity_open_enter</item>
            <item name="android:activityOpenExitAnimation">@anim/activity_open_exit</item>
            <item name="android:activityCloseEnterAnimation">@anim/activity_close_enter</item>
            <item name="android:activityCloseExitAnimation">@anim/activity_close_exit</item>
        </style>
    
        <!--EmptyView的样式-->
            <item name="android:layout_width">wrap_content</item>
            <item name="android:layout_height">wrap_content</item>
            <item name="android:layout_gravity">center</item>
            <item name="android:gravity">center_horizontal</item>
            <item name="android:layout_centerVertical">true</item>
            <item name="android:layout_centerInParent">true</item>
            <item name="android:visibility">gone</item>
            <item name="android:drawablePadding">@dimen/padding_common</item>
            <item name="android:textColor">@color/text_grey_light</item>
            <item name="android:paddingBottom">@dimen/height_common</item>
            <item name="android:textSize">16sp</item>
            <item name="drawableHeight">120dp</item>
            <item name="drawableWidth">120dp</item>
        </style>
    
    opened by msdx 0
  • fixed: xml drawable destoryed

    fixed: xml drawable destoryed

    Signed-off-by: Desert [email protected] Hi, marcoRS I recently found that this plugin would destroy drawables which write by xml. I checked the source code,and I found when a xml-drawable is unused the tag location is like this:

    <location file="path/to/file" line="3" column="2">

    then it will be added into the filePathToLines, so I fixed it

    opened by zyallday 0
Owner
Marco RS
Senior Android developer
Marco RS
gradle-android-scala-plugin adds scala language support to official gradle android plugin

gradle-android-scala-plugin gradle-android-scala-plugin adds scala language support to official gradle android plugin. See also sample projects at htt

saturday06 345 Dec 10, 2022
Ownership-gradle-plugin - Gradle code ownership verification plugin

Gradle code ownership verification plugin A gradle plugin that will verify owner

null 4 Dec 15, 2022
Helper to upload Gradle Android Artifacts, Gradle Java Artifacts and Gradle Kotlin Artifacts to Maven repositories (JCenter, Maven Central, Corporate staging/snapshot servers and local Maven repositories).

GradleMavenPush Helper to upload Gradle Android Artifacts, Gradle Java Artifacts and Gradle Kotlin Artifacts to Maven repositories (JCenter, Maven Cen

 Vorlonsoft LLC 21 Oct 3, 2022
Android Studio plugin which automatically generates drawable selectors from appropriately named resources.

SelectorChapek for Android This Android Studio plugin automatically generates drawable selectors from appropriately named Android resources. How to in

Inmite s.r.o. 1.6k Dec 29, 2022
Export BlueJ project archives from Gradle projects.

bluej-jar Gradle Plugin This is a Gradle plugin for producing JAR files which are valid BlueJ project archives. This plugin only works in Java project

KCL UG 5 Apr 7, 2022
An easy-to-use sbt plugin for working with all Android projects

Build Android Projects Using SBT http://scala-android.org/ Change log | FAQ Auto-import from gradle using sbt-android-gradle NOTE: 1.6.0 is the last v

Scala on Android 749 Nov 20, 2022
A Leiningen plugin for building Clojure/Android projects

lein-droid A Leiningen plugin to simplify Clojure development for Android platform. It acts as a build-tool for Clojure/Android projects. Usage First

Clojure/Android 643 Dec 15, 2022
Jetbrains plugin for differentiating opened projects by color!

?? ?? Project-Color ?? ?? Remember your projects by color! Colorize the title bar to differentiate your open projects. Working on multiple projects si

yon 25 Dec 16, 2022
GPP is Android's unofficial release automation Gradle Plugin. It can do anything from building, uploading, and then promoting your App Bundle or APK to publishing app listings and other metadata.

Gradle Play Publisher Gradle Play Publisher is Android's unofficial release automation Gradle Plugin. It can do anything from building, uploading, and

null 3.9k Dec 30, 2022
Gradle plugin which downloads and manages your Android SDK.

DEPRECATED This plugin is deprecated and is no longer being developed. Tools and dependencies are automatically downloaded using version 2.2.0 of the

Jake Wharton 1.4k Dec 29, 2022
A Gradle plugin to support the Groovy language for building Android apps

Groovy language support for Android Deprecated: This plugin has been deprecated in favor of Kotlin which has the full support of JetBrains and Google.

Groovy programming language 853 Dec 21, 2022
Add a different ribbon to each of your Android app variants using this gradle plugin. Of course, configure it as you will

Easylauncher gradle plugin for Android Modify the launcher icon of each of your app-variants using simple gradle rules. Add ribbons of any color, over

Mikel 960 Dec 18, 2022
Gradle plugin which helps you analyze the size of your Android apps.

Ruler Ruler is a Gradle plugin which helps you analyze the size of your Android apps. Motivation App size is an important metric which directly correl

Spotify 913 Dec 28, 2022
A Gradle plugin for providing your secrets to your Android project.

Secrets Gradle Plugin for Android A Gradle plugin for providing your secrets securely to your Android project. This Gradle plugin reads secrets from a

Google 560 Jan 8, 2023
A powerful Gradle Plugin to help you demonstrate your android app

English | 简体中文 sample-gradle-plugin ?? A powerful Gradle Plugin to help you demonstrate your android app. We often write demo applications that contai

Yoo Zhou 12 Nov 5, 2022
A Gradle plugin to report the number of method references in your APK on every build.

Dexcount Gradle Plugin A Gradle plugin to report the number of method references in your APK, AAR, or java module. This helps you keep tabs on the gro

Keepsafe 3k Dec 29, 2022
Gradle plugin for Google Protocol Buffers

Gradle Protobuf Plugin Author: Andrew Kroh Download: See maven central License: Apache License, Version 2.0 Requirements: Java 1.5+ Google Protocol Bu

Andrew Kroh 36 May 29, 2022
Gradle plugin which validates the licenses of your dependency graph match what you expect

Licensee ?? ?? A Gradle plugin which validates the licenses of your dependency graph match what you expect, or it fails your build! Jump to: Introduct

Cash App 506 Jan 8, 2023