In the new version of Android Gradle plugin, for resource a step more management, you can remove the unused resource, not only the project itself, and the library can not be used, can also be removed.
To experience this feature, the Build.gradle configuration is as follows:
Android { ... Buildtypes { Release { minifyenabled true shrinkresources true proguardfiles getdefaultproguardfile (' Proguard-android.txt '), ' Proguard-rules.pro '}} }
In order to use shrinkresources, you must first turn on minifyenabled, dependencies.
When you are finished configuring, run the View log
...: android:shrinkdebugresourcesremoved unused resources:binary resource Data reduced from 2570KB to 1711kb:removed 33%n Ote:if necessary, you can disable resource shrinking by addingandroid { Buildtypes { Debug { SHRINKRESOURC Es false } }}:android:validatedebugsigning ...
If you need to see more detail on which resource is removed, you can enter the command in Gradle commands:--info
$./gradlew Clean Assembledebug--info | grep "skipped unused resource" skipped unused resource res/anim/abc_fade_in.xml:396 bytesskipped unused resource Res/anim /abc_fade_out.xml:396 bytesskipped Unused resource res/anim/abc_slide_in_bottom.xml:400 bytesskipped unused resource res/anim/abc_slide_in_top.xml:400 bytesskipped Unused Resource res/anim/abc_slide_out_bottom.xml:400 bytesSkipped Unused resource res/anim/abc_slide_out_top.xml:400 bytesskipped unused resource res/color/rating_bar_label.xml:472 bytesskipped Unused resource res/drawable-xhdpi-v4/big.png:866901 bytesskipped unused resource res/drawable-xhdpi-v4/ ic_action_add_schedule.png:282 bytesskipped Unused resource res/drawable-xhdpi-v4/ic_action_remove_schedule.png: 368 bytesskipped Unused Resource res/drawable-xhdpi-v4/ic_livestream_pause.png:1694 bytesskipped unused resource res/ drawable-xhdpi-v4/ic_livestream_play.png:2141 bytesskipped Unused Resource res/drawable-xhdpi-v4/ic_media_route_on _holo_light.png:1594 bytesskipped Unused resource res/drawable-xxhdpi-v4/actionbar_icon.png:2002 bytesskipped unused resource res/ drawable-xxhdpi-v4/ic_action_overflow.png:330 bytesskipped Unused Resource Res/drawable-xxhdpi-v4/ic_action_play_ dark.png:331 bytesskipped Unused resource res/drawable/photo_banner_scrim.xml:620 bytesskipped unused resource res/ drawable/session_detail_photo_gradient.xml:620 bytesskipped Unused Resource Res/drawable/transparent_background_ pattern.xml:436 bytesskipped Unused resource res/layout/activity_letterboxed_when_large.xml:360 bytesSkipped unused Resource res/menu/sessions_context.xml:1088 bytesskipped Unused resource res/raw/keep.xml:262 bytesskipped unused Resource res/transition-v21/shared_element.xml:1008 bytesskipped Unused resource Res/transition-v21/window_enter_ exit.xml:108 bytes
From:http://tools.android.com/tech-docs/new-build-system/resource-shrinking
WARNING [Project:: app] to shrink resources must also enable Proguard