1

最后几天我收到此错误,但仅在 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 对象的地方出现问题。它稍后在其他活动中使用。

我想这是库的问题,因为代码可以在其他设备上运行。

4

1 回答 1

0

我找到了解决方案。问题是 jgravatar 库。我把它改成了gravatar-android现在又可以了

于 2015-11-15T16:18:47.600 回答