android - Does not work when use ProGuard -
the logcat below. wrong?
07-24 10:54:13.529: e/androidruntime(12130): fatal exception: asynctask #3
07-24 10:54:13.529: e/androidruntime(12130): java.lang.runtimeexception: error occured while executing doinbackground()
07-24 10:54:13.529: e/androidruntime(12130): @ android.os.asynctask$3.done(asynctask.java:299)
07-24 10:54:13.529: e/androidruntime(12130): @ java.util.concurrent.futuretask$sync.innersetexception(futuretask.java:273)
07-24 10:54:13.529: e/androidruntime(12130): @ java.util.concurrent.futuretask.setexception(futuretask.java:124)
07-24 10:54:13.529: e/androidruntime(12130): @ java.util.concurrent.futuretask$sync.innerrun(futuretask.java:307)
07-24 10:54:13.529: e/androidruntime(12130): @ java.util.concurrent.futuretask.run(futuretask.java:137)
07-24 10:54:13.529: e/androidruntime(12130): @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1076)
07-24 10:54:13.529: e/androidruntime(12130): @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:569)
07-24 10:54:13.529: e/androidruntime(12130): @ java.lang.thread.run(thread.java:856)
07-24 10:54:13.529: e/androidruntime(12130): caused by: java.lang.assertionerror: illegal type variable reference
07-24 10:54:13.529: e/androidruntime(12130): @ org.apache.harmony.luni.lang.reflect.implforvariable.resolve(implforvariable.java:113)
07-24 10:54:13.529: e/androidruntime(12130): @ org.apache.harmony.luni.lang.reflect.implforvariable.getgenericdeclaration(implforvariable.java:127)
07-24 10:54:13.529: e/androidruntime(12130): @ org.apache.harmony.luni.lang.reflect.implforvariable.hashcode(implforvariable.java:46)
07-24 10:54:13.529: e/androidruntime(12130): @ java.util.arrays.hashcode(arrays.java:1260)
07-24 10:54:13.529: e/androidruntime(12130): @ com.google.gson.internal.$gson$types$parameterizedtypeimpl.hashcode(sourcefile:475)
07-24 10:54:13.529: e/androidruntime(12130): @ com.google.gson.reflect.typetoken.(sourcefile:64)
07-24 10:54:13.529: e/androidruntime(12130): @ com.gaozhi.wh.asynctask.myasynctask$2$1.(sourcefile:78)
07-24 10:54:13.529: e/androidruntime(12130): @ com.gaozhi.wh.asynctask.myasynctask$2.call(sourcefile:78)
07-24 10:54:13.529: e/androidruntime(12130): @ com.gaozhi.wh.asynctask.myasynctask$2.call(sourcefile:1)
07-24 10:54:13.529: e/androidruntime(12130): @ com.gaozhi.wh.utils.async.asynctaskutils$2.doinbackground(sourcefile:114)
07-24 10:54:13.529: e/androidruntime(12130): @ com.gaozhi.wh.utils.async.asynctaskutils$2.doinbackground(sourcefile:1)
07-24 10:54:13.529: e/androidruntime(12130): @ android.os.asynctask$2.call(asynctask.java:287)
07-24 10:54:13.529: e/androidruntime(12130): @ java.util.concurrent.futuretask$sync.innerrun(futuretask.java:305) 07-24 10:54:13.529: e/androidruntime(12130): ... 4 more
i found caused line of code error
info = gsonutils.getmutilebean(result,new typetoken<jsonresult<t>>() {}.gettype());
public static <t> t getmutilebean(string jsondata, type type) throws exception { return new gson().fromjson(jsondata, type); }
.
but had add proguard configuration gson
# gson uses generic type information stored in class file when working fields. proguard
# removes such information default, configure keep of it.
-keepattributes signature
# using gson @expose annotation
-keepattributes annotation
# gson specific classes
-keep class sun.misc.unsafe { *; }
#-keep class com.google.gson.stream.** { *; }
# application classes serialized/deserialized on gson
-keep class com.google.gson.examples.android.model.** { *; }
you may need add
-keepattributes enclosingmethod
Comments
Post a Comment