realmDb初始化错误

时间:2015-03-06 11:04:20

标签: android realm

我听说RealmDb是一个方便的数据库,可以取代Android平台上的sqlite。

我试图让它在我的galaxy s2 android版本2.3上运行

我使用领域版本0.79.1

然而,我接受了以下按摩:

03-06 12:26:24.820: E/AndroidRuntime(17507): FATAL EXCEPTION: main
03-06 12:26:24.820: E/AndroidRuntime(17507): java.lang.ExceptionInInitializerError
03-06 12:26:24.820: E/AndroidRuntime(17507):    at io.realm.Realm.<init>(Realm.java:199)
03-06 12:26:24.820: E/AndroidRuntime(17507):    at io.realm.Realm.createAndValidate(Realm.java:516)
03-06 12:26:24.820: E/AndroidRuntime(17507):    at io.realm.Realm.create(Realm.java:480)
03-06 12:26:24.820: E/AndroidRuntime(17507):    at io.realm.Realm.getInstance(Realm.java:397)
03-06 12:26:24.820: E/AndroidRuntime(17507):    at io.realm.Realm.getInstance(Realm.java:359)
03-06 12:26:24.820: E/AndroidRuntime(17507):    at io.realm.Realm.getInstance(Realm.java:340)
03-06 12:26:24.820: E/AndroidRuntime(17507):    at com.project.peoples.PersonListActivity.addTestPersons(PersonListActivity.java:134)
03-06 12:26:24.820: E/AndroidRuntime(17507):    at com.project.peoples.PersonListActivity.onCreate(PersonListActivity.java:34)
03-06 12:26:24.820: E/AndroidRuntime(17507):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-06 12:26:24.820: E/AndroidRuntime(17507):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
03-06 12:26:24.820: E/AndroidRuntime(17507):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
03-06 12:26:24.820: E/AndroidRuntime(17507):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-06 12:26:24.820: E/AndroidRuntime(17507):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
03-06 12:26:24.820: E/AndroidRuntime(17507):    at android.os.Handler.dispatchMessage(Handler.java:99)
03-06 12:26:24.820: E/AndroidRuntime(17507):    at android.os.Looper.loop(Looper.java:123)
03-06 12:26:24.820: E/AndroidRuntime(17507):    at android.app.ActivityThread.main(ActivityThread.java:3691)
03-06 12:26:24.820: E/AndroidRuntime(17507):    at java.lang.reflect.Method.invokeNative(Native Method)
03-06 12:26:24.820: E/AndroidRuntime(17507):    at java.lang.reflect.Method.invoke(Method.java:507)
03-06 12:26:24.820: E/AndroidRuntime(17507):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
03-06 12:26:24.820: E/AndroidRuntime(17507):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
03-06 12:26:24.820: E/AndroidRuntime(17507):    at dalvik.system.NativeStart.main(Native Method)
03-06 12:26:24.820: E/AndroidRuntime(17507): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load tightdb-jni: findLibrary returned null
03-06 12:26:24.820: E/AndroidRuntime(17507):    at java.lang.Runtime.loadLibrary(Runtime.java:429)
03-06 12:26:24.820: E/AndroidRuntime(17507):    at java.lang.System.loadLibrary(System.java:554)
03-06 12:26:24.820: E/AndroidRuntime(17507):    at io.realm.internal.TightDB.loadLibrary(TightDB.java:144)
03-06 12:26:24.820: E/AndroidRuntime(17507):    at io.realm.internal.SharedGroup.<clinit>(SharedGroup.java:34)
03-06 12:26:24.820: E/AndroidRuntime(17507):    ... 21 more

原因如下:

Realm realmDb=Realm.getInstance(this);

有没有人知道原因以及如何解决它(我发现以下但是并不太明白,如果它与我有任何关系,因为我根本不使用Gson https://github.com/realm/realm-java/issues/620

更新:我在libs目录中有本机库

enter image description here

更新 我认为本机.so文件目录的位置在libs目录下是直接的,我认为解决了早期的问题,但提出了以下错误代码:

03-06 14:18:18.520: E/AndroidRuntime(20552): FATAL EXCEPTION: main
03-06 14:18:18.520: E/AndroidRuntime(20552): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.project.mishnayot/com.project.peoples.PersonListActivity}: io.realm.exceptions.RealmException: Could not find the initTable method in the generated io.realm.PersonRealmProxy class: Annotation processor may not have been executed.
03-06 14:18:18.520: E/AndroidRuntime(20552):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
03-06 14:18:18.520: E/AndroidRuntime(20552):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
03-06 14:18:18.520: E/AndroidRuntime(20552):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-06 14:18:18.520: E/AndroidRuntime(20552):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
03-06 14:18:18.520: E/AndroidRuntime(20552):    at android.os.Handler.dispatchMessage(Handler.java:99)
03-06 14:18:18.520: E/AndroidRuntime(20552):    at android.os.Looper.loop(Looper.java:123)
03-06 14:18:18.520: E/AndroidRuntime(20552):    at android.app.ActivityThread.main(ActivityThread.java:3691)
03-06 14:18:18.520: E/AndroidRuntime(20552):    at java.lang.reflect.Method.invokeNative(Native Method)
03-06 14:18:18.520: E/AndroidRuntime(20552):    at java.lang.reflect.Method.invoke(Method.java:507)
03-06 14:18:18.520: E/AndroidRuntime(20552):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
03-06 14:18:18.520: E/AndroidRuntime(20552):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
03-06 14:18:18.520: E/AndroidRuntime(20552):    at dalvik.system.NativeStart.main(Native Method)
03-06 14:18:18.520: E/AndroidRuntime(20552): Caused by: io.realm.exceptions.RealmException: Could not find the initTable method in the generated io.realm.PersonRealmProxy class: Annotation processor may not have been executed.
03-06 14:18:18.520: E/AndroidRuntime(20552):    at io.realm.Realm.initializeRealm(Realm.java:591)
03-06 14:18:18.520: E/AndroidRuntime(20552):    at io.realm.Realm.createAndValidate(Realm.java:523)
03-06 14:18:18.520: E/AndroidRuntime(20552):    at io.realm.Realm.create(Realm.java:480)
03-06 14:18:18.520: E/AndroidRuntime(20552):    at io.realm.Realm.getInstance(Realm.java:397)
03-06 14:18:18.520: E/AndroidRuntime(20552):    at io.realm.Realm.getInstance(Realm.java:359)
03-06 14:18:18.520: E/AndroidRuntime(20552):    at io.realm.Realm.getInstance(Realm.java:340)
03-06 14:18:18.520: E/AndroidRuntime(20552):    at com.project.peoples.PersonListActivity.addTestPersons(PersonListActivity.java:134)
03-06 14:18:18.520: E/AndroidRuntime(20552):    at com.project.peoples.PersonListActivity.onCreate(PersonListActivity.java:34)
03-06 14:18:18.520: E/AndroidRuntime(20552):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-06 14:18:18.520: E/AndroidRuntime(20552):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)

1 个答案:

答案 0 :(得分:0)

由于某种原因,Realm无法找到本机库。您使用的是Android Studio还是Eclipse。如果您使用的是Eclipse,请注意需要一些额外的设置,如下所述:http://realm.io/docs/java/0.79.0/#getting-started