toothpick
toothpick copied to clipboard
@Qualifier annotations and proguard rules
Hi. I noticed that proguard rules at TP wiki don't cover situations when we use injections with qualifiers.
For example, I have
@Qualifier
annotation class MyQualifier
And class with such constructor
class Foo @Inject constructor(@MyQualifier bar: String)
Toothpick generates Foo__Factory
with code that tries to get instance of qualified argument with full classname of MyQualifier
before obfuscation.
String param1 = scope.getInstance(String.class, "com.example.MyQualifier");
But in runtime it will be bound with full classname after obfuscation and that causes crash. I tried proguard rules from TP Wiki with R8 to reproduce this case.
This proguard rule helped me to avoid crash:
-keep @javax.inject.Qualifier @interface *
Should it be added to wiki or am I missing something?
Hi @horseunnamed
It looks like our rules on the wiki and inside smoothie might not cover that use case. Taking into account that you already found the solution, do you wanna contribute by updating:
- https://github.com/stephanenicolas/toothpick/blob/master/smoothie/proguard-rules.txt
- Wiki: https://github.com/stephanenicolas/toothpick/wiki/Proguard-&-TP
Thx for the issue!
btw, sorry for the delay