Alex
Alex

Reputation: 1934

No type arguments expected for class Call

I'm having an issue.I have project and then i copy paste into an other new project and i'm facing this error

No type arguments expected for class Call

In the first project i didn't have any problem... Here is my interface class which i have the error

interface ApiInterface {
    @GET("data/2.5/weather?q=Prague")
    fun getWeatherData(@Query("units") units: String,
                       @Query("appid") appId: String)
            :Call<WeatherData> //here is the error

}

and here is my WeatherData class

data class WeatherData(
        @SerializedName("coord") val coord: Coord,
        @SerializedName("weather") val weather: List<Weather>,
        @SerializedName("base") val base: String,
        @SerializedName("main") val main: TemperatureData,
        @SerializedName("visibility") val visibility: Int,
        @SerializedName("wind") val wind: Wind,
        @SerializedName("clouds") val clouds: Clouds,
        @SerializedName("dt") val dt: Int,
        @SerializedName("sys") val sys: Sys,
        @SerializedName("id") val id: Int,
        @SerializedName("name") val name: String,
        @SerializedName("cod") val cod: Int
)

data class Sys(
        @SerializedName("type") val type: Int,
        @SerializedName("id") val id: Int,
        @SerializedName("message") val message: Double,
        @SerializedName("country") val country: String,
        @SerializedName("sunrise") val sunrise: Int,
        @SerializedName("sunset") val sunset: Int
)

data class Coord(
        @SerializedName("lon") val lon: Double,
        @SerializedName("lat") val lat: Double
)

data class TemperatureData(
        @SerializedName("temp") val temp: Double,
        @SerializedName("pressure") val pressure: Int,
        @SerializedName("humidity") val humidity: Int,
        @SerializedName("temp_min") val tempMin: Double,
        @SerializedName("temp_max") val tempMax: Double
)

data class Weather(
        @SerializedName("id") val id: Int,
        @SerializedName("main") val main: String,
        @SerializedName("description") val description: String,
        @SerializedName("icon") val icon: String
)

data class Clouds(
        @SerializedName("all") val all: Int
)

data class Wind(
        @SerializedName("speed") val speed: Double,
        @SerializedName("deg") val deg: Int

Upvotes: 24

Views: 25452

Answers (3)

Toda
Toda

Reputation: 41

If you import both Retrofit and Okhttp, make sure the Call class you use is the one from Retrofit:

import retrofit2.Call

not:

import okhttp3.Call

Upvotes: 4

ollaw
ollaw

Reputation: 2193

Just verify that you've imported the correct package from Retrofit.

The correct one is

retrofit2.Call

not to be confused with, for example

android.telecom.Call

Upvotes: 95

Khalid Aziz
Khalid Aziz

Reputation: 29

Give a look to import section and check whether retrofit2.Call library is imported or not ,sometimes it gets touched with okhttp3.call but you have to use the retrofit one.so make sure the library is imported to the interface/class.

Upvotes: 2

Related Questions