2016-08-30 3 views
2

앱을 출시하려는 동안 오류가 발생했습니다. 향후 Gson에서 오류가 계속 발생할 가능성이 있습니다. 전문 사용중인 공인 간부가있는 동안 그러나 왜 나는 모릅니다.Android proguard Gson 오류

이러한 라이브러리는 현재 사용 중입니다.

-libraryjars libs 
-keepattributes SourceFile,LineNumberTable 
-dontwarn okio.** 
-dontnote retrofit2.Platform 
-dontnote retrofit2.Platform$IOS$MainThreadExecutor 
-dontwarn retrofit2.Platform$Java8 
-keepattributes Signature 
-keepattributes Exceptions 
-keepattributes Signature 
-keepattributes *Annotation* 
-keep class sun.misc.Unsafe { *; } 
-keep class com.google.gson.examples.android.model.** { *; } 
-keep class com.google.gson.** { *; } 

APK 잘 이루어진다 : 다음

dependencies { 
compile fileTree(include: ['*.jar'], dir: 'libs') 
apt 'com.jakewharton:butterknife-compiler:8.4.0' 
compile 'com.jakewharton:butterknife:8.4.0' 
compile 'com.android.support:support-v4:24.1.1' 
compile 'com.android.support:support-annotations:24.1.1' 
compile 'com.android.support:appcompat-v7:24.1.1' 
compile 'com.android.support:design:24.1.1' 
compile 'io.reactivex:rxandroid:1.2.1' 
compile 'com.trello:rxlifecycle:0.6.1' 
compile 'com.trello:rxlifecycle-components:0.6.1' 
compile 'com.squareup.retrofit2:retrofit:2.1.0' 
compile 'com.squareup.retrofit2:converter-gson:2.1.0' 
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0' 
compile 'com.squareup.okhttp3:okhttp:3.3.1' 
compile 'com.squareup.okhttp3:okhttp-urlconnection:3.3.1' 
compile 'com.squareup.okhttp3:logging-interceptor:3.3.1' 
compile 'com.github.bumptech.glide:glide:3.7.0' 
compile 'jp.wasabeef:glide-transformations:2.0.1' 
compile 'com.github.captain-miao:autofittextview:0.2.2' 
compile 'com.artemzin.rxjava:proguard-rules:1.1.9.0' 

ProGuard에서 또한 사용된다. 그러나 실행하면 다음 오류가 발생합니다.

STACK_TRACE=java.lang.AssertionError: java.lang.NoSuchFieldException: OPTION 
at com.google.gson.internal.bind.TypeAdapters$EnumTypeAdapter.<init>  (TypeAdapters.java:808) 
at com.google.gson.internal.bind.TypeAdapters$30.create(TypeAdapters.java:834) 
at com.google.gson.Gson.getAdapter(Gson.java:423) 
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:115) 
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:164) 
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:100) 
at com.google.gson.Gson.getAdapter(Gson.java:423) 
at d.b.a.a.a(GsonConverterFactory.java:63) 
at d.at.a(Retrofit.java:325) 
at d.at.b(Retrofit.java:308) 
at d.ax.c(ServiceMethod.java:704) 
at d.ax.a(ServiceMethod.java:167) 
at d.at.a(Retrofit.java:166) 
at d.au.invoke(Retrofit.java:145) 
at java.lang.reflect.Proxy.invoke(Proxy.java:393) 
at $Proxy2.b(Unknown Source) 

레트로 적합이 사용하고 있습니다.

  net = new Retrofit.Builder() 
       .baseUrl(SERVER_URL) 
       .addConverterFactory(GsonConverterFactory.create()) //Json Parser 
       .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) //Rxandroid 
       .client(client) 
       .build() 
       .create(xxx.class); 

답변

3

당신은 당신이 GSON를 통해/역 직렬화를 직렬화하여 모델입니다 응용 프로그램에서 실제 패키지에이 라인을

-keep class com.google.gson.examples.android.model.** { *; }

을 변경해야합니다.

+0

감사합니다. 그것은 잘 작동합니다. – takk