WEBVTT

00:00.080 --> 00:01.040
Welcome back.

00:01.080 --> 00:06.080
We use Hilt for dependency injection and we talked about it in the previous videos.

00:06.360 --> 00:10.000
Also we talked about retrofit in the previous sections.

00:10.320 --> 00:15.520
So please go back to learn more about the hilt and retrofit libraries.

00:15.560 --> 00:25.040
We will use retrofit when using the places API to make the calls to the API and get the response.

00:25.360 --> 00:28.400
And we use Hilt for dependency injection.

00:28.520 --> 00:36.400
I'll skip the retrofit section now in order to add it with the places API and make everything clear.

00:36.680 --> 00:39.520
Now let's add the hilt part.

00:39.720 --> 00:45.960
Here we need the hilt framework to make dependency injections.

00:46.040 --> 00:50.200
So go to Google search for hilt dependency Android.

00:50.200 --> 00:53.840
And now you'll be directed to Developer.android.com.

00:53.840 --> 00:57.680
Or you can simply search here to Hilt Android.

00:57.720 --> 00:58.280
Okay.

00:58.320 --> 01:00.760
And let's copy this plugin.

01:00.800 --> 01:03.200
You need to add it to your projects.

01:03.200 --> 01:06.620
So go to Build.gradle Project.

01:06.620 --> 01:11.140
Add this plugin and we need a compiler.

01:11.140 --> 01:17.340
So I'm not gonna use the ordinary compiler I'm gonna use the KSB.

01:17.500 --> 01:18.060
Okay.

01:18.260 --> 01:26.540
So if this, uh, this is our, um, implementation with KSB Kotlin symbol processing tool.

01:26.580 --> 01:27.060
Okay.

01:27.260 --> 01:32.140
So I'm not gonna use Kapt or not gonna use the annotation processor.

01:32.300 --> 01:37.980
KSB is the latest version of Kotlin symbol processing and the annotation processing.

01:37.980 --> 01:45.580
Back to Google, go to KSB Android and you can select the Kotlin symbol processing API.

01:45.860 --> 01:51.460
But I prefer going to Kotlin lang org to get the latest dependencies.

01:51.620 --> 01:55.340
And here this is our KSB version.

01:55.340 --> 01:57.460
Copy it and paste it here.

01:57.700 --> 02:02.300
Then we need the Kotlin Java JVM.

02:02.340 --> 02:02.740
Okay.

02:02.780 --> 02:07.860
So if you scroll down we need to get the Kotlin JVM, copy it.

02:07.860 --> 02:11.930
And the latest version is Point to one.

02:11.970 --> 02:14.690
Paste it here and set the Apply False.

02:14.690 --> 02:15.650
Click sync.

02:15.650 --> 02:21.130
Now let's move to Build.gradle file app level.

02:21.170 --> 02:25.690
We need to apply those plugins here in the plugins section.

02:25.690 --> 02:29.970
So ID you can get them from here DevTools.

02:30.170 --> 02:32.650
Copy it and paste it here.

02:32.850 --> 02:38.050
This is the ID the KSP for the KSP to apply this version.

02:38.170 --> 02:41.890
Now we need to apply the hilt Android.

02:42.250 --> 02:49.690
So back to here id com dot google dot dagger dot hilt Android.

02:49.730 --> 02:52.370
Okay we talked about this in the previous videos.

02:52.490 --> 02:59.610
Or you can go back to here and set the compiler and get the JVM from here okay.

02:59.930 --> 03:01.410
This is very simple.

03:01.450 --> 03:03.890
Now let's copy this.

03:04.170 --> 03:05.850
Of course we'll get this error.

03:05.890 --> 03:12.130
The hilt Android Gradle plugin is applied but not but no dependency for hilt.

03:12.170 --> 03:13.410
We need to add it.

03:13.410 --> 03:15.450
So scroll down to here.

03:15.570 --> 03:18.790
Let's add the hilt dependencies.

03:18.990 --> 03:25.470
And as we add it before we're we're gonna add it here using the implementation.

03:25.590 --> 03:29.790
Com dot google dagger dash Android.

03:29.830 --> 03:31.510
You can get it from here.

03:31.550 --> 03:32.430
Scroll up.

03:32.590 --> 03:36.110
You get this implementation using dagger.

03:36.190 --> 03:41.510
Or you can go back to the dependency injection in Developer.android.com.

03:41.510 --> 03:43.470
And you get this implementation.

03:43.470 --> 03:49.870
I prefer using this implementation because this is the latest version and the updated version.

03:49.870 --> 03:57.110
This is for Ccbp and this is an example using Ccbp with uh with dagger.

03:57.110 --> 04:00.230
But I'm not gonna use dagger, I'm going to use hilt.

04:00.230 --> 04:02.230
So this is more professional.

04:02.430 --> 04:05.670
Copy this implementation and paste it here.

04:06.030 --> 04:14.270
And we need to add the Ccbp for telling that a hilt that hey I'm going to use Ccbp with you.

04:14.430 --> 04:16.390
Also let's sync.

04:16.390 --> 04:17.630
Now try again.

04:17.750 --> 04:19.750
All errors are being solved.

04:19.870 --> 04:27.780
Now let's add that last thing, which is the implementation for Android Health Navigation compose.

04:27.780 --> 04:33.100
So Android X dot hilt and we need to use the navigation.

04:33.100 --> 04:36.020
We talked about navigation in the previous videos.

04:36.300 --> 04:44.060
So as a quick recap we're going to use it in order to pass between in the constructor and between Composables

04:44.100 --> 04:46.060
the hilt ViewModel.

04:46.060 --> 04:52.900
So since we are using the hilt ViewModel and the ViewModel in our application, we need to use the navigation

04:52.900 --> 04:56.540
in order to pass it between Composables and between screens.

04:56.900 --> 04:58.220
Okay, click sync.

04:58.220 --> 05:02.180
Now in the next videos we're going to add retrofit.

05:02.340 --> 05:05.620
So I'll keep this for later.

05:05.620 --> 05:10.300
And the places API we're going to use them in the previous videos.

05:10.460 --> 05:16.740
So let me cut this from here and let me paste it here okay.

05:17.020 --> 05:22.620
So in the next videos we're going to add the places API and retrofit for our application.
