Giter VIP home page Giter VIP logo

Comments (12)

wanyingd1996 avatar wanyingd1996 commented on June 12, 2024

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.

Dzikry123 avatar Dzikry123 commented on June 12, 2024

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

My Repository

from dagger.

wanyingd1996 avatar wanyingd1996 commented on June 12, 2024

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.

Dzikry123 avatar Dzikry123 commented on June 12, 2024

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,

Screenshot 2024-03-15 141931
Screenshot 2024-03-15 142012

i have updated my repository and here is the link to the updated repository :
Repository-Update

from dagger.

wanyingd1996 avatar wanyingd1996 commented on June 12, 2024

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.

aldee avatar aldee commented on June 12, 2024

@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.

wanyingd1996 avatar wanyingd1996 commented on June 12, 2024

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.

aldee avatar aldee commented on June 12, 2024

@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.

Dzikry123 avatar Dzikry123 commented on June 12, 2024

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 :

Repo-update-2

from dagger.

aldee avatar aldee commented on June 12, 2024

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.

wanyingd1996 avatar wanyingd1996 commented on June 12, 2024

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.

Dzikry123 avatar Dzikry123 commented on June 12, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.