0

shrinkResources is configed as true in build.gradle.

Then I found this weird bug:

In a java file of my app, there is one line like this:

String unit = String.format("%%s %s", getResources().getString(R.string.XXXX));

Note that there is a space in %%s %s

if I add this space, some of my PNGs will be marked as unused resource by ShrinkResources, and won't be packaged into the apk file.

But if I omit the space, everything is fine.

For me it's unbelievable.It's gonna drive me crazy...Any idea about this?

update:

trying to make my question more clear:

if my java code is

String unit = String.format("%%s %s", getResources().getString(R.string.XXXX));

Then part of the outputs is(in fact I found it in resources.txt):

Skipped unused resource res/drawable-xxhdpi-v4/head02.9.png: 822 bytes (replaced with small dummy file of size 77 bytes) Skipped unused resource res/drawable-xxhdpi-v4/appointment_normal.png: 1827 bytes (replaced with small dummy file of size 67 bytes) Skipped unused resource res/drawable-xxhdpi-v4/cg_normal.png: 1850 bytes (replaced with small dummy file of size 67 bytes) Skipped unused resource res/drawable-xxhdpi-v4/pre_normal.png: 1822 bytes (replaced with small dummy file of size 67 bytes) Skipped unused resource res/drawable-xxhdpi-v4/doctor_normal.png: 1963 bytes (replaced with small dummy file of size 67 bytes) Skipped unused resource res/drawable-xxhdpi-v4/infor_normal.png: 1605 bytes (replaced with small dummy file of size 67 bytes) Skipped unused resource res/drawable-xxhdpi-v4/btn_check.png: 716 bytes (replaced with small dummy file of size 67 bytes) Skipped unused resource res/drawable-xxhdpi-v4/btn_check.png: 898 bytes (replaced with small dummy file of size 67 bytes) Skipped unused resource res/drawable-xxhdpi-v4/navigation_arrow_left_normal.png: 184 bytes (replaced with small dummy file of size 67 bytes) Skipped unused resource res/drawable-xxhdpi-v4/dameon_killed.png: 913 bytes (replaced with small dummy file of size 67 bytes)

The pngs that skipped will not be displayed.

if my java code is

String unit = String.format("%%s%s", getResources().getString(R.string.XXXX));

no outputs like I posted above, and everything is fine.

kyoraku
  • 57
  • 7

0 Answers0