Welcome back.
We use Hilt for dependency injection and we talked about it in the previous videos.
Also we talked about retrofit in the previous sections.
So please go back to learn more about the hilt and retrofit libraries.
We will use retrofit when using the places API to make the calls to the API and get the response.
And we use Hilt for dependency injection.
I'll skip the retrofit section now in order to add it with the places API and make everything clear.
Now let's add the hilt part.
Here we need the hilt framework to make dependency injections.
So go to Google search for hilt dependency Android.
And now you'll be directed to Developer.android.com.
Or you can simply search here to Hilt Android.
Okay.
And let's copy this plugin.
You need to add it to your projects.
So go to Build.gradle Project.
Add this plugin and we need a compiler.
So I'm not gonna use the ordinary compiler I'm gonna use the KSB.
Okay.
So if this, uh, this is our, um, implementation with KSB Kotlin symbol processing tool.
Okay.
So I'm not gonna use Kapt or not gonna use the annotation processor.
KSB is the latest version of Kotlin symbol processing and the annotation processing.
Back to Google, go to KSB Android and you can select the Kotlin symbol processing API.
But I prefer going to Kotlin lang org to get the latest dependencies.
And here this is our KSB version.
Copy it and paste it here.
Then we need the Kotlin Java JVM.
Okay.
So if you scroll down we need to get the Kotlin JVM, copy it.
And the latest version is Point to one.
Paste it here and set the Apply False.
Click sync.
Now let's move to Build.gradle file app level.
We need to apply those plugins here in the plugins section.
So ID you can get them from here DevTools.
Copy it and paste it here.
This is the ID the KSP for the KSP to apply this version.
Now we need to apply the hilt Android.
So back to here id com dot google dot dagger dot hilt Android.
Okay we talked about this in the previous videos.
Or you can go back to here and set the compiler and get the JVM from here okay.
This is very simple.
Now let's copy this.
Of course we'll get this error.
The hilt Android Gradle plugin is applied but not but no dependency for hilt.
We need to add it.
So scroll down to here.
Let's add the hilt dependencies.
And as we add it before we're we're gonna add it here using the implementation.
Com dot google dagger dash Android.
You can get it from here.
Scroll up.
You get this implementation using dagger.
Or you can go back to the dependency injection in Developer.android.com.
And you get this implementation.
I prefer using this implementation because this is the latest version and the updated version.
This is for Ccbp and this is an example using Ccbp with uh with dagger.
But I'm not gonna use dagger, I'm going to use hilt.
So this is more professional.
Copy this implementation and paste it here.
And we need to add the Ccbp for telling that a hilt that hey I'm going to use Ccbp with you.
Also let's sync.
Now try again.
All errors are being solved.
Now let's add that last thing, which is the implementation for Android Health Navigation compose.
So Android X dot hilt and we need to use the navigation.
We talked about navigation in the previous videos.
So as a quick recap we're going to use it in order to pass between in the constructor and between Composables
the hilt ViewModel.
So since we are using the hilt ViewModel and the ViewModel in our application, we need to use the navigation
in order to pass it between Composables and between screens.
Okay, click sync.
Now in the next videos we're going to add retrofit.
So I'll keep this for later.
And the places API we're going to use them in the previous videos.
So let me cut this from here and let me paste it here okay.
So in the next videos we're going to add the places API and retrofit for our application.