-3

I have task to prepare realm db and then pack it to res dir in android project, but currently I have exception when I try to create RealmConfiguration:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no realm-jni in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1865)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1119)
at io.realm.internal.RealmCore.loadLibrary(RealmCore.java:69)
at io.realm.RealmConfiguration$Builder.<init>(RealmConfiguration.java:321)
at jujumedia.coffeeguide.PreBuildLoader.main(PreBuildLoader.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)

2 Answers2

5

I'm pretty sure x86 and x64 are "on the roadmap", but aren't supported yet. Android and iOS are. In fact, as per documentation:

Prerequisites
- We do not support Java outside of Android at the moment.
- Android Studio >= 1.5.1
- A recent version of the Android SDK.
- JDK version >=7.
- We support all Android versions since API Level 9 (Android 2.3 Gingerbread & above).

Which means

- Realm does not support Java outside of Android at the moment.

EpicPandaForce
  • 79,669
  • 27
  • 256
  • 428
  • The is no way to use realm from java, maybe is some way to do this? I have task to prepare realm db and then pack it to res dir. – vchernyshov Apr 14 '16 at 12:53
  • The Realm editor works on Mac OS. Otherwise, you'll have to piece together your Realm on Android, then obtain the realm file from there. – EpicPandaForce Apr 14 '16 at 12:55
  • It is bad, if realm supports opportunity to work directly from java, will make process more easy. Currently I create special flavor of app, load data from net, save it in realm and then pull realm file from emulator. – vchernyshov Apr 14 '16 at 13:03
  • That sounds like a reasonable workaround to me. – EpicPandaForce Apr 14 '16 at 13:10
1

This error means that you haven't told the application where to find the library you're using. Since it can't find it, it's telling you that the link between your application and the realm-jni library is unsatisfiable.

See Correct way to add external jars (lib/*.jar) to an IntelliJ IDEA project

Community
  • 1
  • 1
Knetic
  • 2,099
  • 1
  • 20
  • 34
  • I have already added library to my top level gradle file and applied plugin in module gradle file. When I run code in android app all work fine but when I try to run console java app from my desktop I have exception. – vchernyshov Apr 13 '16 at 07:42