-
Notifications
You must be signed in to change notification settings - Fork 2k
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
App crashing with NPE for some classes when Lazy Class Key is used #4309
Comments
Hi, dagger ships an r8 rule -identifiernamestring that comes with the usage of @LazyClassKey, you shouldn't need to do anything else to make that work. What is the version of R8 you are using? Maybe |
Can you point me to the exact rule you are talking about? I came up with a solution to make all Class used as class key implement a marker interface called
With a unit test, we can force future additions to implement the marker interface
|
Hi, the r8 rule we included in the library is here. |
Please find the attached reproducer project. Do I have to add the annotation in the class being used for LazyClassKey? Ideally I would be using the Interface to inject. However, for the sake of reproduction, I had to avoid using the interface to ensure that R8 removed it from the final APK which helps in reproducing the issue. The stacktrace is as below: 2024-05-29 15:15:24.224 11205-11205 AndroidRuntime pid-11205 E FATAL EXCEPTION: main |
Thanks @wanyingd1996. This seems to be working. I will test it more and update here. |
Hi, AGP team has fixed the issue in in R8 version 8.4.37 and 8.5.23, so the alternative solution is override the r8 version in settings.gradle.
|
What is the issue?
NPE when the class used in LazyClassKey is removed by R8.
R8 has removed that type from the final APK. Can we provide examples of R8 rules that should accompany with usage of LazyClassKey?
From the documentation, it's unclear if the R8 rules ship with the library or we need to write one on our own.
Example module that uses LazyClassKey
Dagger version
2.51.1
The text was updated successfully, but these errors were encountered: