shrinkResources在build.gradle
中被标记为true。
然后我发现了这个奇怪的错误:
在我的应用程序的java文件中,有一行如下:
String unit = String.format("%%s %s", getResources().getString(R.string.XXXX));
请注意%%s %s
如果我添加这个空格,我的一些PNG将被ShrinkResources标记为未使用的资源,并且不会被打包到apk文件中。
但如果我省略了空间,一切都很好。
对我而言,这简直令人难以置信。它会让我疯狂......对此有什么看法?
更新
试图让我的问题更加明确:
如果我的java代码是
String unit = String.format("%%s %s", getResources().getString(R.string.XXXX));
然后部分输出(实际上我在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)
不会显示跳过的png。
如果我的java代码是
String unit = String.format("%%s%s", getResources().getString(R.string.XXXX));
没有我上面发布的输出,一切都很好。