B3nedikt / restring

Restring is a android library to replace string resources dynamically
Apache License 2.0
319 stars 31 forks source link

Ruler error when using Restring in dynamic feature #153

Open 0xffrom opened 2 months ago

0xffrom commented 2 months ago

Hi! I am using Ruler to measure the size of an app through App Bundle analysis.

I will add a dynamic feature that depends transitively on Restring.

When trying to do aab analysis via Ruler on a release buildtype of an app using shrinker, I get an error

* What went wrong:
Execution failed for task ':app:analyzeReleaseBundle'.
> Resource table of module 'dynamic' contains references to non-existing files: [res/layout/test_layout.xml, res/menu/test_menu.xml]

Can you add these resources to the test sourceset?

I'm using workaround to keep shrinker from deleting these resources, but I still don't like them going into the release build.

@Keep
class RulerWorkaround {

  val testMenu
    get() = dev.b3nedikt.restring.R.menu.test_menu

  val testLayout
    get() = dev.b3nedikt.restring.R.layout.test_layout
}
B3nedikt commented 2 months ago

What is Ruler? Also on the stackoverflow answer you linked someone wrote the solution does not work anymore in newer IDE versions. I guess the simplest solution would be to move the tests including the test only resources to a different module.

If you think a different solution makes sense though, feel free to create a PR :)

0xffrom commented 2 months ago

Ruler is a library for measuring app bundle size

But it reproduces it without a Ruler too, using ./gradlew app:packageReleaseUniversalApk, this command creates an apk based on the app bundle

If you think a different solution makes sense though, feel free to create a PR :)

Ok, thank you)

B3nedikt commented 2 months ago

Cool plugin, I saw it already before, but completely forgot about it ;)

I think I will implement the solution of just moving all test code into a new module, should be quick to do. I will release it in the next few days.