Status Update
Comments
za...@gmail.com <za...@gmail.com> #2
can you share your android studio version
tn...@google.com <tn...@google.com> #3
Is this happening with Studio 3.0?
ba...@gmail.com <ba...@gmail.com> #4
Note: This worked for me on Windows 7 Pro 32-bit (with Android Studio 2.3.3). Seems like an issue with adt-branding module (which should contain the "/idea/AndroidStudioApplicationInfo.xml" resource).
vi...@gmail.com <vi...@gmail.com> #5
Hi, also happened on Mac Book Pro 15 retina mi-2015
MacOs Sierra 10.12.6
Android Studio 2.3.3
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)
MacOs Sierra 10.12.6
Android Studio 2.3.3
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)
tn...@google.com <tn...@google.com> #6
Thank you for this feedback. Your feedback helps make sure Android development tools are great! Given your issues has been resolved I am closing this issue.
al...@gmail.com <al...@gmail.com> #7
To illustrate on an Android Wear project (there is an apk embedded in an apk):
Gradle 1.0.0-rc1
----------------
:wear:shrinkFullReleaseResources
Removed unused resources: Binary resource data reduced from 1014KB to 707KB: Removed 30%
[...]
:mobile:shrinkFullReleaseResources
Removed unused resources: Binary resource data reduced from 1528KB to 1221KB: Removed 20%
1.37MB is the size of the final apk.
Gradle 0.14.2
-------------
:wear:shrinkFullReleaseResources
Removed unused resources: Binary resource data reduced from 1014KB to 465KB: Removed 54%
[...]
:mobile:shrinkFullReleaseResources
Removed unused resources: Binary resource data reduced from 1286KB to 725KB: Removed 43%
917KB is the size of the final apk.
Gradle 1.0.0-rc1
----------------
:wear:shrinkFullReleaseResources
Removed unused resources: Binary resource data reduced from 1014KB to 707KB: Removed 30%
[...]
:mobile:shrinkFullReleaseResources
Removed unused resources: Binary resource data reduced from 1528KB to 1221KB: Removed 20%
1.37MB is the size of the final apk.
Gradle 0.14.2
-------------
:wear:shrinkFullReleaseResources
Removed unused resources: Binary resource data reduced from 1014KB to 465KB: Removed 54%
[...]
:mobile:shrinkFullReleaseResources
Removed unused resources: Binary resource data reduced from 1286KB to 725KB: Removed 43%
917KB is the size of the final apk.
va...@gmail.com <va...@gmail.com> #8
+tnor How can i use these options :
(1) shrinkMode="strict" to turn off keep-guessing, and/or
(2) tools:discard to explicitly throw away resources that the resource shrinker decided to keep
Setting it in the build.gradle debug buildTypes gives method not found error.
(1) shrinkMode="strict" to turn off keep-guessing, and/or
(2) tools:discard to explicitly throw away resources that the resource shrinker decided to keep
Setting it in the build.gradle debug buildTypes gives method not found error.
de...@gmail.com <de...@gmail.com> #9
Looking forward to testing fix in https://android-review.googlesource.com/116464 as all my resources are being kept by an unrelated string.format pattern in my projects.
Any idea when the next planned plugin update will be available to test this?
Any idea when the next planned plugin update will be available to test this?
de...@gmail.com <de...@gmail.com> #10
Aggressive mode as mentioned with keep option like proguard would be nice.
tn...@google.com <tn...@google.com> #11
Both of the above CL have been integrated and will be part of 1.0-rc2. It's Thanksgivings Holiday in the US this week but I think we hope to release an update to the plugin next week (no promises etc etc.)
de...@gmail.com <de...@gmail.com> #12
Ok great, look forward to it. Happy holidays ☺
vi...@gmail.com <vi...@gmail.com> #13
Happy holiday,Look forward to it too.
tn...@google.com <tn...@google.com> #14
Android Gradle plugin 1.0.0-rc2 is available now if you want to try this (see comment #3 ). Let me know if there are any problems!
za...@gmail.com <za...@gmail.com> #15
Tried out rc2 with strict enabled, but still doesn't remove as much as it did at initial release (0.14.0).
Regular APK size: 7.9MB
0.14.0: 6.0MB
1.0.0-rc2: 7.3MB
Going to dig into the debug logs now though
Regular APK size: 7.9MB
0.14.0: 6.0MB
1.0.0-rc2: 7.3MB
Going to dig into the debug logs now though
za...@gmail.com <za...@gmail.com> #16
EDIT: I misremembered, regular APK size is actually 7.9MB, so RC-2 with strict enabled still doesn't actually shrink anything :(
za...@gmail.com <za...@gmail.com> #17
*is actually 7.3MB. It would really be nice if we could edit our comments
vi...@gmail.com <vi...@gmail.com> #18
[Comment deleted]
vi...@gmail.com <vi...@gmail.com> #19
[Comment deleted]
vi...@gmail.com <vi...@gmail.com> #20
[Comment deleted]
vi...@gmail.com <vi...@gmail.com> #21
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools "
tools:shrinkMode="strict"
tools:discard="@drawable/unused_resource_test_shrinkenable1"/>
shrinkMode="strict" has no affect on my project,discard work well.
<resources xmlns:tools="
tools:shrinkMode="strict"
tools:discard="@drawable/unused_resource_test_shrinkenable1"/>
shrinkMode="strict" has no affect on my project,discard work well.
za...@gmail.com <za...@gmail.com> #22
Discard does work, but unfortunately doesn't help with shrinking library resources (which is where most of these resources come from for us)
tn...@google.com <tn...@google.com> #23
+visa8000: Can you run Gradlew with the --debug flag and grep for unused_resource_test_shrinkenable1 ?
With --debug, the build plugin should dump out the dependency graph, so search for "Resource Reference Graph".
For example, let's say I want to know why @drawable/ic_plus_anim_016 is still in my APK:
$ cat /tmp/build-output.txt | grep drawable/ic_plus_anim_016 | grep reachable
16:25:48.052 [QUIET] [system.out] @drawable/ic_plus_anim_016 : reachable=true
In the build output resource reference graph, I find that it's referenced from a different resource:
16:25:48.005 [QUIET] [system.out] @drawable/add_schedule_fab_icon_anim : reachable=true
16:25:48.009 [QUIET] [system.out] @drawable/ic_plus_anim_016
Therefore, I now need to know why @drawable/add_schedule_fab_icon_anim is reachable -- and if I search upwards I find that that resource is listed under "The root reachable resources are:". This means that there was a code reference to add_schedule_fab_icon_anim (e.g. its R.drawable id was found in the reachable code.).
With --debug, the build plugin should dump out the dependency graph, so search for "Resource Reference Graph".
For example, let's say I want to know why @drawable/ic_plus_anim_016 is still in my APK:
$ cat /tmp/build-output.txt | grep drawable/ic_plus_anim_016 | grep reachable
16:25:48.052 [QUIET] [system.out] @drawable/ic_plus_anim_016 : reachable=true
In the build output resource reference graph, I find that it's referenced from a different resource:
16:25:48.005 [QUIET] [system.out] @drawable/add_schedule_fab_icon_anim : reachable=true
16:25:48.009 [QUIET] [system.out] @drawable/ic_plus_anim_016
Therefore, I now need to know why @drawable/add_schedule_fab_icon_anim is reachable -- and if I search upwards I find that that resource is listed under "The root reachable resources are:". This means that there was a code reference to add_schedule_fab_icon_anim (e.g. its R.drawable id was found in the reachable code.).
tn...@google.com <tn...@google.com> #24
For those of you who can successfully shrink with both 0.14.0 and 1.0.0-rc2, and you saw greater savings with 0.14.0, can you try to figure out which resources were shrunk with 0.14.0 and not with 1.0.0-rc2?
e.g. with --debug output from both, look for the string "reachable" (and chop off the gradle log timestamps since they will ruin the diffs) :
$ cat /tmp/build-output-0.14.txt | grep reachable | awk '{ print substr($0, 35) }' > /tmp/before.txt
$ cat /tmp/build-output-1.0.txt | grep reachable | awk '{ print substr($0, 35) }' > /tmp/after.txt
Then diff the two:
$ diff /tmp/before.txt /tmp/after.txt
543,545c543,545
< @drawable/abc_btn_check_material : reachable=false
< @drawable/abc_btn_check_to_on_mtrl_000 : reachable=false
< @drawable/abc_btn_check_to_on_mtrl_015 : reachable=false
---
> @drawable/abc_btn_check_material : reachable=true
> @drawable/abc_btn_check_to_on_mtrl_000 : reachable=true
> @drawable/abc_btn_check_to_on_mtrl_015 : reachable=true
In this made up example we can see that these three resources are no longer removed; now I can use the method described in the previous comment to figure out why the latest version of the plugin considers these resources to not be eligible for removal.
e.g. with --debug output from both, look for the string "reachable" (and chop off the gradle log timestamps since they will ruin the diffs) :
$ cat /tmp/build-output-0.14.txt | grep reachable | awk '{ print substr($0, 35) }' > /tmp/before.txt
$ cat /tmp/build-output-1.0.txt | grep reachable | awk '{ print substr($0, 35) }' > /tmp/after.txt
Then diff the two:
$ diff /tmp/before.txt /tmp/after.txt
543,545c543,545
< @drawable/abc_btn_check_material : reachable=false
< @drawable/abc_btn_check_to_on_mtrl_000 : reachable=false
< @drawable/abc_btn_check_to_on_mtrl_015 : reachable=false
---
> @drawable/abc_btn_check_material : reachable=true
> @drawable/abc_btn_check_to_on_mtrl_000 : reachable=true
> @drawable/abc_btn_check_to_on_mtrl_015 : reachable=true
In this made up example we can see that these three resources are no longer removed; now I can use the method described in the previous comment to figure out why the latest version of the plugin considers these resources to not be eligible for removal.
vi...@gmail.com <vi...@gmail.com> #26
C:\Users\visa>grep drawable/unused_resource_test_shrinkenable1 E:\project_studio\android\project\build-output.txt
@drawable/unused_resource_test_shrinkenable1 : reachable=true
C:\Users\visa>
we can see that unused_resource_test_shrinkenable1 is "reachable=true",but there was no code reference to unused_resource_test_shrinkenable1
@drawable/unused_resource_test_shrinkenable1 : reachable=true
C:\Users\visa>
we can see that unused_resource_test_shrinkenable1 is "reachable=true",but there was no code reference to unused_resource_test_shrinkenable1
tn...@google.com <tn...@google.com> #27
+visa8000: try grepping for *just* unused_resource_test_shrinkenable1 (not with drawable/ as a prefix) - I wonder if there are other shrink-related messages for that resource
vi...@gmail.com <vi...@gmail.com> #28
C:\Users\visa>grep unused_resource_test_shrinkenable2 E:\project_studio\
android\project\build-output.txt
11:39:48.819 [INFO] [org.gradle.api.Project] command: D:\androidsdk_studio\build
-tools\21.1.1\aapt.exe s -i E:\project_studio\android\project\res\drawable-h
dpi\unused_resource_test_shrinkenable2.png -o E:\project_studio\android\project\build\intermediates\res\release\drawable-hdpi-v4\unused_resource_test_shrink
enable2.png
11:39:48.837 [INFO] [org.gradle.api.Project] Crunching single PNG file: E:\proje
ct_studio\android\project\res\drawable-hdpi\unused_resource_test_shrinkenabl
e2.png
11:39:48.837 [INFO] [org.gradle.api.Project] Output file: E:\project_studi
o\android\project\build\intermediates\res\release\drawable-hdpi-v4\unused_resou
rce_test_shrinkenable2.png
drawable:unused_resource_test_shrinkenable2:2130839231,
@drawable/unused_resource_test_shrinkenable2 : reachable=true
11:43:36.464 [DEBUG] [org.gradle.api.Project] => res/drawable-hdpi-v4/unused_res
ource_test_shrinkenable2.png
C:\Users\visa>
android\project\build-output.txt
11:39:48.819 [INFO] [org.gradle.api.Project] command: D:\androidsdk_studio\build
-tools\21.1.1\aapt.exe s -i E:\project_studio\android\project\res\drawable-h
dpi\unused_resource_test_shrinkenable2.png -o E:\project_studio\android\project\build\intermediates\res\release\drawable-hdpi-v4\unused_resource_test_shrink
enable2.png
11:39:48.837 [INFO] [org.gradle.api.Project] Crunching single PNG file: E:\proje
ct_studio\android\project\res\drawable-hdpi\unused_resource_test_shrinkenabl
e2.png
11:39:48.837 [INFO] [org.gradle.api.Project] Output file: E:\project_studi
o\android\project\build\intermediates\res\release\drawable-hdpi-v4\unused_resou
rce_test_shrinkenable2.png
drawable:unused_resource_test_shrinkenable2:2130839231,
@drawable/unused_resource_test_shrinkenable2 : reachable=true
11:43:36.464 [DEBUG] [org.gradle.api.Project] => res/drawable-hdpi-v4/unused_res
ource_test_shrinkenable2.png
C:\Users\visa>
tn...@google.com <tn...@google.com> #29
I'm guessing the line
drawable:unused_resource_test_shrinkenable2:2130839231
was under the root set of reachable resources. That means hat the literal constant 2130839231 was referenced somewhere in the code. Note that when the code is compiled (in a non library especially), field access likeR.type.name is replaced by the literal value of the resource, in this case R.drawable.unused_resource_test_shrinkenable2 is replaced by the integer 2130839231.
When the resource shrinker sees the literal integer 2130839231 is uses this to mark the corresponding resource as potentially used. It can't analyze the code to figure if the given integer eventually winds up getting used for resource lookup. Given that aapt uses a number of bits in the high range luckily the resource id's are usually unique in an app; they don't tend to alias other non-resource-data. But it's possible that by blind luck this resource happened to have the same id as some other data in your app, or that your app for various reasons contains a lot of integer data?
drawable:unused_resource_test_shrinkenable2:2130839231
was under the root set of reachable resources. That means hat the literal constant 2130839231 was referenced somewhere in the code. Note that when the code is compiled (in a non library especially), field access like
When the resource shrinker sees the literal integer 2130839231 is uses this to mark the corresponding resource as potentially used. It can't analyze the code to figure if the given integer eventually winds up getting used for resource lookup. Given that aapt uses a number of bits in the high range luckily the resource id's are usually unique in an app; they don't tend to alias other non-resource-data. But it's possible that by blind luck this resource happened to have the same id as some other data in your app, or that your app for various reasons contains a lot of integer data?
vi...@gmail.com <vi...@gmail.com> #30
when I use 0.14.2,the output is below,but the apk size reduce:
E:\project_studio\android\project>grep unused_resource_test_shrinkenable2 E:
\project_studio\android\project\build-output.txt
10:22:29.242 [INFO] [org.gradle.api.Project] command: D:\androidsdk_studio\build
-tools\21.1.1\aapt.exe s -i E:\project_studio\android\project\res\drawable-h
dpi\unused_resource_test_shrinkenable2.png -o E:\project_studio\android\Baidu
Map\build\intermediates\res\release\drawable-hdpi-v4\unused_resource_test_shrink
enable2.png
10:22:29.265 [INFO] [org.gradle.api.Project] Crunching single PNG file: E:\proje
ct_studio\android\project\res\drawable-hdpi\unused_resource_test_shrinkenabl
e2.png
10:22:29.265 [INFO] [org.gradle.api.Project] Output file: E:\project_studi
o\android\project\build\intermediates\res\release\drawable-hdpi-v4\unused_resou
rce_test_shrinkenable2.png
10:27:28.310 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %d
10:27:30.286 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %f
10:27:32.268 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %s
10:27:34.689 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %s%s
10:27:37.585 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %c%c
%c%d
10:27:39.660 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %d%s
10:27:41.679 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %d_%
d
10:27:44.088 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %s%s
%s%s
10:27:45.894 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %s_%
s_%s
10:27:47.515 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %2A
10:27:50.447 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %.0f
%s
10:27:53.599 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %.1f
%s
10:27:56.053 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %02d
10:27:58.168 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %s_%
s
10:28:00.342 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %.2f
10:28:02.235 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %.0f
10:28:04.297 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %.1f
10:28:06.185 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %.7f
drawable:unused_resource_test_shrinkenable2:2130839231,
@drawable/unused_resource_test_shrinkenable2 : reachable=true
10:28:18.383 [DEBUG] [org.gradle.api.Project] => res/drawable-hdpi-v4/unused_res
ource_test_shrinkenable2.png
E:\project_studio\android\project>
E:\project_studio\android\project>grep unused_resource_test_shrinkenable2 E:
\project_studio\android\project\build-output.txt
10:22:29.242 [INFO] [org.gradle.api.Project] command: D:\androidsdk_studio\build
-tools\21.1.1\aapt.exe s -i E:\project_studio\android\project\res\drawable-h
dpi\unused_resource_test_shrinkenable2.png -o E:\project_studio\android\Baidu
Map\build\intermediates\res\release\drawable-hdpi-v4\unused_resource_test_shrink
enable2.png
10:22:29.265 [INFO] [org.gradle.api.Project] Crunching single PNG file: E:\proje
ct_studio\android\project\res\drawable-hdpi\unused_resource_test_shrinkenabl
e2.png
10:22:29.265 [INFO] [org.gradle.api.Project] Output file: E:\project_studi
o\android\project\build\intermediates\res\release\drawable-hdpi-v4\unused_resou
rce_test_shrinkenable2.png
10:27:28.310 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %d
10:27:30.286 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %f
10:27:32.268 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %s
10:27:34.689 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %s%s
10:27:37.585 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %c%c
%c%d
10:27:39.660 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %d%s
10:27:41.679 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %d_%
d
10:27:44.088 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %s%s
%s%s
10:27:45.894 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %s_%
s_%s
10:27:47.515 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %2A
10:27:50.447 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %.0f
%s
10:27:53.599 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %.1f
%s
10:27:56.053 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %02d
10:27:58.168 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %s_%
s
10:28:00.342 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %.2f
10:28:02.235 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %.0f
10:28:04.297 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %.1f
10:28:06.185 [QUIET] [system.out] Marking drawable:unused_resource_test_shrinken
able2:2130839231 used because it format-string matches string pool constant %.7f
drawable:unused_resource_test_shrinkenable2:2130839231,
@drawable/unused_resource_test_shrinkenable2 : reachable=true
10:28:18.383 [DEBUG] [org.gradle.api.Project] => res/drawable-hdpi-v4/unused_res
ource_test_shrinkenable2.png
E:\project_studio\android\project>
vi...@gmail.com <vi...@gmail.com> #31
+Tor Norbye I have search the whole project,2130839231=0x7f0206bf,the value is only exist in my R.java
vi...@gmail.com <vi...@gmail.com> #32
and unused_resource_test_shrinkenable2 is only exist in my R.java too.
tn...@google.com <tn...@google.com> #33
How did you search? It's not a matter of appearing as an integer literal in your source code. It's whether that constant appear in any of the .class files, including within any libraries you are using - and it can for example appear as an annotation constant (in any earlier version of the resource shrinker it did not properly keep resources that were only referenced via annotations, e.g. @Layout(R.layout.used17).
za...@gmail.com <za...@gmail.com> #34
@tor I have a diff for you as well, but would prefer not to post it here. Can I email it to you?
tn...@google.com <tn...@google.com> #35
Yes -- just send it to tnorbye@google.com. But honestly there's not much I can do with that diff: to find out what the problem is, we need to identify some resources that were marked as reachable=false in 0.14.x, and are now marked as reachable=true in 1.0.0-rc, and which you don't think should be reachable, and then look at the build output to see why it's marked reachable. If it turns out to be the same case as for visa8000 (where these resources are marked as reachable from code) I may have to add some more logging where code references will log the corresponding .class and .jar file the resources are coming from.
tn...@google.com <tn...@google.com> #36
I added some preliminary logging of the bytecode visitor and I'm seeing that these fields are all somehow preserved in the proguard output classes:
Marking attr:actionBarDivider:2130772110 reachable: referenced from field in /my/build/intermediates/classes-proguard/debug/classes.jar:android/support/v7/appcompat/R$attr.class
.... etc
I don't know why that would have changed recently. I'll need to look at the proguard output files and compare them with 0.14.x.
Marking attr:actionBarDivider:2130772110 reachable: referenced from field in /my/build/intermediates/classes-proguard/debug/classes.jar:android/support/v7/appcompat/R$attr.class
.... etc
I don't know why that would have changed recently. I'll need to look at the proguard output files and compare them with 0.14.x.
va...@gmail.com <va...@gmail.com> #37
Using tools:shrinkMode="strict" removed some drawables which were used.
Drawables are accessed using URI which is constructed string-array.
String[] fileList = getResources().getStringArray(R.array.clip_art_thumnail);
InputStream inStream = mgr.open(filePath);
Bitmap src = BitmapFactory.decodeStream(inStream);
Now all the resources mentioned in the list are not present in the apk.
So do i have to protect all resources using tools:keep ?
Drawables are accessed using URI which is constructed string-array.
String[] fileList = getResources().getStringArray(R.array.clip_art_thumnail);
InputStream inStream = mgr.open(filePath);
Bitmap src = BitmapFactory.decodeStream(inStream);
Now all the resources mentioned in the list are not present in the apk.
So do i have to protect all resources using tools:keep ?
tn...@google.com <tn...@google.com> #38
+vahbiav01: Yes, that's precisely what tools:shrinkMode="strict" means; it means that you'll need to manually keep resources that are dynamically loaded, similar to how with ProGuard you'll need to write manual keep rules.
tn...@google.com <tn...@google.com> #39
By the way, I've written up a document with some of this information such that you don't have to go hunting through bug comments to find the relevant info:
http://tools.android.com/tech-docs/new-build-system/resource-shrinking
tn...@google.com <tn...@google.com> #40
Ok I've found the problem. From the commit message in https://android-review.googlesource.com/118100 :
For some reason, recent versions of the Gradle plugin (or ProGuard)
ends up with all the R$type classes from libraries in the final ProGuard
output.
The resource shrink bytecode visitor would visit all the field values
in these R classes and therefore find all the resources and treat them
as used. This meant a lot of resources that were otherwise eligible for
resource shrinking would not be removed.
This CL fixes that by deliberately skipping R$type classes from the
bytecode visitor.
It also adds more logging (for the --debug flag) such that developers
can track down which class is referencing a given resource id that
they believe should be unused.
With this fix, I see that more resources from appcompat becomes eligible for removal.
One important note though: In the first couple of versions of the resource shrinker (e.g. versions 0.14.0 and 0.14.1, and maybe 0.14.2) the resource shrinker would compress raw resources. That's wrong; it shouldn't do that. It did lead to a smaller APK file of course -- but it can lead to runtime crashes. So if you're using 0.14.0 and noticing that you got larger "gains" with the resource shrinker then, *that* part won't be the case for new versions of the resource shrinker. But it *should* help with shrinking resources from libraries.
For some reason, recent versions of the Gradle plugin (or ProGuard)
ends up with all the R$type classes from libraries in the final ProGuard
output.
The resource shrink bytecode visitor would visit all the field values
in these R classes and therefore find all the resources and treat them
as used. This meant a lot of resources that were otherwise eligible for
resource shrinking would not be removed.
This CL fixes that by deliberately skipping R$type classes from the
bytecode visitor.
It also adds more logging (for the --debug flag) such that developers
can track down which class is referencing a given resource id that
they believe should be unused.
With this fix, I see that more resources from appcompat becomes eligible for removal.
One important note though: In the first couple of versions of the resource shrinker (e.g. versions 0.14.0 and 0.14.1, and maybe 0.14.2) the resource shrinker would compress raw resources. That's wrong; it shouldn't do that. It did lead to a smaller APK file of course -- but it can lead to runtime crashes. So if you're using 0.14.0 and noticing that you got larger "gains" with the resource shrinker then, *that* part won't be the case for new versions of the resource shrinker. But it *should* help with shrinking resources from libraries.
vi...@gmail.com <vi...@gmail.com> #41
+Tor Norbye
I have found some problems when package apk using gradle and ant
I have found some problems when package apk using gradle and ant
ku...@gmail.com <ku...@gmail.com> #42
as suggested on http://tools.android.com/tech-docs/new-build-system/resource shrinking i added a keep xml to my res/raw folder. but for that file Android Studio (RC4) complains "URI not registred (Settings | Project Settings | Schemas and DTDs)" for the xmlns:tools="http://schemas.android.com/tools " part. i tried to add that scheme as external but it wants an xsd. also ignoring does not work as Android Studio then complains "Cannot find the declaration of element 'resrouces'.".
Any Idea how to fix that?
Another Problem:
I have set tools:shrinkMode to strict but only get a data reduction from 2686KB to 2685KB.
the only resources that got removed are some anims of actionbarcompat and the raw/keep xml file... shouldn't there be much more that gets removed?
19:47:10.540 [QUIET] [system.out] Skipped unused resource res/anim/abc_fade_in.xml: 396 bytes
19:47:10.540 [QUIET] [system.out] Skipped unused resource res/anim/abc_fade_out.xml: 396 bytes
19:47:10.540 [QUIET] [system.out] Skipped unused resource res/anim/abc_slide_in_bottom.xml: 400 bytes
19:47:10.540 [QUIET] [system.out] Skipped unused resource res/anim/abc_slide_in_top.xml: 400 bytes
19:47:10.540 [QUIET] [system.out] Skipped unused resource res/anim/abc_slide_out_bottom.xml: 400 bytes
19:47:10.541 [QUIET] [system.out] Skipped unused resource res/anim/abc_slide_out_top.xml: 400 bytes
19:47:10.619 [QUIET] [system.out] Skipped unused resource res/raw/keep.xml: 293 bytes
19:47:10.681 [QUIET] [system.out] Removed unused resources: Binary resource data reduced from 2686KB to 2685KB: Removed 0%
Any Idea how to fix that?
Another Problem:
I have set tools:shrinkMode to strict but only get a data reduction from 2686KB to 2685KB.
the only resources that got removed are some anims of actionbarcompat and the raw/keep xml file... shouldn't there be much more that gets removed?
19:47:10.540 [QUIET] [system.out] Skipped unused resource res/anim/abc_fade_in.xml: 396 bytes
19:47:10.540 [QUIET] [system.out] Skipped unused resource res/anim/abc_fade_out.xml: 396 bytes
19:47:10.540 [QUIET] [system.out] Skipped unused resource res/anim/abc_slide_in_bottom.xml: 400 bytes
19:47:10.540 [QUIET] [system.out] Skipped unused resource res/anim/abc_slide_in_top.xml: 400 bytes
19:47:10.540 [QUIET] [system.out] Skipped unused resource res/anim/abc_slide_out_bottom.xml: 400 bytes
19:47:10.541 [QUIET] [system.out] Skipped unused resource res/anim/abc_slide_out_top.xml: 400 bytes
19:47:10.619 [QUIET] [system.out] Skipped unused resource res/raw/keep.xml: 293 bytes
19:47:10.681 [QUIET] [system.out] Removed unused resources: Binary resource data reduced from 2686KB to 2685KB: Removed 0%
to...@gmail.com <to...@gmail.com> #43
Is it possible to use different shrink modes for libraries and for my own code? For example, it would be nice to be able to use shrinkMode="strict" for my own code so that calls that I make to getIdentifier are ignored, but still use shrinkMode="safe" for third party libraries since I don't really know how they use their resources.
za...@gmail.com <za...@gmail.com> #44
Did your fix go out in the 1.0.0 release? We still only get 1% shrinkage, compared to much more on 0.14.0
tn...@google.com <tn...@google.com> #45
No, it has not been integrated yet. Xav just agreed to have it in 1.0.1 :-)
tn...@google.com <tn...@google.com> #46
(Apparently we upgraded to a more recent version of ProGuard in one of the 1.0 RC builds; that can explain why there was a change in the .class files including these resource integers)
tn...@google.com <tn...@google.com> #47
(Note also that 0.14.0 accidentally compressed the raw resources; that (depending on how large raw resources oyu have) could give you a pretty huge space savings that we can't actually do, since compressing raw resources breaks runtime behavior.)
za...@gmail.com <za...@gmail.com> #48
Yeah just looking at our output, it seems like a large chunk of the unused resources came from appcompat. Do you guys have a roadmap for one 1.0.1 will be released?
za...@gmail.com <za...@gmail.com> #49
Did this finally make it in the 1.1.0 release? Just tried it again and we only get ~2% shrinkage as compared to substantially more than before (as in, it seems like it's missing more than just the raw resource images).
tn...@google.com <tn...@google.com> #50
Yes, this *did* go in. I guess there must be something else which is triggering the resources to be kept in your case.
dr...@gmail.com <dr...@gmail.com> #51
Also confirmed that shrinking is still not working properly on 1.1.0.
tn...@google.com <tn...@google.com> #52
I need a bit more detail than "not working properly". Can you find out which resource you expected to be shrunk, that is still in the stripped APK? The logging information in http://tools.android.com/tech-docs/new-build-system/resource-shrinking should be helpful.
ka...@gmail.com <ka...@gmail.com> #53
Not good
er...@gmail.com <er...@gmail.com> #54
I get a 2+ MB difference in an application when built using 1.0+ version of the build-tools. The size when built with 0.14.2 is about 3 MB. The content in the two apk's is the same. When I check the files with zipinfo it tells me that some of the files in the apk built with 1.1.2 aren't compressed while it seems it is with 0.14.2.
$ zipinfo myapp-release-0.14.2.apk resources.arsc
-rw---- 2.0 fat 1602648 bl defN 5-Mar-15 10:20 resources.arsc
$ zipinfo myapp-release-1.1.2.apk resources.arsc
-rw---- 1.0 fat 1602648 b- stor 5-Mar-15 15:56 resources.arsc
This happens to resources.arsc and some of the drawables.
$ zipinfo myapp-release-0.14.2.apk resources.arsc
-rw---- 2.0 fat 1602648 bl defN 5-Mar-15 10:20 resources.arsc
$ zipinfo myapp-release-1.1.2.apk resources.arsc
-rw---- 1.0 fat 1602648 b- stor 5-Mar-15 15:56 resources.arsc
This happens to resources.arsc and some of the drawables.
xa...@android.com <xa...@android.com> #55
resource.arsc should not be deflated, so that it can be memory mapped on the device instead of extracted (resulting in actually larger storage on the device).
if 0.14.2 deflated it, it was a bug.
if 0.14.2 deflated it, it was a bug.
an...@gmail.com <an...@gmail.com> #56
In latest gradle plugin (and AS 1.2), I found out a scenario where resources are not removed, while obviously no longer being used:
Let's assume we have an .xml file for a preference named pref.xml, this pref.xml is loaded from code conditionally (with a final boolean Build.INCLUDE_FLAG) based on variant and refers to a number of string resources.
In the variant that does not load pref.xml, the file pref.xml is removed as expected. However the strings it refers to, are not, even though they are not used anywhere else!
For my projects, this would mean another 20% resource shrinking which doesn't occur at the moment. Would be nice to have that handled in the future.
Let's assume we have an .xml file for a preference named pref.xml, this pref.xml is loaded from code conditionally (with a final boolean Build.INCLUDE_FLAG) based on variant and refers to a number of string resources.
In the variant that does not load pref.xml, the file pref.xml is removed as expected. However the strings it refers to, are not, even though they are not used anywhere else!
For my projects, this would mean another 20% resource shrinking which doesn't occur at the moment. Would be nice to have that handled in the future.
an...@gmail.com <an...@gmail.com> #57
Forgot to mention I'm using strict mode. It appears that resources that reference other resources, when removed do not also remove referred-to resources when possible.
sv...@gmail.com <sv...@gmail.com> #58
1
tn...@google.com <tn...@google.com> #59
I've just checked in a bunch of fixes related to resource shrinking.
Two of these could be the root causes for the various problems people have listed in this issue. With these fixes, I'm going to mark this issue as fixed; if there are remaining problems, pleas file new bugs, preferably with detailed instructions to reproduce. (Note that as of 2.0 alpha 4 there is a "resources.txt" file in the proguard output directory listing diagnostic details of the resource shrinker.)
Here are details from the commit message for two of the problems that could have explained why some resources weren't deleted as expected:
First, it was not correctly skipping field referenced to resources
when it encountered an obfuscated library class (such as appcompat's
own R$string file). This meant that many appcompat resources were
incorrectly marked as used by the app.
Second, when the resource shrinker sees a call to
Resources#getIdentifier (which is a method which lets you look up
resources by dynamically computed resource names), it reverts to a
safe mode where it plays it safe and for example marks any resource
whose name is a match for any constant in the string pool as possibly
being used.
Unfortunately, appcompat, used in nearly all apps created from Android
Studio, has a couple of usages of Resources#getIdentifier, which means
that nearly all apps end up in safe mode, where many resources are
incorrectly kept just to be on the safe side. However, it turns out
that these two usages are benign and not typically used to look up
resources in a reflective way.
Therefore, the resource shrinker now keeps track of the obfuscated
names of the classes for these two resource lookup calls, and when it
comes across a Resources#getIdentifier() call it ignores it if it's
one of these "benign" usages.
Issue id's for problems related to resource shrinker that were fixed in 2.0 alpha 4:
* issue 36949180
* issue 36949180
* issue 36949180
* issue 36949180
* issue 36949180
Two of these could be the root causes for the various problems people have listed in this issue. With these fixes, I'm going to mark this issue as fixed; if there are remaining problems, pleas file new bugs, preferably with detailed instructions to reproduce. (Note that as of 2.0 alpha 4 there is a "resources.txt" file in the proguard output directory listing diagnostic details of the resource shrinker.)
Here are details from the commit message for two of the problems that could have explained why some resources weren't deleted as expected:
First, it was not correctly skipping field referenced to resources
when it encountered an obfuscated library class (such as appcompat's
own R$string file). This meant that many appcompat resources were
incorrectly marked as used by the app.
Second, when the resource shrinker sees a call to
Resources#getIdentifier (which is a method which lets you look up
resources by dynamically computed resource names), it reverts to a
safe mode where it plays it safe and for example marks any resource
whose name is a match for any constant in the string pool as possibly
being used.
Unfortunately, appcompat, used in nearly all apps created from Android
Studio, has a couple of usages of Resources#getIdentifier, which means
that nearly all apps end up in safe mode, where many resources are
incorrectly kept just to be on the safe side. However, it turns out
that these two usages are benign and not typically used to look up
resources in a reflective way.
Therefore, the resource shrinker now keeps track of the obfuscated
names of the classes for these two resource lookup calls, and when it
comes across a Resources#getIdentifier() call it ignores it if it's
one of these "benign" usages.
Issue id's for problems related to resource shrinker that were fixed in 2.0 alpha 4:
*
*
*
*
*
bb...@gmail.com <bb...@gmail.com> #60
Can we see the source of change that is made or is that not available to us?
km...@gmail.com <km...@gmail.com> #61
What about removing library resources?
It's not working for me with gradle tools "1.5+", wondering if trying 2.0 would be worth it:
build.gradle:
dependencies {
marketCompile ('com.google.android.gms:play-services-auth:8.3+') {
exclude group: 'com.android.support'
}
also:
buildTypes {
release {
minifyEnabled true
shrinkResources true
}
}
and also in the app's res/raw/keep.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools "
tools:discard="@drawable/common_plus_signin_*,@drawable/common_google_signin_*,@drawable/ic_plusone_*,@drawable/powered_by_google_*"
tools:shrinkMode="strict" >
</resources>
This is printed while building:
Removed unused resources: Binary resource data reduced from 4688KB to 4370KB: Removed 6%
So the resource shrinker is bring invoked.
And yet, this is the resulting .apk:
$ unzip -l ../release/AquaMail-market-1.6.1.1.apk | grep common
104 03-01-2016 21:12 res/color/common_google_signin_btn_text_dark.xml
104 03-01-2016 21:12 res/color/common_google_signin_btn_text_light.xml
104 03-01-2016 21:12 res/color/common_plus_signin_btn_text_dark.xml
104 03-01-2016 21:12 res/color/common_plus_signin_btn_text_light.xml
67 03-01-2016 21:12 res/drawable-hdpi-v4/common_full_open_on_phone.png
77 03-01-2016 21:12 res/drawable-hdpi-v4/common_google_signin_btn_icon_dark_disabled.9.png
77 03-01-2016 21:12 res/drawable-hdpi-v4/common_google_signin_btn_icon_dark_focused.9.png
77 03-01-2016 21:12 res/drawable-hdpi-v4/common_google_signin_btn_icon_dark_normal.9.png
77 03-01-2016 21:12 res/drawable-hdpi-v4/common_google_signin_btn_icon_dark_pressed.9.png
77 03-01-2016 21:12 res/drawable-hdpi-v4/common_google_signin_btn_icon_light_disabled.9.png
77 03-01-2016 21:12 res/drawable-hdpi-v4/common_google_signin_btn_icon_light_focused.9.png
77 03-01-2016 21:12 res/drawable-hdpi-v4/common_google_signin_btn_icon_light_normal.9.png
These resources amount to about 300K, a killer for me.
It's not working for me with gradle tools "1.5+", wondering if trying 2.0 would be worth it:
build.gradle:
dependencies {
marketCompile ('com.google.android.gms:play-services-auth:8.3+') {
exclude group: 'com.android.support'
}
also:
buildTypes {
release {
minifyEnabled true
shrinkResources true
}
}
and also in the app's res/raw/keep.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="
tools:discard="@drawable/common_plus_signin_*,@drawable/common_google_signin_*,@drawable/ic_plusone_*,@drawable/powered_by_google_*"
tools:shrinkMode="strict" >
</resources>
This is printed while building:
Removed unused resources: Binary resource data reduced from 4688KB to 4370KB: Removed 6%
So the resource shrinker is bring invoked.
And yet, this is the resulting .apk:
$ unzip -l ../release/AquaMail-market-1.6.1.1.apk | grep common
104 03-01-2016 21:12 res/color/common_google_signin_btn_text_dark.xml
104 03-01-2016 21:12 res/color/common_google_signin_btn_text_light.xml
104 03-01-2016 21:12 res/color/common_plus_signin_btn_text_dark.xml
104 03-01-2016 21:12 res/color/common_plus_signin_btn_text_light.xml
67 03-01-2016 21:12 res/drawable-hdpi-v4/common_full_open_on_phone.png
77 03-01-2016 21:12 res/drawable-hdpi-v4/common_google_signin_btn_icon_dark_disabled.9.png
77 03-01-2016 21:12 res/drawable-hdpi-v4/common_google_signin_btn_icon_dark_focused.9.png
77 03-01-2016 21:12 res/drawable-hdpi-v4/common_google_signin_btn_icon_dark_normal.9.png
77 03-01-2016 21:12 res/drawable-hdpi-v4/common_google_signin_btn_icon_dark_pressed.9.png
77 03-01-2016 21:12 res/drawable-hdpi-v4/common_google_signin_btn_icon_light_disabled.9.png
77 03-01-2016 21:12 res/drawable-hdpi-v4/common_google_signin_btn_icon_light_focused.9.png
77 03-01-2016 21:12 res/drawable-hdpi-v4/common_google_signin_btn_icon_light_normal.9.png
These resources amount to about 300K, a killer for me.
pu...@gmail.com <pu...@gmail.com> #62
I have an app that uses appcompat through com.android.support:mediarouter-v7:23.3.0.
Looking at the png included in the generated APK using the gradle android plugin (v2.1.0), I noticed that all the PNGs of appcompat (and there are a bunch!) where included, while my app does not make use of appcompat directly nor using mediarouter UI features that could make use of these PNGs.
After reading the doc on resource shrinking, lots of googling and hair-pulling to find the cause, I found it to be the safe mode to be way too much conservative (and even wrong), as I had a lot of:
Marking style:TextAppearance_AppCompat_Widget_ActionMode_Subtitle_Inverse:2131558684 used because it format-string matches string pool constant %dx%d
Marking style:TextAppearance_AppCompat_Widget_ActionMode_Title:2131558685 used because it format-string matches string pool constant %dx%d
Marking style:TextAppearance_AppCompat_Widget_ActionMode_Title_Inverse:2131558686 used because it format-string matches string pool constant %dx%d
Marking style:TextAppearance_AppCompat_Widget_Button:2131558687 used because it format-string matches string pool constant %dx%d
Marking style:TextAppearance_AppCompat_Widget_Button_Inverse:2131558688 used because it format-string matches string pool constant %dx%d
Marking style:TextAppearance_AppCompat_Widget_DropDownItem:2131558689 used because it format-string matches string pool constant %dx%d
Marking style:TextAppearance_AppCompat_Widget_PopupMenu_Large:2131558690 used because it format-string matches string pool constant %dx%d
Marking style:TextAppearance_AppCompat_Widget_PopupMenu_Small:2131558691 used because it format-string matches string pool constant %dx%d
...
The string pool contained "%dx%d", found in a String.format() statement of a third party lib. And this format string does not even match the ids mentioned (a bug IMHO).
But had it been %s or %sx%s, it would have matched.
This fix was to use a keep.xml specifying strict mode, and bam, resource shrinking removing 700kb of unused PNGs in appcompat.
I think the current default for shrinking leads to overbloated APKs without most developers being aware of it, because they assume it just works and do not know the internals, and rarely look at the final content of their APK. I think strict mode should be the default, even if can give some crashes if getIdentifier() is used. The same way Proguard can cause crashes if it removes too much. Currently the string pool is way too broad and will likely retain mainly resources that could have been shrinked.
Description
This issue will try to track down the various causes for this.
I suspect the *main* reason this happens is that the resource shrinker tries to err on the side of caution: If it is not *sure* if a resource is unused, it will keep it. The rationale for this is that it's better to have an unused resource than to have a runtime crash when a removed resource that turns out to be used after all cannot be found.
If the app does not look up resources by name (e.g. by calling Resources#getIdentifier(String)), then resource usage should be fairly accurate and most eligible resources should be removed.
However, if that method is called (and if you use appcompat, that method uses it, so your app is considered to b using it), then that means that your code could be constructing resource names dynamically, and looking those up. Therefore, the resource shrinker in that case will look at all the strings in your app (including those from your libraries), and try to figure out whether these are used to construct resource names.
For example, if it sees the string "cursor_%d", it guesses that this might be used to look up the resource icons cursor1.png, cursor2.png, cursor3.png via code like Resources.getIdentifier(String.format("cursor_%d", count) - so all resources that String#format match "cursor_%d" are kept. Similarly, you might be doing "cursor_" + count, so anything which starts with that string is kept as well.
(In 0.14.2 the mere presence of "%s" would be used by this code to mask absolutely everything; that has now been fixed.)
How do you know if this is what's happening to your app?
First build with the --debug flag such that the resource shrinking generates status information. This is going to dump out a lot of information (from all tasks) so you should dump it into a file:
$ ./gradlew --debug clean assembleRelease > /tmp/build-output.txt
Now let's see if the app contained a dynamic resource lookup:
$ grep Resources#getIdentifier /tmp/build-output.txt
07:48:48.285 [QUIET] [system.out] android.content.res.Resources#getIdentifier present: true
Yes it did! If you open the build output file and look for "Referenced Strings:" you can see all the constants found in the app that it uses to look for possible matches (there are different heuristics applied; some for the file:///android_res syntax, some for the #getIdentifier call, etc.
This shows which drawable resources were kept because their names matched a string pool constant that the resource shrinker worried could be used to dynamically look up the resource:
$ cat /tmp/build-output.txt | grep "Marking drawable:"
13:15:34.543 [QUIET] [system.out] Marking drawable:powered_by_google_dark:2130837586 used because its prefix matches string pool constant power
13:15:34.543 [QUIET] [system.out] Marking drawable:powered_by_google_light:2130837587 used because its prefix matches string pool constant power
So the code included the string "power" somewhere, and this caused these two icons to be kept.
SOLUTIONS:
So what can we do about this? One possibility is for us to add a flag or option of some sort where Lint does *not* attempt to figure out possible uses, and simply force the user to *explicitly* keep all dynamically referenced resources. This is similar to how ProGuard already works; it doesn't try very hard to figure out reflective uses of calls, so you have to explicitly keep those via a
OTHER CAUSES:
If your resources are *not* kept because of a String pool constant, look at the debug output and grep for the "reachable" attribute; e.g. something like this:
$ cat /tmp/build-output.txt | grep reachable= | awk '{print $4 $5 $6}' | grep drawable | sort
@drawable/abc_textfield_search_material:reachable=true
@drawable/common_full_open_on_phone:reachable=false
@drawable/common_ic_googleplayservices:reachable=false
@drawable/common_signin_btn_icon_dark:reachable=false
Make sure that your resource which you expected to be unused is not actually marked as reachable. If it is, you can try looking for it; the reference graph is also printed. For example, for the top reference above, we have
$ cat /tmp/build-output.txt | grep abc_textfield_search_material | grep '=>'
07:48:48.636 [QUIET] [system.out] drawable:abc_textfield_search_material:2130837554 => [drawable:abc_textfield_search_activated_mtrl_alpha:2130837552, drawable:abc_textfield_search_default_mtrl_alpha:2130837553]
07:48:48.648 [QUIET] [system.out] style:Base_Widget_AppCompat_SearchView:2131492957 => [layout:abc_search_view:2130903061, drawable:abc_textfield_search_material:2130837554, drawable:abc_ic_clear_mtrl_alpha:2130837519, drawable:abc_ic_search_api_mtrl_alpha:2130837528, drawable:abc_ic_go_search_api_mtrl_alpha:2130837521, drawable:abc_ic_voice_search_api_mtrl_alpha:2130837529, drawable:abc_ic_commit_search_api_mtrl_alpha:2130837520, layout:abc_search_dropdown_item_icons_2line:2130903060]
07:48:50.392 [DEBUG] [org.gradle.api.Project] => res/drawable/abc_textfield_search_material.xml
07:49:01.585 [QUIET] [system.out] drawable:abc_textfield_search_material:2130837554 => [drawable:abc_textfield_search_activated_mtrl_alpha:2130837552, drawable:abc_textfield_search_default_mtrl_alpha:2130837553]
07:49:01.596 [QUIET] [system.out] style:Base_Widget_AppCompat_SearchView:2131492957 => [layout:abc_search_view:2130903061, drawable:abc_textfield_search_material:2130837554, drawable:abc_ic_clear_mtrl_alpha:2130837519, drawable:abc_ic_search_api_mtrl_alpha:2130837528, drawable:abc_ic_go_search_api_mtrl_alpha:2130837521, drawable:abc_ic_voice_search_api_mtrl_alpha:2130837529, drawable:abc_ic_commit_search_api_mtrl_alpha:2130837520, layout:abc_search_dropdown_item_icons_2line:2130903060]
07:49:03.477 [DEBUG] [org.gradle.api.Project] => res/drawable/abc_textfield_search_material.xml
If you don't see an actual resource reference to your file, that means it must be referenced from the code instead.