android / codelab-android-dagger-to-hilt Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
The Documentation on https://codelabs.developers.google.com/codelabs/android-dagger-to-hilt/ is confusing. It is not clear when the application should build and what the error messages mean. Even I used Dagger before in a Project I have no understanding what I'm doing within this tutorial.
I'ts more like a do ist this way tutorial for that example. But gives you no real understanding about what you are doing.
Please clarify:
Hello there,
According to page #2 of the codelab, we are supposed to add Hilt to the project ourselves. However, as seen in the following lines, Hilt is already included in this project in Master.
https://github.com/googlecodelabs/android-dagger-to-hilt/blob/267db264888e8c76b9c6b54f663d9462fbb55e37/build.gradle#L5
https://github.com/googlecodelabs/android-dagger-to-hilt/blob/267db264888e8c76b9c6b54f663d9462fbb55e37/build.gradle#L13
https://github.com/googlecodelabs/android-dagger-to-hilt/blob/267db264888e8c76b9c6b54f663d9462fbb55e37/app/build.gradle#L9
https://github.com/googlecodelabs/android-dagger-to-hilt/blob/267db264888e8c76b9c6b54f663d9462fbb55e37/app/build.gradle#L71-L73
Moreover, this also prevent us from running the project at its starting point, because Hilt produces the following issue:
com\example\android\dagger\di\AppSubcomponents.java:7: error: [Hilt]
public final class AppSubcomponents {
^
com.example.android.dagger.di.AppSubcomponents must also be annotated with @InstallIn.
[Hilt] Processing did not complete. See error above for details
At step 8. Migrating another scoped component, the instructions refer to call initData()
on the UserDataRepository
yet the method does not exist nor is there any obvious alternative code that's analogous to it.
android-dagger-to-hilt/app/build/tmp/kapt3/stubs/debug/com/example/android/dagger/di/AppSubcomponents.java:7: error: [Hilt]
public final class AppSubcomponents {
^
com.example.android.dagger.di.AppSubcomponents must also be annotated with @Installin.
[Hilt] Processing did not complete. See error above for details.
e: /home/ny/AndroidStudioProjects/DaggerHilt/android-dagger-to-hilt/app/build/tmp/kapt3/stubs/debug/com/example/android/dagger/di/StorageModule.java:7: error: [Hilt]
public abstract class StorageModule {
^
com.example.android.dagger.di.StorageModule must also be annotated with @Installin.
[Hilt] Processing did not complete. See error above for details.
w: warning: The following options were not recognized by any processor: '[dagger.hilt.android.internal.disableAndroidSuperclassValidation, kapt.kotlin.generated]'
e: /home/ny/AndroidStudioProjects/DaggerHilt/android-dagger-to-hilt/app/build/tmp/kapt3/stubs/debug/com/example/android/dagger/di/AppSubcomponents.java:7: error: [Hilt]
public final class AppSubcomponents {
^
com.example.android.dagger.di.AppSubcomponents must also be annotated with @Installin.
�[1;31m[Hilt] Processing did not complete. See error above for details.�[0m
e: /home/ny/AndroidStudioProjects/DaggerHilt/android-dagger-to-hilt/app/build/tmp/kapt3/stubs/debug/com/example/android/dagger/di/StorageModule.java:7: error: [Hilt]
public abstract class StorageModule {
^
com.example.android.dagger.di.StorageModule must also be annotated with @Installin.
�[1;31m[Hilt] Processing did not complete. See error above for details.�[0m
w: warning: The following options were not recognized by any processor: '[dagger.hilt.android.internal.disableAndroidSuperclassValidation, kapt.kotlin.generated]'
The error goes away when I remove all references to hilt in the module's build,gradle.
Hello, I tried finding a solution to connect the existing library DependencyComponent to Hilt ApplicationComponent. It looks like it is impossible at the moment.
Could you please clarify that.
Example:
we have the following gradle modules structure:
// from feature1 lib module
interface Feature1DependencyComponent {
val feature1Api: Feature1Api
}
// from app module
@Component(
dependencies = [Feature1DependencyComponent::class],
modules = [AppModule1::class, AppModule2::class]
)
@Singleton
interface ApplicationComponent {
val feature1Api: Feature1Api // to have explicit exposing
}
As you can see @Module
can't be used in feature1
because it doesn't know anything about ApplicationComponent to use with @InstallIn
.
Question: how to connect Feature1DependencyComponent
without using @BindsInstance
to Hilt ApplicationComponent?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.