June 2022 Edition page 408 Error

Following the book there is an error “No value passed for parameter service” in the line:

val flickrApi: FlickrApi = retrofit.create()
I searched and found the value has to be: FlickrApi::class.java
So the corrected line has to be:
val flickrApi: FlickrApi = retrofit.create(FlickrApi::class.java)
Then the file can be run in the emulator.

Thank you for bringing this up! Both approaches work, but you might have had some issues on the first if you didn’t import the right thing. The second approach has been in Retrofit since the early Java days, but the first approach is actually a Kotlin extension function (see: retrofit/KotlinExtensions.kt at master · square/retrofit · GitHub). If you forget to import that Kotlin extension function, then you are going to run into the issue you see here.