Hello,I use gson lib for my android application.It works in many phones very
well,but in some mobile it can not work.
Here is the stack trace.
HTC DesireHD G10:
01-05 09:49:50.553: W/System.err(11264): java.lang.TypeNotPresentException:
Type com.ifeng.news2.bean.BaseItem not present
01-05 09:49:50.573: W/System.err(11264): at
org.apache.harmony.luni.lang.reflect.ImplForType.getRawType(ImplForType.java:64)
01-05 09:49:50.573: W/System.err(11264): at
org.apache.harmony.luni.lang.reflect.ImplForType.getResolvedType(ImplForType.jav
a:73)
01-05 09:49:50.573: W/System.err(11264): at
org.apache.harmony.luni.lang.reflect.ListOfTypes.getResolvedTypes(ListOfTypes.ja
va:68)
01-05 09:49:50.573: W/System.err(11264): at
org.apache.harmony.luni.lang.reflect.ImplForType.getResolvedType(ImplForType.jav
a:72)
01-05 09:49:50.573: W/System.err(11264): at
org.apache.harmony.luni.lang.reflect.Types.getType(Types.java:29)
01-05 09:49:50.573: W/System.err(11264): at
java.lang.reflect.Field.getGenericType(Field.java:191)
01-05 09:49:50.573: W/System.err(11264): at
com.google.gson.TypeInfoFactory.getTypeInfoForField(TypeInfoFactory.java:53)
01-05 09:49:50.573: W/System.err(11264): at
com.google.gson.ObjectNavigator.navigateClassFields(ObjectNavigator.java:148)
01-05 09:49:50.573: W/System.err(11264): at
com.google.gson.ObjectNavigator.accept(ObjectNavigator.java:123)
01-05 09:49:50.573: W/System.err(11264): at
com.google.gson.JsonDeserializationVisitor.visitChild(JsonDeserializationVisitor
.java:107)
01-05 09:49:50.573: W/System.err(11264): at
com.google.gson.JsonDeserializationVisitor.visitChildAsObject(JsonDeserializatio
nVisitor.java:95)
01-05 09:49:50.573: W/System.err(11264): at
com.google.gson.JsonObjectDeserializationVisitor.visitObjectField(JsonObjectDese
rializationVisitor.java:62)
01-05 09:49:50.573: W/System.err(11264): at
com.google.gson.ObjectNavigator.navigateClassFields(ObjectNavigator.java:156)
01-05 09:49:50.573: W/System.err(11264): at
com.google.gson.ObjectNavigator.accept(ObjectNavigator.java:123)
01-05 09:49:50.573: W/System.err(11264): at
com.google.gson.JsonDeserializationContextDefault.fromJsonObject(JsonDeserializa
tionContextDefault.java:73)
01-05 09:49:50.573: W/System.err(11264): at
com.google.gson.JsonDeserializationContextDefault.deserialize(JsonDeserializatio
nContextDefault.java:51)
01-05 09:49:50.573: W/System.err(11264): at
com.google.gson.Gson.fromJson(Gson.java:495)
01-05 09:49:50.573: W/System.err(11264): at
com.google.gson.Gson.fromJson(Gson.java:444)
01-05 09:49:50.573: W/System.err(11264): at
com.google.gson.Gson.fromJson(Gson.java:396)
01-05 09:49:50.573: W/System.err(11264): at
com.google.gson.Gson.fromJson(Gson.java:372)
01-05 09:49:50.573: W/System.err(11264): at
com.ifeng.news2.bean.ListUnit.parse(ListUnit.java:137)
01-05 09:49:50.573: W/System.err(11264): at
com.ifeng.news2.test.ListUnitTest.testParseList(ListUnitTest.java:138)
01-05 09:49:50.573: W/System.err(11264): at
java.lang.reflect.Method.invokeNative(Native Method)
01-05 09:49:50.573: W/System.err(11264): at
java.lang.reflect.Method.invoke(Method.java:521)
01-05 09:49:50.573: W/System.err(11264): at
junit.framework.TestCase.runTest(TestCase.java:154)
01-05 09:49:50.573: W/System.err(11264): at
junit.framework.TestCase.runBare(TestCase.java:127)
01-05 09:49:50.573: W/System.err(11264): at
junit.framework.TestResult$1.protect(TestResult.java:106)
01-05 09:49:50.573: W/System.err(11264): at
junit.framework.TestResult.runProtected(TestResult.java:124)
01-05 09:49:50.573: W/System.err(11264): at
junit.framework.TestResult.run(TestResult.java:109)
01-05 09:49:50.573: W/System.err(11264): at
junit.framework.TestCase.run(TestCase.java:118)
01-05 09:49:50.573: W/System.err(11264): at
android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
01-05 09:49:50.573: W/System.err(11264): at
android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
01-05 09:49:50.573: W/System.err(11264): at
android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:52
0)
01-05 09:49:50.573: W/System.err(11264): at
android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1580)
01-05 09:49:50.573: W/System.err(11264): Caused by:
java.lang.ClassNotFoundException: com.ifeng.news2.bean.BaseItem
01-05 09:49:50.573: W/System.err(11264): at
java.lang.Class.classForName(Native Method)
01-05 09:49:50.573: W/System.err(11264): at
java.lang.Class.forName(Class.java:235)
01-05 09:49:50.573: W/System.err(11264): at
org.apache.harmony.luni.lang.reflect.ImplForType.getRawType(ImplForType.java:62)
01-05 09:49:50.573: W/System.err(11264): ... 33 more
01-05 09:49:50.573: W/System.err(11264): Caused by:
java.lang.NoClassDefFoundError: com.ifeng.news2.bean.BaseItem
01-05 09:49:50.573: W/System.err(11264): ... 36 more
01-05 09:49:50.573: W/System.err(11264): Caused by:
java.lang.ClassNotFoundException: com.ifeng.news2.bean.BaseItem in loader
dalvik.system.PathClassLoader[.]
01-05 09:49:50.583: W/System.err(11264): at
dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
01-05 09:49:50.583: W/System.err(11264): at
java.lang.ClassLoader.loadClass(ClassLoader.java:573)
01-05 09:49:50.583: W/System.err(11264): at
java.lang.ClassLoader.loadClass(ClassLoader.java:532)
01-05 09:49:50.583: W/System.err(11264): ... 36 more
That's strange.I write test case like that:
Class.forName("com.ifeng.news2.bean.BaseItem");
//parseFrom json String
Class.forName is ok,fromJson occured a TypeNotPresentException
Thank you for help.
Original issue reported on code.google.com by ifen...@gmail.com on 5 Jan 2012 at 2:04
Original issue reported on code.google.com by
ifen...@gmail.com
on 5 Jan 2012 at 2:04