Comments (6)
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 identifiernamestring
isn't included in an earlier version of R8. If version update doesn't help, can you provide a repro for the problem. I copied your example into our sample r8 app, and it build and runs successfully.
from dagger.
Can you point me to the exact rule you are talking about?
I use the R8 version 8.2.47 that ships with AGP 8.2.2.
I came up with a solution to make all Class used as class key implement a marker interface called LazyClassKeyable
. Once we do that, the below R8 rule will work for all keys.
# Keep rule for supporting LazyClassKey
-keep class * implements com.microsoft.teams.injection.LazyClassKeyable { *; }
With a unit test, we can force future additions to implement the marker interface LazyClassKeyable
. I was thinking of writing a unit tests that gets holds of all keys and assert that they can be assigned to LazyClassKeyable.
@Test
fun appDataFactory_mapKeys_shouldBeLazyClassKeyable() {
val app = context as StubbedSkypeTeamsApplication
val userDataFactory : UserDataFactory = app.getUserDataFactory(TEST_USER_OBJECT_ID)
assertEquals("Note: New key added to multibinding UserDataFactoryMap needs to implement LazyClassKeyable.",251, userDataFactory.mProviderMap.size)
val values = userDataFactory.mProviderMap.values
values.forEach {
val classObject = it.get()
assertTrue("Key $classObject should implement LazyClassKeyable", classObject is LazyClassKeyable)
}
}
from dagger.
Hi, the r8 rule we included in the library is here. -keep
the class works, but may result in your class name not being obfuscated? I still want to figure out why the class gets removed, I expect with usage of -identifiernamesstring rule, the class shouldn't have been removed. Is it ok to provide a repro of the problem? Or provide more detail about what's special about the class being removed? Also, please share the NPE stack trace. Thanks!
from dagger.
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
Process: com.ms.multimoduleapp, PID: 11205
java.lang.RuntimeException: Unable to create application com.ms.multimoduleapp.MultiModuleApp: java.lang.IllegalArgumentException: Unknown class class G0.a
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7003)
at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2236)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8177)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
Caused by: java.lang.IllegalArgumentException: Unknown class class G0.a
at com.ms.multimoduleapp.MultiModuleApp.onCreate(Unknown Source:110)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1316)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6998)
at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2236)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8177)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
from dagger.
Related Issues (20)
- [Dagger-Hilt] Can't get viewModel in composable by Hilt HOT 1
- Why does Provides in a Companion Object work? HOT 6
- Update Dagger guava dependency to address CVE-2023-2976 HOT 2
- Add KMP support for @HiltViewModel annotation HOT 2
- Dagger resolution and dynamic feature module HOT 1
- Feature request: Manually regenerate application component HOT 1
- Using TestContainer.com HOT 2
- Detect dependency cycles containing Lazy or Provider during the compilation time HOT 6
- error when ksp.useKSP2=true HOT 2
- Suppress annotation on @Inject is not honored on the Factory HOT 1
- [KSP2] Dagger and Hilt incompatibility with KSP2 HOT 2
- [KSP2] NullPointerException: null cannot be cast to non-null type androidx.room.compiler.processing.XType HOT 1
- OutOfMemoryError with Maven HOT 1
- DaggerAppComponent not creating in the version 2.51.1 HOT 3
- java.lang.ClassNotFoundException: dagger.spi.shaded.androidx.room.compiler.processing.javac.JavacBasicAnnotationProcessor. Hilt 2.49+ HOT 1
- how to manually generate module HOT 1
- Explain how to add dagger jar files manually to the android project HOT 2
- Annotate interface with default Bind implementation HOT 2
- Transitive vulnerability from symbol-processing-api HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dagger.