강의

멘토링

커뮤니티

Inflearn Community Q&A

tnghks21003340's profile image
tnghks21003340

asked

[Intermediate] Kind JETPACK Introduction <Part 1> (Android Kotlin)

Retrofit Simple Example - 1

Retrfit 에러

Written on

·

115

0

개발자님 혹시 제가 android 2024.2.2 버전을 사용하고 있는데 이 버전에서는 dependencies부분에 retrofit2을 어떻게 추가해야하는지 알 수 있을까요?

 

아래와 같이 두 방법으로 시도해봤는데 추가가 안되는 거 같아 질문드립니다.

 

implementation("com.squareup.retrofit2:retrofit:2.9.0")
implementation("com.squareup.retrofit2:converter-gson:2.9.0")

 

implementation(libs.retrofit)
implementation(libs.converter.gson)
androidkotlinjetpack

Answer 2

0

tnghks21003340님의 프로필 이미지
tnghks21003340
Questioner

해결됐습니다 감사합니다!

0

bokchi님의 프로필 이미지
bokchi
Instructor

안녕하세요

전체 코드를 실행해볼 수 있게 프로젝트를 구글드라이브/깃허브 링크로 공유해주시면 살펴보겠습니다.

tnghks21003340님의 프로필 이미지
tnghks21003340
Questioner

bokchi님의 프로필 이미지
bokchi
Instructor

myApi 파일에 import가 잘못되었네요

 

package com.example.retrofit_ex1


import retrofit2.Call
import retrofit2.http.GET

interface MyApi {

    @GET("posts/1")
    fun getPost1() : Call<Post>
}

이렇게 변경해보시겠어요?

기존에는

 

package com.example.retrofit_ex1

import android.telecom.Call
import retrofit2.http.GET

interface MyApi {

    @GET("posts/1")
    fun getPost1() : Call<Post>
}

이렇게 되어있었습니다.

tnghks21003340's profile image
tnghks21003340

asked

Ask a question