Sitemap

Day90 of #100DaysOfCode

2 min readMay 10, 2022

--

Press enter or click to view image in full size
Day90 of #100DaysOfCode

Hii folks 🙌

Today I will be continuing the same pathway in which we will learn about Web Services and Retrofit dependencies

Unit 4: Internet

Pathway 2: Get and Display Data

https://developer.android.com/courses/android-basics-kotlin/course

Retrofit Library

The retrofit library will communicate with the backend. It creates URI’s for the web service based on the parameters we pass to it.

Press enter or click to view image in full size

Adding Retrofit dependencies

  • We will then open the project’s top-level level build.gradle(Project: MarsPhotos) file. We will see two repositories, google(), mavenCentral().
repositories {
google()
mavenCentral()
}
  • Then we will Open module level gradle file, build.gradle (Module: MarsPhots.app).
  • In the dependencies section, we will add these lines for the Retrofit libraries
// Retrofit 
implementation "com.squareup.retrofit2:retrofit:2.9.0"
// Retrofit with Moshi Converter
implementation "com.squareup.retrofit2:converter-scalars:2.9.0"
  • Click Sync Now to rebuild the project with the new dependencies.

Add support for Java 8 language features

  • To use the built-in features, we need the following code in the module’s build.gradle file. This step is already done for us, so we will make sure the following code is present in our build.gradle(Module: MarsPhotos.app).
android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = '1.8'
}
}

That is all for Day90 ✅

Thanks for reading, See you tomorrow!

--

--

No responses yet