{"id":3577,"url":"https://github.com/realm/realm-java","last_synced_at":"2025-05-13T15:07:40.105Z","repository":{"id":3062525,"uuid":"4084908","full_name":"realm/realm-java","owner":"realm","description":"Realm is a mobile database: a replacement for SQLite \u0026 ORMs","archived":false,"fork":false,"pushed_at":"2025-01-10T23:09:27.000Z","size":65940,"stargazers_count":11484,"open_issues_count":398,"forks_count":1752,"subscribers_count":341,"default_branch":"main","last_synced_at":"2025-05-06T14:48:55.579Z","etag":null,"topics":["android","database","java","mobile","mobile-database","nosql-database","realtime-database"],"latest_commit_sha":null,"homepage":"http://realm.io","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/realm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-04-20T09:18:42.000Z","updated_at":"2025-05-06T06:45:06.000Z","dependencies_parsed_at":"2023-10-10T15:13:00.129Z","dependency_job_id":"ea4c605c-e250-4abe-a7d9-8ebd88407f82","html_url":"https://github.com/realm/realm-java","commit_stats":{"total_commits":6114,"total_committers":150,"mean_commits":40.76,"dds":0.7628393850179915,"last_synced_commit":"93263ec03df332d37e09a492233cd69fca268b05"},"previous_names":[],"tags_count":234,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/realm%2Frealm-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/realm%2Frealm-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/realm%2Frealm-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/realm%2Frealm-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/realm","download_url":"https://codeload.github.com/realm/realm-java/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253969228,"owners_count":21992262,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","database","java","mobile","mobile-database","nosql-database","realtime-database"],"created_at":"2024-01-05T20:16:45.423Z","updated_at":"2025-05-13T15:07:40.069Z","avatar_url":"https://github.com/realm.png","language":"Java","readme":"\u003e [!WARNING]\n\u003e We announced the deprecation of Atlas Device Sync + Realm SDKs in September 2024. For more information please see:\n\u003e - [SDK Deprecation](https://www.mongodb.com/docs/atlas/device-sdks/deprecation/)\n\u003e - [Device Sync Deprecation](https://www.mongodb.com/docs/atlas/app-services/sync/device-sync-deprecation/)\n\u003e\n\n\u003cpicture\u003e\n    \u003csource srcset=\"./media/logo-dark.svg\" media=\"(prefers-color-scheme: dark)\" alt=\"realm by MongoDB\"\u003e\n    \u003cimg src=\"./media/logo.svg\" alt=\"realm by MongoDB\"\u003e\n\u003c/picture\u003e\n\n[![Maven Central](https://img.shields.io/maven-central/v/io.realm/realm-gradle-plugin?colorB=4dc427\u0026label=Maven%20Central)](https://search.maven.org/artifact/io.realm/realm-gradle-plugin)\n[![License](https://img.shields.io/badge/License-Apache-blue.svg)](https://github.com/realm/realm-java/blob/master/LICENSE)\n\nRealm is a mobile database that runs directly inside phones, tablets or wearables.\nThis repository holds the source code for the Java version of Realm, which currently runs only on Android.\n\n## Realm Kotlin\n\nThe [Realm Kotlin SDK](https://github.com/realm/realm-kotlin) is now GA and can be used for both Android and Kotlin Multiplatform. While we are still adding features, please consider using Realm Kotlin for any new project, and let us know if you miss anything there!\n\n## Features\n\n* **Mobile-first:** Realm is the first database built from the ground up to run directly inside phones, tablets, and wearables.\n* **Simple:** Data is directly exposed as objects and queryable by code, removing the need for ORM's riddled with performance \u0026 maintenance issues. Plus, we've worked hard to [keep our API down to very few classes](https://www.mongodb.com/docs/atlas/device-sdks/sdk/java/): most of our users pick it up intuitively, getting simple apps up \u0026 running in minutes.\n* **Modern:** Realm supports easy thread-safety, relationships \u0026 encryption.\n* **Fast:** Realm is faster than even raw SQLite on common operations while maintaining an extremely rich feature set.\n* **[Device Sync](https://www.mongodb.com/atlas/app-services/device-sync)**: Makes it simple to keep data in sync across users, devices, and your backend in real-time. Get started for free with [a template application](https://github.com/mongodb/template-app-react-native-todo) and [create the cloud backend](http://mongodb.com/realm/register?utm_medium=github_atlas_CTA\u0026utm_source=realm_js_github).\n\n## Getting Started\n\nPlease see the [detailed instructions in our docs](https://www.mongodb.com/docs/atlas/device-sdks/sdk/java/install/) to add Realm to your project.\n\n## Documentation\n\nDocumentation for Realm can be found at [mongodb.com/docs/atlas/device-sdks/sdk/java/](https://www.mongodb.com/docs/atlas/device-sdks/sdk/java/).\nThe API reference is located at [mongodb.com/docs/atlas/device-sdks/sdk/java/api/](https://www.mongodb.com/docs/atlas/device-sdks/sdk/java/api/).\n\n## Getting Help\n\n- **Got a question?**: Look for previous questions on the [#realm tag](https://stackoverflow.com/questions/tagged/realm?sort=newest) — or [ask a new question](http://stackoverflow.com/questions/ask?tags=realm). We actively monitor \u0026 answer questions on StackOverflow! You can also check out our [Community Forum](https://developer.mongodb.com/community/forums/tags/c/realm/9/realm-sdk) where general questions about how to do something can be discussed.\n- **Think you found a bug?** [Open an issue](https://github.com/realm/realm-java/issues/new?template=bug_report.md). If possible, include the version of Realm, a full log, the Realm file, and a project that shows the issue.\n- **Have a feature request?** [Open an issue](https://github.com/realm/realm-java/issues/new?template=feature_request.md). Tell us what the feature should do, and why you want the feature.\n\n## Using Snapshots\n\nIf you want to test recent bugfixes or features that have not been packaged in an official release yet, you can use a **-SNAPSHOT** release of the current development version of Realm via Gradle, available on [Sonatype OSS](https://oss.sonatype.org/#nexus-search;quick~realm-gradle-plugin)\n\n\n```\nbuildscript {\n    repositories {\n        mavenCentral()\n        google()\n        maven {\n            url 'https://oss.sonatype.org/content/repositories/snapshots/'\n        }\n        jcenter()\n    }\n    dependencies {\n        classpath \"io.realm:realm-gradle-plugin:\u003cversion\u003e-SNAPSHOT\"\n    }\n}\n\nallprojects {\n    repositories {\n        mavenCentral()\n        google()\n        maven {\n            url 'https://oss.sonatype.org/content/repositories/snapshots/'\n        }\n        jcenter()\n    }\n}\n```\n\nSee [version.txt](version.txt) for the latest version number.\n\n## Building Realm\n\nIn case you don't want to use the precompiled version, you can build Realm yourself from source.\n\n### Prerequisites\n\n * Download the [**JDK 8**](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) from Oracle and install it.\n * The latest stable version of Android Studio. Currently [4.1.1](https://developer.android.com/studio/).\n * Download \u0026 install the Android SDK **Build-Tools 29.0.3**, **Android Pie (API 29)** (for example through Android Studio’s **Android SDK Manager**).\n * Install CMake version 3.18.4 and build Ninja.\n * Install the NDK (Side-by-side) **21.0.6113669** from the SDK Manager in Android Studio. Remember to check `☑  Show package details` in the manager to display all available versions.\n\n * Add the Android home environment variable to your profile:\n\n    ```\n    export ANDROID_HOME=~/Library/Android/sdk\n    ```\n\n * If you are launching Android Studio from the macOS Finder, you should also run the following command:\n\n    ```\n    launchctl setenv ANDROID_HOME \"$ANDROID_HOME\"\n    ```\n\n * If you'd like to specify the location in which to store the archives of Realm Core, define the `REALM_CORE_DOWNLOAD_DIR` environment variable. It enables caching core release artifacts.\n\n   ```\n   export REALM_CORE_DOWNLOAD_DIR=~/.realmCore\n   ```\n\n   macOS users must also run the following command for Android Studio to see this environment variable.\n\n   ```\n   launchctl setenv REALM_CORE_DOWNLOAD_DIR \"$REALM_CORE_DOWNLOAD_DIR\"\n   ```\n\nIt would be a good idea to add all of the symbol definitions (and their accompanying `launchctl` commands, if you are using macOS) to your `~/.profile` (or `~/.zprofile` if the login shell is `zsh`)\n\n * If you develop Realm Java with Android Studio, we recommend you to exclude some directories from indexing target by executing following steps on Android Studio. It really speeds up indexing phase after the build.\n\n    - Under `/realm/realm-library/`, select `build`, `.cxx` and `distribution` folders in `Project` view.\n    - Press `Command + Shift + A` to open `Find action` dialog. If you are not using default keymap nor using macOS, you can find your shortcut key in `Keymap` preference by searching `Find action`.\n    - Search `Excluded` (not `Exclude`) action and select it. Selected folder icons should become orange (in default theme).\n    - Restart Android Studio.\n\n### Download sources\n\nYou can download the source code of Realm Java by using git. Since realm-java has git submodules, use `--recursive` when cloning the repository.\n\n```\ngit clone git@github.com:realm/realm-java.git --recursive\n```\n\nor\n\n```\ngit clone https://github.com/realm/realm-java.git --recursive\n```\n\n### Build\n\nOnce you have completed all the pre-requisites building Realm is done with a simple command.\n\n```\n./gradlew assemble\n```\n\nThat command will generate:\n\n * a jar file for the Realm Gradle plugin\n * an aar file for the Realm library\n * a jar file for the annotations\n * a jar file for the annotations processor\n\nThe full build may take an hour or more, to complete.\n\n### Building from source\n\nIt is possible to build Realm Java with the submodule version of Realm Core. This is done by providing the following parameter when building: `-PbuildCore=true`.\n\n```\n./gradlew assembleBase -PbuildCore=true\n```\n\nYou can turn off interprocedural optimizations with the following parameter: `-PenableLTO=false`. \n\n```\n./gradlew assembleBase -PenableLTO=false`\n```\n\nNote: Building the `Base` variant would always build realm-core.\n\nNote: Interprocedural optimizations are enabled by default.\n\nNote: If you want to build from source inside Android Studio, you need to update the Gradle parameters by going into the Realm projects settings `Settings \u003e Build, Execution, Deployment \u003e Compiler \u003e Command-line options` and add `-PbuildCore=true` or `-PenableLTO=false` to it. Alternatively you can add it into your `gradle.properties`:\n\n```\nbuildCore=true\nenableLTO=false\n```\n\nNote: If building on OSX you might like to prevent Gatekeeper to block all NDK executables by disabling it: `sudo spctl --master-disable`. Remember to enable it afterwards: `sudo spctl --master-enable`\n\n### Other Commands\n\n * `./gradlew tasks` will show all the available tasks\n * `./gradlew javadoc` will generate the Javadocs\n * `./gradlew monkeyExamples` will run the monkey tests on all the examples\n * `./gradlew installRealmJava` will install the Realm library and plugin to mavenLocal()\n * `./gradlew clean -PdontCleanJniFiles` will remove all generated files except for JNI related files. This reduces recompilation time a lot.\n * `./gradlew connectedUnitTests -PbuildTargetABIs=$(adb shell getprop ro.product.cpu.abi)` will build JNI files only for the ABI which corresponds to the connected device.  These tests require a running Object Server (see below)\n\nGenerating the Javadoc using the command above may generate warnings. The Javadoc is generated despite the warnings.\n\n\n### Upgrading Gradle Wrappers\n\n All gradle projects in this repository have `wrapper` task to generate Gradle Wrappers. Those tasks refer to `gradle` property defined in `/dependencies.list` to determine Gradle Version of generating wrappers.\nWe have a script `./tools/update_gradle_wrapper.sh` to automate these steps. When you update Gradle Wrappers, please obey the following steps.\n\n 1. Edit `gradle` property in defined in `/dependencies.list` to new Gradle Wrapper version.\n 2. Execute `/tools/update_gradle_wrapper.sh`.\n\n### Gotchas\n\nThe repository is organized into six Gradle projects:\n\n * `realm`: it contains the actual library (including the JNI layer) and the annotations processor.\n * `realm-annotations`: it contains the annotations defined by Realm.\n * `realm-transformer`: it contains the bytecode transformer.\n * `gradle-plugin`: it contains the Gradle plugin.\n * `examples`: it contains the example projects. This project directly depends on `gradle-plugin` which adds a dependency to the artifacts produced by `realm`.\n * The root folder is another Gradle project.  All it does is orchestrate the other jobs.\n\nThis means that `./gradlew clean` and `./gradlew cleanExamples` will fail if `assembleExamples` has not been executed first.\nNote that IntelliJ [does not support multiple projects in the same window](https://youtrack.jetbrains.com/issue/IDEABKL-6118#)\nso each of the six Gradle projects must be imported as a separate IntelliJ project.\n\nSince the repository contains several completely independent Gradle projects, several independent builds are run to assemble it.\nSeeing a line like: `:realm:realm-library:compileBaseDebugAndroidTestSources UP-TO-DATE` in the build log does *not* imply\nthat you can run `./gradlew :realm:realm-library:compileBaseDebugAndroidTestSources`.\n\n## Examples\n\nThe `./examples` folder contains many example projects showing how Realm can be used. If this is the first time you checkout or pull a new version of this repository to try the examples, you must call `./gradlew installRealmJava` from the top-level directory first. Otherwise, the examples will not compile as they depend on all Realm artifacts being installed in `mavenLocal()`.\n\nStandalone examples can be [downloaded from website](https://www.mongodb.com/docs/realm/sdk/java/quick-starts/quick-start-local/#complete-example).\n\n## Running Tests on a Device\n\nTo run these tests, you must have a device connected to the build computer, and the `adb` command must be in your `PATH`\n\n1. Connect an Android device and verify that the command `adb devices` shows a connected device:\n\n    ```sh\n    adb devices\n    List of devices attached\n    004c03eb5615429f device\n    ```\n\n2. Run instrumentation tests:\n\n    ```sh\n    cd realm\n    ./gradlew connectedBaseDebugAndroidTest\n    ```\n\nThese tests may take as much as half an hour to complete.\n\n## Running Tests Using The Realm Object Server\n\nTests in `realm/realm-library/src/syncIntegrationTest` require a running testing server to work.\nA docker image can be built from `tools/sync_test_server/Dockerfile` to run the test server.\n`tools/sync_test_server/start_server.sh` will build the docker image automatically.\n\nTo run a testing server locally:\n\n1. Install [docker](https://www.docker.com/products/overview) and run it.\n\n2. Run `tools/sync_test_server/start_server.sh`:\n\n    ```sh\n    cd tools/sync_test_server\n    ./start_server.sh\n    ```\n\n    This command will not complete until the server has stopped.\n\n3. Run instrumentation tests\n\n    In a new terminal window, run:\n\n    ```sh\n    cd realm\n    ./gradlew connectedObjectServerDebugAndroidTest\n    ```\n\nNote that if using VirtualBox (Genymotion), the network needs to be bridged for the tests to work.\nThis is done in `VirtualBox \u003e Network`. Set \"Adapter 2\" to \"Bridged Adapter\".\n\nThese tests may take as much as half an hour to complete.\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for more details!\n\nThis project adheres to the [MongoDB Code of Conduct](https://www.mongodb.com/community-code-of-conduct).\nBy participating, you are expected to uphold this code. Please report\nunacceptable behavior to [community-conduct@mongodb.com](mailto:community-conduct@mongodb.com).\n\nThe directory `realm/config/studio` contains lint and style files recommended for project code.\nImport them from Android Studio with Android Studio \u003e Preferences... \u003e Code Style \u003e Manage... \u003e Import,\nor Android Studio \u003e Preferences... \u003e Inspections \u003e Manage... \u003e Import.  Once imported select the\nstyle/lint in the drop-down to the left of the Manage... button.\n\n## License\n\nRealm Java is published under the Apache 2.0 license.\n\nRealm Core is also published under the Apache 2.0 license and is available\n[here](https://github.com/realm/realm-core).\n\n## Feedback\n\n**_If you use Realm and are happy with it, all we ask is that you, please consider sending out a tweet mentioning [@realm](http://twitter.com/realm) to share your thoughts!_**\n\n**_And if you don't like it, please let us know what you would like improved, so we can fix it!_**\n\n\u003cimg style=\"width: 0px; height: 0px;\" src=\"https://3eaz4mshcd.execute-api.us-east-1.amazonaws.com/prod?s=https://github.com/realm/realm-java#README.md\"\u003e\n","funding_links":[],"categories":["项目","Database","Java","Libraries","Projects","\u003ca name=\"java\"\u003e Java/Kotlin","Index","数据库管理系统","Libs","Android 开发中的日常积累","数据库","库"],"sub_categories":["数据库","Database","\u003ca name=\"swift-tools\"\u003e\u003c/a\u003eSwift Tools","O/R Mapping","网络服务_其他","Databases","\u003cA NAME=\"Orm\"\u003e\u003c/A\u003eOrm","Android NoSql","[](https://github.com/JStumpp/awesome-android/blob/master/readme.md#database)数据库"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frealm%2Frealm-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frealm%2Frealm-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frealm%2Frealm-java/lists"}