Comments (12)
Hi, did you follow the proguard configuration provided in official guidance?. We already has some rules in dagger keeping entrypoints, example. Your error seems coming from a over aggressive proguard shrinking, I vaguely remember I had similar issue before when I didn't include getDefaultProguardFile("proguard-android-optimize.txt").
If you did included the android proguard file, can you create a repro for your problem, so that we can look into this further.
from dagger.
i have try to follow the official guidance and put all of the rules into my proguard-rules.pro, and i have include the getDefaultProguardFile("proguard-android-optimize.txt").
too in my build.gradle, but somehow the error is still exist, i put the link for my project repository below so you can see the detail of my code
from dagger.
Hi, I patched your repro and ran ./gradlew assembleDebug
, but I'm not seeing the missing dagger errors, I only see missing StringConcatFactory, which looks like Kotlin/kotlinx.serialization#2145. But I noticed that your repo is using pretty old version of Dagger, Kotlin, Ksp and Compose. Can you try to upgrade your versions first to see if the errors goes away?
from dagger.
Hello, i have tried to update all of the version of my Dagger, Kotlin, Ksp and Compose but it seems the error is remains the same,
i have updated my repository and here is the link to the updated repository :
Repository-Update
from dagger.
Hi, I noticed that the hilt gradle plugin is missing from your class path. https://github.com/Dzikry123/Android-Proguard/blob/version2/build.gradle#L9. https://dagger.dev/hilt/gradle-setup.html, please refer to the hilt gradle section for how to include it in the class path.
from dagger.
@wanyingd1996 he's already declared it in https://github.com/Dzikry123/Android-Proguard/blob/b0c85c6d5ba802f6190c5237f4dbd74a482b7089/build.gradle#L17 using the new plugin DSL.
I encountered similar issue as well after upgrade AGP to 8.3 and Gradle 8.6, which uses R8 full mode by default.
from dagger.
Thank you, sorry didn't notice the new plugin. I think the issue was the with R8 not hilt, I bumped the AGP version to 8.3.0 and I'm seeing missing binding error instead of the r8 errors. @aldee, can you share details of your problem? I suspect it is a different issue.
from dagger.
@wanyingd1996 no worries. actually I don't have that problem anymore, somehow. my problem was actually on runtime, but it's complaining about similar issue
Fatal Exception: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/example/app/MyApplication_GeneratedInjector; at com.example.DaggerMyApplication_HiltComponents_SingletonC.builder(DaggerMyApplication_HiltComponents_SingletonC.java:64) at com.example.Hilt_MyApplication$1.get(Hilt_MyApplication.java:24) at dagger.hilt.android.internal.managers.ApplicationComponentManager.generatedComponent(ApplicationComponentManager.java:40) at com.example.Hilt_MyApplication.generatedComponent(Hilt_MyApplication.java:37) at com.example.Hilt_MyApplication.hiltInternalInject(Hilt_MyApplication.java:52) at com.example.Hilt_MyApplication.onCreate(Hilt_MyApplication.java:43) at com.example.MyApplication.onCreate(MyApplication.kt:13) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1316) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6998) at android.app.ActivityThread.-$$Nest$mhandleBindApplication() 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(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
that's the stacktrace of the crash, and that crash only happened after using R8 full mode. But unfortunately I forgot what the environment was (gradle, hilt, AGP version).
Maybe @Dzikry123 can try updating to latest AGP and Gradle? and also use the latest R8 as well by adding this
classpath("com.android.tools:r8:8.3.37")
to your project's build.gradle buildscript dependencies
from dagger.
Hi @aldee and @wanyingd1996 thank you for your support, i have tried to update the AGP, Gradle and also the R8 to my project's build.gradle , but the error is still exist, i try to update the android studio to iguana version, but the error remains the same, here is the update of my project, perhaps you can find some clue here :
from dagger.
So in my case, I'm using Hilt version 2.44.2, it works fine. But when I upgraded it to 2.51, I got the same error with nothing else changed.
from dagger.
Hi, @Dzikry123, there are several misconfiguration in the project.
(1) :favorite
and :core
are libraries, you don't need to include the android default proguard files there. I'm seeing warning about it is not necessary to include those in a module.
(2) You are using incompatible version of hilt-android and hilt-compiler, these are separate artifact, but using different version of them may result in internal API incompatible.
(3) You did not include hilt as dependency for :core
, but you are defined hilt entry point in that library, therefore, you have a missing binding error hidden behind the r8 error.
Applying the above changes resulted in a successful build from my side. I think the missing class from r8 is just red herrings, covering the real errors.
To summarize, It is recommended to alway try the latest version of libraries to avoid seeing mysterious errors, and some of the bugs may already being fixed in the latest version.
from dagger.
Hi @wanyingd1996 and @aldee after 2 weeks i found what is the error, the warnings I see (e.g., "Class com.example.projectone.Hilt_GithubUserApplication does not exist") are caused by these classes not being present in the input passed to the compiler.
i tried to get Hilt to work by updating the version and minifyEnabled false then tried switching to minifyEnabled true once it worked.
thank you so much for helping me to find the solution of this problem :)
from dagger.
Related Issues (20)
- Following dagger.dev tutorial doesnt create singleton in v2.51 HOT 2
- Multibinding with Nested Complex Keys uses the wrong AnnotationCreator HOT 1
- [Hilt] onCreate() in my Application doesn't called on Instrument test HOT 4
- [Dagger-Hilt] Error when applying obfuscation other than Proguard (Allatori) HOT 3
- error: [Hilt] Expected @AndroidEntryPoint to have a value HOT 3
- @IntoSet analog for injectable classes HOT 3
- Hilt Generated Code having not used code? HOT 2
- [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
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.