realmDb 初始化错误
realmDb initialization error
我听说了 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.access00(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 目录中有本机库
更新
我将本机 .so 文件目录的位置更改为 direcetlly 在 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.access00(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)
由于某种原因,Realm 无法找到本机库。您使用的是 Android Studio 还是 Eclipse。如果您使用的是 Eclipse,请注意需要进行一些额外的设置,如下所述:http://realm.io/docs/java/0.79.0/#getting-started
我听说了 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.access00(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 目录中有本机库
更新 我将本机 .so 文件目录的位置更改为 direcetlly 在 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.access00(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)
由于某种原因,Realm 无法找到本机库。您使用的是 Android Studio 还是 Eclipse。如果您使用的是 Eclipse,请注意需要进行一些额外的设置,如下所述:http://realm.io/docs/java/0.79.0/#getting-started