Open dellis1972 opened 3 years ago
Some code to take a look at
https://github.com/luori366/android-platform-tools-base/blob/49d23734981c27378c9dea00266e402f7f1e5de8/build-system/gradle-core/src/main/groovy/com/android/build/gradle/tasks/ShrinkResources.groovy https://github.com/luori366/android-platform-tools-base/blob/49d23734981c27378c9dea00266e402f7f1e5de8/build-system/gradle-core/src/main/groovy/com/android/build/gradle/tasks/ResourceUsageAnalyzer.java
We can probably create a task which can replicate those.
The process seems to run as follows
This will need to be updated to use our C# Resouce.desinger.cs as well as the R.java classes. But once we have a list of used resources we can remove the unused from the apk. Can must be taken to make sure transient resources are kept.
Is this at all related to aapt2 optimize
? See: https://github.com/xamarin/xamarin-android/issues/5116
As far as I know its not. This seems to related to a post Java link step that runs to remove unused resources.
Also #5116 seems to only work on .apk files, where as this would work on both apk and aab files.
Context https://developer.android.com/studio/build/shrink-code#shrink-resources
Android includes a system where unused resources from the apk are removed as part of the build process. This will result in smaller abb/apk files. We should look at doing something similar, it will take some investigation though.
Initial thoughts would be.
Resources.Foo
Items in the linked C# code via Cecil. Use this information to generate a .java stub file which contains only the use resources.more investigation will be needed. However I think this is something we should look at.