tiann / ideas

inspiration
GNU General Public License v2.0
1 stars 0 forks source link

android-resource-shrinker #10

Open tiann opened 8 years ago

tiann commented 8 years ago

used proguard to find unused class: usage.txt contains deleted files.

tiann commented 8 years ago

lint seems can not found cross-module referenced unused resource; the default proguard file of android keep all fields of R class; so we can not distinguish the unused resource correctly??

tiann commented 8 years ago

proguard to found unused class:

-dontoptimize
-dontobfuscate
-dontpreverify
-printusage
tiann commented 8 years ago

source code of shrinkResource

tiann commented 8 years ago

can not use shrinkReleaseResources directly, this task is added dynamicly, we can only access it after the gradle scripts are evaluated:

afterEvaluate { project ->
    project.tasks.shrinkReleaseResources << {
    doSomeThing()
}
tiann commented 8 years ago

we can debug gradle plugin, use remote debugger:

  1. http://stackoverflow.com/questions/11129401/debug-gradle-plugins-with-intellij
  2. http://georgik.sinusgear.com/2014/06/23/how-to-debug-gradle-script/
tiann commented 8 years ago

how to get all resource the project depends on?

tiann commented 8 years ago

get all project: project.rootProject.subprojects

and android is just a ext property of project, we can access like this:

module.extensions.findByName("android")
tiann commented 8 years ago

AndroidProguardTask

tiann commented 8 years ago

AndroidSourceSet

tiann commented 8 years ago

this has changed in Gradle 2.0 https://android.googlesource.com/platform/tools/base/+/gradle_2.0.0/build-system/gradle-core/src/main/groovy/com/android/build/gradle/internal/transforms/ShrinkResourcesTransform.java