Skip to content
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

Can't add Hilt to a multiplatform project #4163

Closed
mylesbennett opened this issue Nov 28, 2023 · 4 comments
Closed

Can't add Hilt to a multiplatform project #4163

mylesbennett opened this issue Nov 28, 2023 · 4 comments

Comments

@mylesbennett
Copy link

This was first raised here when I was trying to add Hilt to a multiplatform project using the traditional kapt annotation processor. I switched to the latest KSP arrangement and now have a new error on build:

[ksp] /composeApp/src/androidMain/kotlin/com/bpp/example/MainActivity.kt:12: [Hilt] Expected @AndroidEntryPoint to have a value. Did you forget to apply the Gradle Plugin? (com.google.dagger.hilt.android)
See https://dagger.dev/hilt/gradle-setup.html
[1;31m[Hilt] Processing did not complete. See error above for details. [0m

Here is a repo demonstrating the problem.

@kuanyingchou
Copy link
Collaborator

Hi, @mylesbennett , thanks for reporting. This looks similar to this one: #4130. Could you give the latest snapshot a try?

@mylesbennett
Copy link
Author

mylesbennett commented Nov 29, 2023

Hi @kuanyingchou, Thanks for your quick reply.

I tried the snapshot arrangement - still the same error.

It's possible there was something lost in my translating the Groovy instructions to Kotlin DSL/ Version Catalogs.
Also the instructions were for Dagger, but the resolution strategy seemed to pick up the snapshots for Hilt as well. At least, that was what the download report suggested on build.

Here is my attempt:
https://github.com/mylesbennett/Compose-Multiplatform-Hilt-Kapt-type-mismatch/tree/dagger-snapshot
(BTW, ignore the title of repo. I gave up on kapt and switched to ksp)

@kuanyingchou
Copy link
Collaborator

kuanyingchou commented Nov 30, 2023

Hi, @mylesbennett , you also need to move Hilt to "HEAD-SNAPSHOT" in your libs.versions.toml, and add maven("https://oss.sonatype.org/content/repositories/snapshots") to both repositories in your settings.gradle.kts.

@mylesbennett
Copy link
Author

mylesbennett commented Nov 30, 2023

Odd. The first time I attempted to move Hilt to "HEAD-SNAPSHOT", the build said it couldn't find the libraries.
Maybe adding the maven snapshot in settings.gradle.kts is what made the difference. That bit wasn't in the "latest snapshot" intstructions.

Anyhow, thanks, that seems fixed. I pushed the changes to that branch for anyone intrrested.

What official version can I document that this will be fixed in (ie, when will it be released)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants