Skip to content
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

Inner R classes aren't kept for tests #104

Closed
vRallev opened this issue Jul 22, 2022 · 1 comment
Closed

Inner R classes aren't kept for tests #104

vRallev opened this issue Jul 22, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@vRallev
Copy link

vRallev commented Jul 22, 2022

Keeper version: main

Imagine a library module :main defining an Android resource. Library :android-test-only references the resource in Java / Kotlin code. The :app module depends on :main in the main source code and on :android-test-only for Android tests only. A test in :app calls the code from :android-test-only referencing the resource, but the resource is otherwise nowhere else being used. I'd expect Keeper to generate a rule to keep the inner R class in order to reference the resource. Instead, I'm seeing a crash that the class was removed:

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/slack/keeper/sample/main/R$bool;
at com.slack.keeper.example.android.test.SomeClass.isTablet(SomeClass.kt:10)
at com.slack.keeper.example.android.test.SomeClass.test(SomeClass.kt:13)
at com.slack.keeper.sample.KeeperSampleTest.testFunctionKept(KeeperSampleTest.kt:28)
... 31 trimmed
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.slack.keeper.sample.main.R$bool

The workaround is to add following rule to the main (not test) proguard rules:

-keep class com.slack.keeper.sample.main.R$bool { *; }

I was able to reproduce the issue within the Keeper project: main...vRallev:keeper:ralf/bug

@vRallev vRallev added the bug Something isn't working label Jul 22, 2022
ZacSweers added a commit that referenced this issue Dec 8, 2022
@ZacSweers
Copy link
Collaborator

Looking more into this, there's no top-level R class kept either. This is ultimately the same issue as #22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants