Android에서 Retrfoit2와 함께 Youtube API를 사용하려고하는데 Jackson / JSON 변환기 모두 개체를 구문 분석 할 수 없습니다.
YoutubeService
public interface YoutubeService {
@GET("playlistItems?part=snippet%2CcontentDetails")
Observable<PlaylistItemListResponse> getVideos(@Query("maxResults") Integer maxResults,
@Query("pageToken")String pageToken,
@Query("playlistId")String playlistId,
@Query("key")String key);
}
사용 방법은 다음과 같습니다.
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(YouTube.DEFAULT_BASE_URL)
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(JacksonConverterFactory.create())
.build();
youtubeService = retrofit.create(YoutubeService.class);
다음은 내가 받고있는 오류입니다.
reactivex.exceptions.OnErrorNotImplementedException: field com.google.api.services.youtube.model.PlaylistItemListResponse.pageInfo has type com.google.api.services.youtube.model.PageInfo, got java.util.LinkedHashMap (through reference chain: com.google.api.services.youtube.model.PlaylistItemListResponse["pageInfo"])
이 PlaylistItemResponse 모델입니다
PlaylistItemResponse 용 Java 파일
이것은 응답입니다
누군가이 문제를 해결하는 방법을 안내 할 수 있습니까?
나는 당신의 문제에 대해 더 깊이 이해할 수 없지만 아래와 같이 변경하십시오.
1. Gson으로 만들기
addConverterFactory(GsonConverterFactory.create(gson))
2. PlaylistItemListResponse
아래와 같이 모델 클래스 를 변경하십시오 .
모델 클래스 문제에 관한 모든 것이기 때문입니다.
즐거운 코딩
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다