-
-
Notifications
You must be signed in to change notification settings - Fork 433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minify + Shrink resources removes String resources #331
Comments
I had success with this:
This only keeps the definitions used by |
@rubengees but wouldn't this also remove the strings of the libs themself? So do you add them manually to your project in addition? |
Hmm, no it works out of the box in my case. Maybe |
Shrink resources is the issue, not proguard. |
It can't as those are loaded during the runtime. So this means your definition still keeps the resources. @AllanWang I do not think there is anything I can do about this, or the lib can do about it. |
Just tried it with |
@rubengees is your project open sourced? |
Also since this keeps the whole R class, I'm not sure if this will be better than the original rules |
Yes, here here are the
I am not a
As far as I know, |
From the
I think that means that entire R does not get keeped, but only the fields we use or specify with this rule. |
@rubengees I think it means that it does, since the only constraint is that a class contains a define_ string and it's preserving the entire class rather than just some members. I'm still waiting for travis to build so I can decompile it later. Plus I think the reason it works with define_ is because the rest of the class is kept, otherwise all your library_ strings will be gone too. (Not a proguard expert either, so what you're saying is ideally what I want to happen) |
The only thing which can be maybe done in the future is to split up the core, and move all libraries to a different module. So you can either use the module with all the resources, or you manually add the resources you want |
I just decompiled my app and the R file is really small. I think it works the way we want to (I could be mistaken of course). |
@rubengees just drag&drop the apk onto Android Studio 3.0, it has a really cool visualisation, and also shows the contained resources |
@mikepenz The issue still stands with all the external libraries with their strings, Using the rules defined above definitely cleans it a fair bit though, since it seems to remove all the appcompat resources. My R class with from 6k variables to 3k, and About library went from 3709 to ~300. For the app, the size
|
well I can't do anything about external libraries. The only reason the |
Our cases are for proguard + shrink + no auto detection. Because without this rule those strings will be gone anyways. I don't think any changes need to be done on your end since it's fine the way it is, but perhaps the proguard lines can be added to the readme for those who want to shrink their resources as much as possible and are willing to input libraries manually. Thanks rubengees!
|
@AllanWang My pleasure :) |
@rubengees already writing the README update :) |
Obviously this is the case, and it can be fixed by keeping the R class, but I was wondering if there is hopefully a better alternative somehow.
-keepresources
looked promising but it seems to be a dexguard feature rather than a proguard feature.In comparison, keeping all the R classes adds around 60kb to a < 3mb app, which is somewhat significant.
The text was updated successfully, but these errors were encountered: