Retrofit2 Failed to connect to 에러해결 및 기타 정보
첫번째
Retrofit2 가지고 쓸려니깐 자꾸 아래와 같은 에러가 뜨길래 곰곰히 생각해봄
Could not locate converter for class
이게 뭔문제냐면 retrofit2 에서는 converter 가 빠져있기때문에 내가 넣어줘야한다고 하드라...
바로 다음과 같이 addConverterFactory 부분! 참고로 Converter 는 종류가 많으며 retroFit2 하고 버전을 동일하게 써야한다고한다
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
두번째
기껏 위에 문제 해결하니 아래의 문제를 뱉어냄
java.net.ConnectException: Failed to connect to /127.0.0.1:8080
알고보니 테스트할 기기와 소스가 있는 컴퓨터? 두개의 기기의 인터넷이 같은걸 잡아야된다는 글을 읽었다
뭐 로컬은 그렇긴한데 www.api.naver.com
이런것들은 인터넷만되면되니까... 무튼 기기가 단순히 USB 로 연결되어있다고 인터넷이 되는것이 아니라는것을 깨달음..하 찹찹
세번째
두번째는 휴대폰을 홍미노트쓰는데 최신인 파이버젼이다 근데...아래와 같은 에러를 밷었다
CLEARTEXT communication to 127.0.0.1:8080 not permitted by network security policy
이건또 무엇인가...찾아보니 박상권님의 블로그를 보고 알게됨 압도적감사...ㅜㅜ
공식적으로 https 로만 쓰게끔 바꾸었다는데 물론 예외를 만들순있다 예외적인것들은 박상권님 블로그를 통해 확인하시길
출처
https://stackoverflow.com/questions/32343183/retrofit-could-not-locate-converter-for-class-crashing-app
https://stackoverflow.com/questions/47609995/retrofit-cant-connect-to-hapi-server-localhost
https://gun0912.tistory.com/80