我收到此错误的最后几天,但仅限于Android版本低于4.4的设备。
java.lang.ExceptionInInitializerError
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:217)
at com.orm.util.ReflectionUtil.getDomainClass(ReflectionUtil.java:273)
at com.orm.util.ReflectionUtil.getDomainClasses(ReflectionUtil.java:257)
at com.orm.SchemaGenerator.createDatabase(SchemaGenerator.java:37)
at com.orm.SugarDb.onCreate(SugarDb.java:26)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:252)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164)
at com.orm.SugarDb.getDB(SugarDb.java:36)
at com.orm.SugarRecord.find(SugarRecord.java:194)
at com.orm.SugarRecord.listAll(SugarRecord.java:99)
at co.getcontrol.service.AccountsService.getAnyAccount(AccountsService.java:142)
at co.getcontrol.ui.MainActivity.onCreate(MainActivity.java:191)
at android.app.Activity.performCreate(Activity.java:5244)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1082)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2034)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2095)
at android.app.ActivityThread.access$600(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1201)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4849)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.Error
at com.timgroup.jgravatar.internal.com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator$1.run(UnsignedBytes.java:259)
at java.security.AccessController.doPrivileged(AccessController.java:45)
at com.timgroup.jgravatar.internal.com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator.<clinit>(UnsignedBytes.java:248)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:217)
at com.orm.util.ReflectionUtil.getDomainClass(ReflectionUtil.java:273)
at com.orm.util.ReflectionUtil.getDomainClasses(ReflectionUtil.java:257)
at com.orm.SchemaGenerator.createDatabase(SchemaGenerator.java:37)
at com.orm.SugarDb.onCreate(SugarDb.java:26)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:252)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164)
at com.orm.SugarDb.getDB(SugarDb.java:36)
at com.orm.SugarRecord.find(SugarRecord.java:194)
at com.orm.SugarRecord.listAll(SugarRecord.java:99)
at co.getcontrol.service.AccountsService.getAnyAccount(AccountsService.java:142)
at co.getcontrol.ui.MainActivity.onCreate(MainActivity.java:191)
at android.app.Activity.performCreate(Activity.java:5244)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1082)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2034)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2095)
at android.app.ActivityThread.access$600(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1201)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4849)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
at dalvik.system.NativeStart.main(Native Method)
如你所见,有SugarDb。这不完全是我的项目,我不知道Sugar如何添加到项目中 - gradle中没有这种依赖,文件夹中没有extern库。此外,您可以看到错误日志中有jgravatar库。但应用程序在这个地方崩溃,这里没有任何jgravatar对象。稍后会在其他活动中使用它。
我想这是库的错误,因为代码适用于其他设备。