0

I would like to remove unused resources from my final release apk file created. I am able to configure proguard but its limited to Java files only. I would like to remove unused layouts, strings, pngs etc Any ideas?

I read android link can help; got the script here: http://yltechblog.blogspot.in/2012/06/remove-unused-resource-from-android.html but i donnot know how to integrate it with gradle.

Similarly: https://code.google.com/p/android-unused-resources/; claims to help; but i am unable to figure out how to integrate it with gradle.

My gradle file is as follows

// COMMANDS::
// gradle --build-file adt_build.gradle clean  build 
// adb -e install  -r build/apk/rpsl-debug-unaligned.apk

buildscript {
    repositories {
        mavenLocal()
        maven { url 'http://repo1.maven.org/maven2' } 
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.4.2'
    }
}
apply plugin: 'android'

apply plugin: 'eclipse'

def artifactoryurl='http://10.10.8.10:8081/artifactory'
repositories {
    mavenLocal()
    maven { url 'http://repo1.maven.org/maven2' } 
    mavenCentral()
    maven {url "$artifactoryurl/jfrog-libs"}
    maven {url "$artifactoryurl/plugins-release"}
    maven {url "$artifactoryurl/libs-local"}    
}

dependencies {
    compile 'com.google.code.gson:gson:2.2.4' , 'android:support:v4', 'wavecrest.mobile.libraries:libraries:2'
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    signingConfigs {
        debugconfig {
            storeFile file("../configs/keystore.jks")
            storePassword "asdf"
            keyAlias "rpsl"
            keyPassword "asdf"
        }
    }

    buildTypes {
        debug {
            packageNameSuffix ".debug"
            signingConfig signingConfigs.debugconfig
            zipAlign true
            runProguard true
            proguardFile file('configs/proguard-android.txt')
        }

        release {
            signingConfig signingConfigs.debugconfig
            zipAlign true
            runProguard true
            proguardFile 'configs/proguard-android-optimize.txt'
        }
    }

    defaultConfig {
        versionCode 1
    }


    sourceSets {
        main {
            manifest{
                srcFile 'AndroidManifest.xml'
            }
            java {
                srcDir 'src'
            }
            res.srcDirs = ['res']
        }

        instrumentTest.setRoot('tests')
    }   

}
chendu
  • 684
  • 9
  • 21

1 Answers1

0

Lint support is not complete yet with the android gradle plugin. It is scheduled for next release.

From there, you might be able to use the lint results. In gradle to execute a script do something like 'script'.execute()

Snicolas
  • 37,840
  • 15
  • 114
  • 173
  • As a build tool i was expecting gradle to give hooks by which we can execute our custom scripts/ commands just before jar building/ signing/ packaging things... – chendu Sep 22 '13 at 14:05
  • There are some hooks, but not as fine grained to the best of my knowledge. – Snicolas Sep 22 '13 at 18:54