IT_Programming/Dev Tools
ProGuard keep Generic
JJun ™
2013. 7. 16. 07:35
출처: http://lsit81.tistory.com/entry/ProGuard-keep-Generic
Gson을 이용하여 JSON 데이터를 파싱하는 기능을 구현하였습니다.
그런데 해당 프로젝트에 ProGuard를 적용시켜 동작을 시켜보니 JSonParserException 이 나타나는
문제가 발생되어 Decompile을 통해 원인을 알아보니 ProGuard를 적용시키면서 Generic으로 선언된
변수에서 "<Generic>" 선언 부가 제거된 것을 확인 할 수 있었습니다.
* 원본 코드
public Collection<Theme> Themes; |
* Proguard가 적용되고 난 이후 코드
public Collection Themes; |
위와 같은 문제가 발생되어 해결책을 알아본 결과 "proguard.cfg"에
-keepattributes Signature
를 추가함으로써 해당 문제를 해결할 수 있었습니다.
다음은 ProGuard Manual에 표시된 원문입니다.
The "Signature" attribute is required to be able to access generic types when compiling in JDK 5.0 and higher. |