Stackoverflow
gson type
!!! FAILED BINDER TRANSACTION !!!
등이 에러가 났다. 3일 동안 앱 진행을 못했다. 결국 해냈다. 정확한 원인은 모르겠지만, 다음과 같이 하면된다.
이전엔 이렇게 Gson을 선언 했었다.
Gson gson = new GsonBuilder()
.setLenient()
.create();
여기에 excludeFieldsWithoutExposeAnnotation()를 추가해준다.
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.setLenient()
.create();
그리고 사용되는 파라미터들에 @Expose 어노테이션을 붙여준다.
public class SearchItem implements Serializable {
@Expose
String category;
@Expose
String subcategory;
@Expose
String country;
@Expose
String writer;
@Expose
String city;
@Expose
Date date;
@Expose
String keyword;
}
일단, SearchItem은 이렇게 하지 않아도 되는데, UserItem에서 문제가 발생했기 때문에 다른 Item들도 바꿔줘야한다. UserItem에서 문제가 발생한 이유는 서버와 통신을 할 때 사용되지 않는 변수들이 있어서 그런 것 같다.
'Computer > Android' 카테고리의 다른 글
1인 Android 개발자에게 도움이 되는 행사/정보/단톡 (0) | 2018.07.27 |
---|---|
[Android Studio] 폰트(Font)가 필요하다면? (0) | 2018.07.27 |
[Android Studio]retrofit+Node.js, Expected BEGIN_OBJECT but was BEGIN_ARRAY에러 (0) | 2018.07.27 |
[Android Studio] Spinner, default 주기 (0) | 2018.07.27 |
[Android Studio] Context정리 - getContext(), getBaseContext(), getApplicationContext() 등 (0) | 2018.07.27 |