Realm is a mobile database: a replacement for SQLite & ORMs

Overview

Realm

bintray License

Realm is a mobile database that runs directly inside phones, tablets or wearables. This repository holds the source code for the Java version of Realm, which currently runs only on Android.

Realm Kotlin

See Realm Kotlin for more information about our new SDK written specifically for Kotlin Multiplatform and Android. The SDK is still experimental and the API surface has not been finalized yet, but we highly encourage any feedback you might have.

Features

  • Mobile-first: Realm is the first database built from the ground up to run directly inside phones, tablets, and wearables.
  • Simple: Data is directly exposed as objects and queryable by code, removing the need for ORM's riddled with performance & maintenance issues. Plus, we've worked hard to keep our API down to very few classes: most of our users pick it up intuitively, getting simple apps up & running in minutes.
  • Modern: Realm supports easy thread-safety, relationships & encryption.
  • Fast: Realm is faster than even raw SQLite on common operations while maintaining an extremely rich feature set.

Getting Started

Please see the detailed instructions in our docs to add Realm to your project.

Documentation

Documentation for Realm can be found at realm.io/docs/java. The API reference is located at realm.io/docs/java/api.

Getting Help

  • Got a question?: Look for previous questions on the #realm tag — or ask a new question. We actively monitor & answer questions on StackOverflow! You can also check out our Community Forum where general questions about how to do something can be discussed.
  • Think you found a bug? Open an issue. If possible, include the version of Realm, a full log, the Realm file, and a project that shows the issue.
  • Have a feature request? Open an issue. Tell us what the feature should do, and why you want the feature.

Using Snapshots

If 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 JFrog OSS

buildscript {
    repositories {
        mavenCentral()
        google()
        maven {
            url 'https://oss.sonatype.org/content/repositories/snapshots/'
        }
        jcenter()
    }
    dependencies {
        classpath "io.realm:realm-gradle-plugin:<version>-SNAPSHOT"
    }
}

allprojects {
    repositories {
        mavenCentral()
        google()
        maven {
            url 'https://oss.sonatype.org/content/repositories/snapshots/'
        }
        jcenter()
    }
}

See version.txt for the latest version number.

Building Realm

In case you don't want to use the precompiled version, you can build Realm yourself from source.

Prerequisites

  • Download the JDK 8 from Oracle and install it.

  • The latest stable version of Android Studio. Currently 4.1.1.

  • Download & install the Android SDK Build-Tools 29.0.3, Android Pie (API 29) (for example through Android Studio’s Android SDK Manager).

  • Install CMake version 3.18.4 and build Ninja.

  • 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.

  • Add the Android home environment variable to your profile:

    export ANDROID_HOME=~/Library/Android/sdk
    
  • If you are launching Android Studio from the macOS Finder, you should also run the following command:

    launchctl setenv ANDROID_HOME "$ANDROID_HOME"
    
  • 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.

    export REALM_CORE_DOWNLOAD_DIR=~/.realmCore
    

    macOS users must also run the following command for Android Studio to see this environment variable.

    launchctl setenv REALM_CORE_DOWNLOAD_DIR "$REALM_CORE_DOWNLOAD_DIR"
    

It 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)

  • 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.

    • Under /realm/realm-library/, select build, .cxx and distribution folders in Project view.
    • 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.
    • Search Excluded (not Exclude) action and select it. Selected folder icons should become orange (in default theme).
    • Restart Android Studio.

Download sources

You can download the source code of Realm Java by using git. Since realm-java has git submodules, use --recursive when cloning the repository.

git clone [email protected]:realm/realm-java.git --recursive

or

git clone https://github.com/realm/realm-java.git --recursive

Build

Once you have completed all the pre-requisites building Realm is done with a simple command.

./gradlew assemble

That command will generate:

  • a jar file for the Realm Gradle plugin
  • an aar file for the Realm library
  • a jar file for the annotations
  • a jar file for the annotations processor

The full build may take an hour or more, to complete.

Building from source

It 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.

./gradlew assembleBase -PbuildCore=true

You can turn off interprocedural optimizations with the following parameter: -PenableLTO=false.

./gradlew assembleBase -PenableLTO=false`

Note: Building the Base variant would always build realm-core.

Note: Interprocedural optimizations are enabled by default.

Note: 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 > Build, Execution, Deployment > Compiler > Command-line options and add -PbuildCore=true or -PenableLTO=false to it. Alternatively you can add it into your gradle.properties:

buildCore=true
enableLTO=false

Note: 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

Other Commands

  • ./gradlew tasks will show all the available tasks
  • ./gradlew javadoc will generate the Javadocs
  • ./gradlew monkeyExamples will run the monkey tests on all the examples
  • ./gradlew installRealmJava will install the Realm library and plugin to mavenLocal()
  • ./gradlew clean -PdontCleanJniFiles will remove all generated files except for JNI related files. This reduces recompilation time a lot.
  • ./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)

Generating the Javadoc using the command above may generate warnings. The Javadoc is generated despite the warnings.

Upgrading Gradle Wrappers

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. We have a script ./tools/update_gradle_wrapper.sh to automate these steps. When you update Gradle Wrappers, please obey the following steps.

  1. Edit gradle property in defined in /dependencies.list to new Gradle Wrapper version.
  2. Execute /tools/update_gradle_wrapper.sh.

Gotchas

The repository is organized into six Gradle projects:

  • realm: it contains the actual library (including the JNI layer) and the annotations processor.
  • realm-annotations: it contains the annotations defined by Realm.
  • realm-transformer: it contains the bytecode transformer.
  • gradle-plugin: it contains the Gradle plugin.
  • examples: it contains the example projects. This project directly depends on gradle-plugin which adds a dependency to the artifacts produced by realm.
  • The root folder is another Gradle project. All it does is orchestrate the other jobs.

This means that ./gradlew clean and ./gradlew cleanExamples will fail if assembleExamples has not been executed first. Note that IntelliJ does not support multiple projects in the same window so each of the six Gradle projects must be imported as a separate IntelliJ project.

Since the repository contains several completely independent Gradle projects, several independent builds are run to assemble it. Seeing a line like: :realm:realm-library:compileBaseDebugAndroidTestSources UP-TO-DATE in the build log does not imply that you can run ./gradlew :realm:realm-library:compileBaseDebugAndroidTestSources.

Examples

The ./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().

Standalone examples can be downloaded from website.

Running Tests on a Device

To run these tests, you must have a device connected to the build computer, and the adb command must be in your PATH

  1. Connect an Android device and verify that the command adb devices shows a connected device:

    adb devices
    List of devices attached
    004c03eb5615429f device
  2. Run instrumentation tests:

    cd realm
    ./gradlew connectedBaseDebugAndroidTest

These tests may take as much as half an hour to complete.

Running Tests Using The Realm Object Server

Tests in realm/realm-library/src/syncIntegrationTest require a running testing server to work. A docker image can be built from tools/sync_test_server/Dockerfile to run the test server. tools/sync_test_server/start_server.sh will build the docker image automatically.

To run a testing server locally:

  1. Install docker and run it.

  2. Run tools/sync_test_server/start_server.sh:

    cd tools/sync_test_server
    ./start_server.sh

    This command will not complete until the server has stopped.

  3. Run instrumentation tests

    In a new terminal window, run:

    cd realm
    ./gradlew connectedObjectServerDebugAndroidTest

Note that if using VirtualBox (Genymotion), the network needs to be bridged for the tests to work. This is done in VirtualBox > Network. Set "Adapter 2" to "Bridged Adapter".

These tests may take as much as half an hour to complete.

Contributing

See CONTRIBUTING.md for more details!

This project adheres to the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to [email protected].

The directory realm/config/studio contains lint and style files recommended for project code. Import them from Android Studio with Android Studio > Preferences... > Code Style > Manage... > Import, or Android Studio > Preferences... > Inspections > Manage... > Import. Once imported select the style/lint in the drop-down to the left of the Manage... button.

License

Realm Java is published under the Apache 2.0 license.

Realm Core is also published under the Apache 2.0 license and is available here.

This product is not being made available to any person located in Cuba, Iran, North Korea, Sudan, Syria or the Crimea region, or to any other person that is not eligible to receive the product under U.S. law.

Feedback

If you use Realm and are happy with it, all we ask is that you, please consider sending out a tweet mentioning @realm to share your thoughts!

And if you don't like it, please let us know what you would like improved, so we can fix it!

analytics

Comments
  • Samsung Tab 3 Lite 7 crashes on Realm 2.0.1 and 2.0.2

    Samsung Tab 3 Lite 7 crashes on Realm 2.0.1 and 2.0.2

    A Samsung Galaxy Tab 3 Lite 7 (SM-T111) crashes on startup with the below error (Android 4.2.2) Has been confirmed working on Nexus 5, Nexus 4 and emulators 15, 19, 21, 22, 23, 24.

    10-18 11:57:25.851 D/dalvikvm( 6127): Trying to load lib /data/app-lib/com.zt.android.test.realmio-1/librealm-jni.so 0x412e0568
    10-18 11:57:25.851 D/dalvikvm( 6127): Added shared lib /data/app-lib/com.zt.android.test.realmio-1/librealm-jni.so 0x412e0568
    10-18 11:57:25.859 V/REALM   ( 6127):  --> Java_io_realm_internal_SharedRealm_nativeCreateConfig
    10-18 11:57:25.859 V/REALM   ( 6127):  --> Java_io_realm_internal_SharedRealm_nativeGetSharedRealm 1521857752
    10-18 11:57:25.867 I/v_hwc   (  112): hwc prepare: 3D composition
    10-18 11:57:25.875 V/REALM   ( 6127):  --> Java_io_realm_internal_SharedRealm_nativeCloseConfig 1521857752
    10-18 11:57:25.875 V/REALM   ( 6127):  --> Java_io_realm_internal_SharedRealm_nativeHasTable 1522273128
    10-18 11:57:25.875 V/REALM   ( 6127):  --> Java_io_realm_internal_SharedRealm_nativeCloseSharedRealm 1522273128
    10-18 11:57:25.875 V/REALM   ( 6127):  --> Java_io_realm_internal_SharedRealm_nativeCreateConfig
    10-18 11:57:25.875 V/REALM   ( 6127):  --> Java_io_realm_internal_SharedRealm_nativeGetSharedRealm 1521857752
    10-18 11:57:25.875 V/REALM   ( 6127):  --> Java_io_realm_internal_SharedRealm_nativeGetVersion 1522276080
    10-18 11:57:25.875 V/REALM   ( 6127):  --> Java_io_realm_internal_SharedRealm_nativeCloseConfig 1521857752
    10-18 11:57:25.875 V/REALM   ( 6127):  --> Java_io_realm_internal_SharedRealm_nativeIsClosed 1522276080
    10-18 11:57:25.875 V/REALM   ( 6127):  --> Java_io_realm_internal_SharedRealm_nativeGetVersion 1522276080
    10-18 11:57:25.875 V/REALM   ( 6127):  --> Java_io_realm_internal_SharedRealm_nativeGetVersion 1522276080
    10-18 11:57:25.875 V/REALM   ( 6127):  --> Java_io_realm_internal_SharedRealm_nativeIsClosed 1522276080
    10-18 11:57:25.875 V/REALM   ( 6127):  --> Java_io_realm_internal_SharedRealm_nativeBeginTransaction 1522276080
    10-18 11:57:25.875 V/REALM   ( 6127):  --> Java_io_realm_internal_SharedRealm_nativeGetVersion 1522276080
    10-18 11:57:25.875 V/REALM   ( 6127):  --> Java_io_realm_internal_SharedRealm_nativeSetVersion 1522276080
    10-18 11:57:25.875 F/libc    ( 6127): Fatal signal 11 (SIGSEGV) at 0x5ab3eff6 (code=2), thread 6127 (id.test.realmio)
    10-18 11:57:25.882 F/libc    ( 6127): Fatal signal 11 (SIGSEGV) at 0x00000008 (code=1), thread 6142 (id.test.realmio)
    
    10-18 11:48:42.945 D/CrashAnrDetector(  484): Build: samsung/goya3gxx/goya3g:4.2.2/JDQ39/T111XXUAOC2:user/release-keys
    10-18 11:48:42.945 D/CrashAnrDetector(  484): Hardware: PXA986
    10-18 11:48:42.945 D/CrashAnrDetector(  484): Revision: 2
    10-18 11:48:42.945 D/CrashAnrDetector(  484): Bootloader: T111XXUAOC2
    10-18 11:48:42.945 D/CrashAnrDetector(  484): Radio: unknown
    10-18 11:48:42.945 D/CrashAnrDetector(  484): Kernel: Linux version 3.4.5-2825369 (se.infra@SWDB2804) (gcc version 4.6.x-google 20120106 (prerelease) (GCC) ) #2 SMP PREEMPT Tue Mar 17 22:04:14 KST 2015
    10-18 11:48:42.945 D/CrashAnrDetector(  484):
    10-18 11:48:42.945 D/CrashAnrDetector(  484): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    10-18 11:48:42.945 D/CrashAnrDetector(  484): Build fingerprint: 'samsung/goya3gxx/goya3g:4.2.2/JDQ39/T111XXUAOC2:user/release-keys'
    10-18 11:48:42.945 D/CrashAnrDetector(  484): Revision: '2'
    10-18 11:48:42.945 D/CrashAnrDetector(  484): pid: 5805, tid: 5805, name: id.test.realmio  >>> io.realm.test.realmio <<<
    10-18 11:48:42.945 D/CrashAnrDetector(  484): signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 5baa4ffe
    10-18 11:48:42.945 D/CrashAnrDetector(  484):     r0 5baa500b  r1 5baa4ffe  r2 5bb71283  r3 5baa4ffe
    10-18 11:48:42.945 D/CrashAnrDetector(  484):     r4 00000000  r5 5baa500a  r6 5bbb5358  r7 5dc08d20
    10-18 11:48:42.945 D/CrashAnrDetector(  484):     r8 00000010  r9 00000010  sl 5e8bf810  fp 00000010
    10-18 11:48:42.945 D/CrashAnrDetector(  484):     ip 00000000  sp bed19318  lr 00000000  pc 5e7a1052  cpsr 20000030
    10-18 11:48:42.945 D/CrashAnrDetector(  484):     d0  65706f72705f6b70  d1  532f6c616e726500
    10-18 11:48:42.945 D/CrashAnrDetector(  484):     d2  65742e64696f7200  d3  6d6c6165722e7402
    10-18 11:48:42.945 D/CrashAnrDetector(  484):     d4  746c75616665642f  d5  6d2e6d6c6165722e
    10-18 11:48:42.945 D/CrashAnrDetector(  484):     d6  6e656d6567616e61  d7  7373656363612f74
    10-18 11:48:42.945 D/CrashAnrDetector(  484):     d8  0000000000000000  d9  0000000000000000
    10-18 11:48:42.945 D/CrashAnrDetector(  484):     d10 0000000000000000  d11 0000000000000000
    10-18 11:48:42.945 D/CrashAnrDetector(  484):     d12 0000000000000000  d13 0000000000000000
    10-18 11:48:42.945 D/CrashAnrDetector(  484):     d14 0000000000000000  d15 0000000000000000
    10-18 11:48:42.945 D/CrashAnrDetector(  484):     d16 4026000000000000  d17 0000000000000000
    10-18 11:48:42.945 D/CrashAnrDetector(  484):     d18 0000000000000000  d19 0000000000000000
    10-18 11:48:42.945 D/CrashAnrDetector(  484):     d20 4008000000000000  d21 3fbc71c71c71c71c
    10-18 11:48:42.945 D/CrashAnrDetector(  484):     d22 3fcc7288e957b53b  d23 3fd24998d6307188
    10-18 11:48:42.945 D/CrashAnrDetector(  484):     d24 3fd99a27ad32ddf5  d25 3fe555b0aaeac752
    10-18 11:48:42.945 D/CrashAnrDetector(  484):     d26 0000000000000000  d27 0000000000000000
    10-18 11:48:42.945 D/CrashAnrDetector(  484):     d28 0000000000000000  d29 0000000000000000
    10-18 11:48:42.945 D/CrashAnrDetector(  484):     d30 0000000000000000  d31 0000000000000000
    10-18 11:48:42.945 D/CrashAnrDetector(  484):     scr 20000010
    10-18 11:48:42.945 D/CrashAnrDetector(  484):
    10-18 11:48:42.945 D/CrashAnrDetector(  484): backtrace:
    10-18 11:48:42.945 D/CrashAnrDetector(  484):     #00  pc 00082052  /data/app-lib/io.realm.test.realmio-1/librealm-jni.so
    10-18 11:48:42.945 D/CrashAnrDetector(  484):     #01  pc 000a50b7  /data/app-lib/io.realm.test.realmio-1/librealm-jni.so
    10-18 11:48:42.945 D/CrashAnrDetector(  484):     #02  pc 0005a69d  /data/app-lib/io.realm.test.realmio-1/librealm-jni.so
    10-18 11:48:42.945 D/CrashAnrDetector(  484):
    10-18 11:48:42.945 D/CrashAnrDetector(  484): stack:
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed192d8  5bbb5950
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed192dc  00001680
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed192e0  5bbb5bd0
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed192e4  00001900
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed192e8  5e7991cb  /data/app-lib/io.realm.test.realmio-1/librealm-jni.so
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed192ec  5e7a0e85  /data/app-lib/io.realm.test.realmio-1/librealm-jni.so
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed192f0  00000000
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed192f4  5e8d4168  /data/app-lib/io.realm.test.realmio-1/librealm-jni.so
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed192f8  5bbb5958
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed192fc  00000000
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed19300  bed19330  [stack]
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed19304  00000000
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed19308  5dc08d20
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed1930c  5dc08d20
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed19310  df0027ad
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed19314  00000000
    10-18 11:48:42.945 D/CrashAnrDetector(  484):     #00  bed19318  5e799c41  /data/app-lib/io.realm.test.realmio-1/librealm-jni.so
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed1931c  00000001
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed19320  0000000f
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed19324  00000008
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed19328  5e8bf810  /data/app-lib/io.realm.test.realmio-1/librealm-jni.so
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed1932c  00000008
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed19330  5bbb5360
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed19334  ffffffff
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed19338  00000000
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed1933c  5dc08d20
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed19340  00000001
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed19344  00000001
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed19348  00000000
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed1934c  5e8bf810  /data/app-lib/io.realm.test.realmio-1/librealm-jni.so
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed19350  5dc08008
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed19354  5e7c40bb  /data/app-lib/io.realm.test.realmio-1/librealm-jni.so
    10-18 11:48:42.945 D/CrashAnrDetector(  484):     #01  bed19358  ffffffff
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed1935c  00000000
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed19360  00000000
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed19364  00000008
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed19368  5abee570
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed1936c  00000000
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed19370  5ab9ed08
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed19374  5abee6e0
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed19378  5e8bf810  /data/app-lib/io.realm.test.realmio-1/librealm-jni.so
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed1937c  00000008
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed19380  00000001
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed19384  5e7db265  /data/app-lib/io.realm.test.realmio-1/librealm-jni.so
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed19388  5e8bf810  /data/app-lib/io.realm.test.realmio-1/librealm-jni.so
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed1938c  00000008
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed19390  00000000
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed19394  5abee570
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          ........  ........
    10-18 11:48:42.945 D/CrashAnrDetector(  484):     #02  bed193b8  00000000
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed193bc  00000000
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed193c0  5dc08d20
    10-18 11:48:42.945 D/CrashAnrDetector(  484):          bed193c4  5e7c0c
    10-18 11:48:42.945 D/CrashAnrDetector(  484): processName:io.realm.test.realmio
    10-18 11:48:42.945 D/CrashAnrDetector(  484): broadcastEvent : io.realm.test.realmio SYSTEM_TOMBSTONE
    

    I'm working on getting a sample project. /cc @beeender

    T-Bug-Crash 
    opened by cmelchior 174
  • RealmError: Incompatible lock file /  After 2.0 RealmFileException  All processes sharing a single file must be the same architecture.

    RealmError: Incompatible lock file / After 2.0 RealmFileException All processes sharing a single file must be the same architecture.

    Goal

    To report specific error after upgrading v0.88.0

    Expected Results

    Crash is not occurred.

    Actual Results

    Fatal Exception: io.realm.exceptions.RealmError: Unrecoverable error. Incompatible lock file in io_realm_internal_SharedGroup.cpp line 113
       at io.realm.internal.SharedGroup.createNativeWithImplicitTransactions(SharedGroup.java)
       at io.realm.internal.SharedGroup.(SharedGroup.java:63)
       at io.realm.internal.SharedGroupManager.(SharedGroupManager.java:48)
       at io.realm.BaseRealm.(BaseRealm.java:76)
       at io.realm.Realm.(Realm.java:138)
       at io.realm.Realm.createAndValidate(Realm.java:268)
       at io.realm.Realm.createInstance(Realm.java:248)
       at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:114)
       at io.realm.Realm.getInstance(Realm.java:213)
       at kr.co.vcnc.android.couple.feature.MainTabIndicator.updateHomeBadge(MainTabIndicator.java:138)
       at kr.co.vcnc.android.couple.feature.MainTabIndicator.onAttachedToWindow(MainTabIndicator.java:83)
       at android.view.View.dispatchAttachedToWindow(View.java:12626)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2473)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2480)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2480)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2480)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2480)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2480)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2480)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2480)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2480)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2480)
       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1264)
       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1047)
       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5896)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
       at android.view.Choreographer.doCallbacks(Choreographer.java:574)
       at android.view.Choreographer.doFrame(Choreographer.java:544)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
       at android.os.Handler.handleCallback(Handler.java:733)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:136)
       at android.app.ActivityThread.main(ActivityThread.java:5120)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
       at dalvik.system.NativeStart.main(NativeStart.java)
    

    Steps & Code to Reproduce

    I got this stack trace from Fabric. I've tested several devices that we have, i can't reproduce it. Instead, i attached some code that error is happening.

    FYI, at this update (to v0.88.0), we upgraded Realm's schema version. (We're using deleteRealmIfMigrationNeeded option)

    Code Sample

    @Override
    protected void onAttachedToWindow() {
        homeBadgeSubscription = Realm.getInstance(CoupleApplication.getRealmHome())
                    .where(RHomeCardViewView.class)
                    .equalTo("closed", false)
                    .equalTo("newIndicator", true)
                    .findAllAsync()
                    .asObservable()
                    .filter(RealmResults::isLoaded)
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(BasicSubscriber.    <RealmResults<RHomeCardViewView>>create().next(homeCardViewViews -> {
                        int size = homeCardViewViews.size();
                        updateTextView(size);
                    }));
    
    @Override
    protected void onDetachedFromWindow() {
        if (homeBadgeSubscription != null) {
            homeBadgeSubscription.unsubscribe();
        }
    }
    

    Version of Realm and tooling

    Realm version(s): v0.88.0

    Which Android version and device: When i first saw this crash, i think this is occurred because users are using BlackBerry. But now Android users have a crash.

    screen shot 2016-03-15 at 10 55 28 am screen shot 2016-03-15 at 10 55 40 am screen shot 2016-03-15 at 10 55 47 am

    The peak point is yesterday. (Realm v0.88.0) screen shot 2016-03-15 at 10 59 39 am

    T-Bug-Crash Reproduction-Required 
    opened by hohnamkung 141
  • RealmList<Integer / String / ...>

    RealmList

    Dear realm-Team,

    I'm really impressed by Realm and I do like the way you're providing support and solutions on github, SO and gGroups! I like working with Realm - however there are three really big drawbacks for me:

    1. No model-instantiation by = new ... - I know you're on it. I can't wait for this! Do we have to wait for the "whole" JSON-Upgrade or will there be an earlier release providing this feature?

    2. No model-passing across threads. That's hindering all the great benefits of EventBus and Android Priority Job Queue. But I read that it will be possible in the further versions and I'm looking forward on this.

    3. The reason for this issue: In my model class I'm allowed to have primitive fields as well as object fields of objects that extend RealmObject. But I'm not allowed to have a field type like RealmList<Integer> or RealmList<String>. However it is possible to work around this by

    RealmList<RealmString> names;
    

    and

    public class RealmString extends RealmObject {
    private String name;
    // getter & setter
    

    It works but it's really ugly and should be unnecessary in my opinion. Is there any improvement planned regarding this?

    Thanks again for your great work - I'm glad Realm helps me developing my app!


    Related PRs:

    • [ ] API design (#4165)
    • [ ] Implementation (#5031)
    Blocked T-Feature Design-Required 
    opened by an-k 139
  • Unrecoverable error. Permission denied in /Users/cm/Realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_SharedRealm.cpp

    Unrecoverable error. Permission denied in /Users/cm/Realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_SharedRealm.cpp

    Goal

    Sharing a crash log (as reported by Crashlytics) on specific devices.

    Expected Results

    To verify if my current API usage is correct and hopefully find a resolution.

    Actual Results

    Fatal Exception: io.realm.exceptions.RealmError: Unrecoverable error. Permission denied in /Users/cm/Realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_SharedRealm.cpp line 92 at io.realm.internal.SharedRealm.nativeGetSharedRealm(SharedRealm.java) at io.realm.internal.SharedRealm.getInstance(SharedRealm.java:205) at io.realm.internal.SharedRealm.getInstance(SharedRealm.java:182) at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:124) at io.realm.Realm.getInstance(Realm.java:227) at com.project.base.BaseRealm.(BaseRealm.java) at com.project.helpers.RepoImpl.(RepoImpl.java) at com.project.MainActivity.initialiseHelpers(MainActivity.java:272) at com.project.MainActivity.onCreate(MainActivity.java:162) at android.app.ActivityThread.handleCreateService(ActivityThread.java:2937) at android.app.ActivityThread.access$1900(ActivityThread.java:174) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1403) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:146) at android.app.ActivityThread.main(ActivityThread.java:5752) at java.lang.reflect.Method.invokeNative(Method.java) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107) at dalvik.system.NativeStart.main(NativeStart.java)

    Code:

    public class BaseRealm {
        private RealmConfiguration config = new RealmConfiguration.Builder().build();
        protected Realm mRealm = Realm.getInstance(config);
    }
    
    public class RepoImpl extends BaseRealm implements RepoInterface {
        @Override
        public void add(String item) {
            MyPOJO data = new MyPOJO();
            data.setItem(item);
            data.setTimestamp(System.currentTimeMillis());
            mRealm.beginTransaction();
            mRealm.copyToRealmOrUpdate(data);
            mRealm.commitTransaction();
        }
        @Override
        public int getResultCount() {
            return mRealm.where(MyPOJO.class).findAllSorted("timestamp", Sort.DESCENDING).size();
        }
        @Override
        public MyPOJO getItemObjectByIndex(int index) {
            try {
                return mRealm.where(MyPOJO.class).findAllSorted("timestamp", Sort.DESCENDING).get(index);
            } catch (Exception e) {
                return null;
            }
        }
        @Override
        public void remove(int position) {
            mRealm.beginTransaction();
            mRealm.where(MyPOJO.class).findAllSorted("timestamp", Sort.DESCENDING).deleteFromRealm(position);
            mRealm.commitTransaction();
        }
        @Override
        public void closeRealm() {
            mRealm.close();
        }
        @Override
        public Realm getRealm() {
            return mRealm;
        }
        @Override
        public void clearRealm() {
            getRealm().beginTransaction();
            getRealm().deleteAll();
            getRealm().commitTransaction();
        }
    

    The RepoImpl instance is being created from two separate classes and the realm instance is being closed only when onDestroy() is triggered in each of the classes. clearRealm() is currently never called.

    Realm version(s): 2.2.1

    Android Studio version: 2.2.3

    Which Android version and device: Samsung SM-A500F (Android 6.0) and Lenovo S1a40 (Android 4.4.4)

    It's seemingly working well on other devices.

    T-Bug-Crash Reproduction-Required 
    opened by sabergeek 104
  • Support MutableRealmInteger

    Support MutableRealmInteger

    (The original initial comment for this issue is here. This heading reflects the current understanding of the project)

    The basic semantics for this feature, now called MutableRealmInteger have finally been sorted out here.

    This issue now tracks implementation.

    TODO:

    • [x] Support unmanaged MutableRealmIntegers
    • [x] Support basic managed MutableRealmIntegers (atomic increment and decrement)
    • [x] Support @Required
    • [x] Support @Index
    • [x] Support JSON and streams
    • [ ] Support Dynamic API
    • [ ] Support RealmList
    T-Feature 
    opened by cmelchior 100
  • couldn't find

    couldn't find "librealm-jni.so"

    After the last android updates i found this error in every project i use realm

    this is the stacktrace:

    08-25 16:03:40.457 16017-16017/it.fortech.fortechmobilepayment E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: it.fortech.fortechmobilepayment, PID: 16017 java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/it.fortech.fortechmobilepayment-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]] couldn't find "librealm-jni.so" at java.lang.Runtime.loadLibrary(Runtime.java:366) at java.lang.System.loadLibrary(System.java:988) at io.realm.internal.RealmCore.loadLibrary(RealmCore.java:114) at io.realm.internal.SharedGroup.(SharedGroup.java:35) at io.realm.Realm.(Realm.java:205) at io.realm.Realm.createAndValidate(Realm.java:594) at io.realm.Realm.create(Realm.java:564) at io.realm.Realm.getInstance(Realm.java:411) at io.realm.Realm.getInstance(Realm.java:368) at io.realm.Realm.getInstance(Realm.java:349) at it.fortech.fortechmobilepayment.account.LoginActivity.onCreate(LoginActivity.java:55) at android.app.Activity.performCreate(Activity.java:5990) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) at android.app.ActivityThread.access$800(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

    Tested on Nexus 5 device Android Studio 1.3 OS X 10.10.5

    T-Bug Reproduction-Required 
    opened by DenisBronx 91
  • App  crashes with FORMAT_UPGRADE_REQUIRED while using Realm 7.0.0

    App crashes with FORMAT_UPGRADE_REQUIRED while using Realm 7.0.0

    We have been using Realm from the past year, We recently upgraded the application from V6.1.0 to V7.0.0, post this upgrade we are witnessing the crash mentioned, we are using Kotlin for application development with Realm java and lastly, we have enabled DB encryption

    Process: com.com.myapp.Application.qa, PID: 31558 java.lang.RuntimeException: Unable to create application com.myapp.Application: io.realm.exceptions.RealmFileException: Opening Realm files of format version 0 is not supported by this version of Realm (Database has an unsupported version and cannot be upgraded Exception backtrace: (/data/data/com.myapp.Application:/files/myapp.realm) in /Users/cm/Realm/realm-java-release/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm.cpp line 107 Kind: FORMAT_UPGRADE_REQUIRED. at io.realm.internal.OsSharedRealm.nativeGetSharedRealm(Native Method) at io.realm.internal.OsSharedRealm.(OsSharedRealm.java:175) at io.realm.internal.OsSharedRealm.getInstance(OsSharedRealm.java:251) at io.realm.BaseRealm.(BaseRealm.java:137) at io.realm.BaseRealm.(BaseRealm.java:104) at io.realm.Realm.(Realm.java:163) at io.realm.Realm.createInstance(Realm.java:499) at io.realm.RealmCache.createInstance(RealmCache.java:507) at io.realm.RealmCache.doCreateRealmOrGetFromCache(RealmCache.java:473) at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:414) at io.realm.Realm.getDefaultInstance(Realm.java:407)

    T-Bug-Crash Reproduction-Required O-Community 
    opened by 73sravanthi 82
  • Fatal signal 11 (SIGSEGV) from Java_io_realm_internal_UncheckedRow_nativeGetString

    Fatal signal 11 (SIGSEGV) from Java_io_realm_internal_UncheckedRow_nativeGetString

    Goal

    No crashes

    Expected Results

    No crashes

    Actual Results

    Crashing consistently for one affected user w/a seemingly corrupted DB state

    A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        Build fingerprint: 'samsung/dreamqltesq/dreamqltesq:8.0.0/R16NW/G950USQU5CRG3:user/release-keys'
        Revision: '12'
        ABI: 'arm64'
    A/DEBUG: pid: 27327, tid: 27372, name: RxComputationTh  >>> com.preveil.preveil <<<
        signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x78713fe000
            x0   00000078704e4380  x1   00000078704e437f  x2   0000007871254317  x3   00000078704e43d8
            x4   00000078704e4380  x5   000000786f5a9d7d  x6   0000000000000000  x7   0000000000000000
            x8   0000000000000000  x9   0000000000000000  x10  0000000000000001  x11  0000000000000000
            x12  000000786fc05210  x13  0000000001000000  x14  0000000000000000  x15  0000000000000000
            x16  000000787380e570  x17  000000788e181970  x18  0000000000000020  x19  00000078704e4380
            x20  000000787376a000  x21  00000078704e4540  x22  00000078713fe000  x23  00000078704e4380
            x24  00000078704e437f  x25  0000000000000001  x26  00000078704e4568  x27  00000078704e45d0
            x28  00000078704e4570  x29  00000078704e42f0  x30  00000078735424e0
            sp   00000078704e42f0  pc   00000078735424cc  pstate 0000000020000000
    09-04 11:23:56.963 27385-27385/? A/DEBUG: backtrace:
            #00 pc 000000000003b4cc  /data/app/com.preveil.preveil-FG01oMB2aWtfSFb4Aipq1w==/lib/arm64/librealm-jni.so
            #01 pc 00000000000be5d8  /data/app/com.preveil.preveil-FG01oMB2aWtfSFb4Aipq1w==/lib/arm64/librealm-jni.so
            #02 pc 00000000000b6f28  /data/app/com.preveil.preveil-FG01oMB2aWtfSFb4Aipq1w==/lib/arm64/librealm-jni.so (Java_io_realm_internal_UncheckedRow_nativeGetString+92)
            #03 pc 0000000000510d00  /system/lib64/libart.so (art_quick_generic_jni_trampoline+144)
            #04 pc 000000000000f8bc  /dev/ashmem/dalvik-jit-code-cache_27327_27327 (deleted)
    

    Steps & Code to Reproduce

    So far, only one known user has encountered this issue. This user will encounter the crash every time they launch the app. Fortunately, I have access to the user's device and have hooked it up to the debugger. There seems to be 3 RealmObjects (all of the same ChildObject type described below) out of hundreds which have somehow corrupted, and trying to access any of these 3 objects will seg fault. I've tried accessing these objects w/in a DynamicRealm, but that seg faults as well.

    Although the stacktrace above happens on a RxComputation thread, when I run everything on the main thread, the crash persists.

    Code Sample

    Unfortunately I can't share specific code or realm files, but I'll describe the relevant schema structure and access which is causing the crash.

    open class ParentObject : RealmObject() {
        @PrimaryKey
        var identifier = UUID.randomUUID().toString()
        var children = RealmList<ChildObject>()
        // other properties
    }
    
    open class ChildObject : RealmObject() {
        @PrimaryKey
        var identifier = UUID.randomUUID().toString()
        // other properties
    }
    
    // Elsewhere, on app launch
    val parents = Realm.getDefaultInstance().where(ParentObject::class.java).findAll()
    parents.forEach { parentObject ->
        parentObject.children.forEach { childObject ->
            // For hundreds of ChildObjects, this is totally fine
            // But for 3 seemingly corrupted objects, this seg faults
            val property = childObject.property
        }
    }
    

    Version of Realm and tooling

    Realm version(s): 5.3.1 w/encryption enabled

    Realm sync feature enabled: no

    Android Studio version: 3.1.3

    Which Android version and device: Samsung Galaxy S8 running Android 8

    T-Bug-Crash O-Customer 
    opened by bfichter 80
  • Fatal Exception: java.lang.IllegalArgumentException Illegal Argument: Invalid format of Realm file.

    Fatal Exception: java.lang.IllegalArgumentException Illegal Argument: Invalid format of Realm file.

    Even with the latest version of Realm I am getting this crash in production builds. It is amusing that the rate I am receiving the crash is tripled with the latest version.

    Crash link

    T-Help Reproduction-Required 
    opened by mihirjoshi21 76
  • Permission denied in /src/main/cpp/io_realm_internal_SharedRealm.cpp line 101 on Huawei P8 and P8 Lite

    Permission denied in /src/main/cpp/io_realm_internal_SharedRealm.cpp line 101 on Huawei P8 and P8 Lite

    Edit by @cmelchior See https://github.com/realm/realm-java/issues/3972#issuecomment-313675948 for the most plausible reason for this.


    Goal

    What do you want to achieve?

    Open Realm file on Huawei P8 and Huawei P8 Lite

    Expected Results

    Realm should work on all devices

    Actual Results

    Apparently there are 2 very specific Huawei devices (Android 6.0) where Realm files cannot be opened.

    There is also possibility that this only occurs in multi-process access, but it is happening in production.

    io.realm.exceptions.RealmError: Unrecoverable error. Permission denied in /Users/Nabil/Dev/realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_SharedRealm.cpp line 101
    	at io.realm.internal.SharedRealm.nativeGetSharedRealm(SharedRealm.java)
    	at io.realm.internal.SharedRealm.<init>(SharedRealm.java:172)
    	at io.realm.internal.SharedRealm.<init>(SharedRealm.java:172)
    	at io.realm.internal.SharedRealm.getInstance(SharedRealm.java:219)
    	at io.realm.internal.SharedRealm.getInstance(SharedRealm.java:209)
    	at io.realm.RealmCache.doCreateRealmOrGetFromCache(RealmCache.java:319)
    	at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:282)
    	at io.realm.Realm.getInstance(Realm.java:353)
    	at x.data.repository.LongRealmRepositoryImpl.<init>(LongRealmRepositoryImpl.java:25)
    	at x.data.repository.impl.tv_programs.program_info.ProgramNotificationRepositoryImpl.<init>(ProgramNotificationRepositoryImpl.java:15)
    	at x.application.RestoreAfterReboot.onReceive(RestoreAfterReboot.java:38)
    	at android.app.ActivityThread.handleReceiver(ActivityThread.java:2760)
    	at android.app.ActivityThread.access$1800(ActivityThread.java:165)
    	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1453)
    	at android.os.Handler.dispatchMessage(Handler.java:102)
    	at android.os.Looper.loop(Looper.java:150)
    	at android.app.ActivityThread.main(ActivityThread.java:5621)
    	at java.lang.reflect.Method.invoke(Method.java)
    	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684)
    

    and

    io.realm.exceptions.RealmError: Unrecoverable error. Permission denied in /Users/Nabil/Dev/realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_SharedRealm.cpp line 101
    	at io.realm.internal.SharedRealm.nativeGetSharedRealm(SharedRealm.java)
    	at io.realm.internal.SharedRealm.<init>(SharedRealm.java:172)
    	at io.realm.internal.SharedRealm.<init>(SharedRealm.java:172)
    	at io.realm.internal.SharedRealm.getInstance(SharedRealm.java:219)
    	at io.realm.internal.SharedRealm.getInstance(SharedRealm.java:209)
    	at io.realm.RealmCache.doCreateRealmOrGetFromCache(RealmCache.java:319)
    	at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:282)
    	at io.realm.Realm.getInstance(Realm.java:353)
    	at x.application.CustomApplication.initializeRealm(CustomApplication.java:397)
    	at x.application.CustomApplication.initialize(CustomApplication.java:229)
    	at x.application.Initializer.initialize(Initializer.java:12)
    	at x.presentation.view.activity.base.BaseActivity.onCreate(BaseActivity.java:261)
    	at x.presentation.view.activity.DashboardActivity.onCreate(DashboardActivity.java:156)
    	at android.app.Activity.performCreate(Activity.java:6367)
    	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
    	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2404)
    	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2511)
    	at android.app.ActivityThread.access$900(ActivityThread.java:165)
    	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1375)
    	at android.os.Handler.dispatchMessage(Handler.java:102)
    	at android.os.Looper.loop(Looper.java:150)
    	at android.app.ActivityThread.main(ActivityThread.java:5621)
    	at java.lang.reflect.Method.invoke(Method.java)
    	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684)
    

    Steps & Code to Reproduce

    I do not have these devices. They are in the wild. But technically it just opens a Realm in Application.onCreate(), or in BroadcastReceiver.onReceive().

    Code Sample

    It really is just opening a Realm configuration. Properties:

    • No encryption
    • deleteIfMigrationNeeded()

    The tricky thing here is that

    1.) these devices already had permission troubles with 1.2.0 (?!) 2.) it only happens on two specific Huawei devices, but it seems to be a popular device, because it affects quite a few users... :| 3.) the access of Realm file is multi-process (broadcast receiver + app itself)

    Version of Realm and tooling

    Realm version(s): 1.2.0 and 4.1.1

    Realm sync feature enabled: no

    Android Studio version: irrelevant

    Which Android version and device:

    Android: 6.0
    Android Build: GRA-L09C150B390
    Manufacturer: HUAWEI
    Model: HUAWEI GRA-L09
    

    and

    Android: 6.0
    Android Build: ALE-L21C150B588
    Manufacturer: HUAWEI
    Model: ALE-L21
    

    (i think this is the same as https://github.com/realm/realm-java/issues/3972 )

    T-Bug-Crash Reproduction-Required O-Community 
    opened by Zhuinden 73
  • io.realm.exceptions.RealmFileException when launching application

    io.realm.exceptions.RealmFileException when launching application

    I have researched many and many times about this issue but I have not found any solution. I am implementing an Android application with Realm Android 3.0 and using Fabric to find out crash report. Below is Realm initialize code in Application class:

     Realm.init(this);
            RealmConfiguration config = new RealmConfiguration.Builder().name(REALM_SCHEMA_NAME)
                    .schemaVersion(REALM_SCHEMA_VERSION)
                    .migration(new Migration())
                    .build();
            Realm.setDefaultConfiguration(config);
            Realm realm = Realm.getDefaultInstance(); // Automatically run migration if needed
            realm.close();
    

    I get many crash report from Fabric related with io.realm.exceptions.RealmFileException such as:

    • Unable to open a realm at path '/data/data/com.xxx/files/xxx.realm': Incompatible histories.
    • Unable to open a realm at path '/data/data/com.xxx/files/xxx.realm': bad realm file header (#3). (bad realm file header (#3))
    • Unrecoverable error. mmap() failed: Out of memory size xxx
    • etc ...

    So, can you tell me the reason of this issue? Thank you.

    T-Help Reproduction-Required 
    opened by jollyjoker992 73
  • deleteAllFromRealm() issue with gradle-plugin:10.13.0  - OK with realm-gradle-plugin:10.12.0

    deleteAllFromRealm() issue with gradle-plugin:10.13.0 - OK with realm-gradle-plugin:10.12.0

    How frequently does the bug occur?

    All the time

    Description

    Hello,

    I wanted to upgrade realm in my Android (Dolphin) project from dependencies = classpath 'io.realm:realm-gradle-plugin:10.12.0' to dependencies = classpath 'io.realm:realm-gradle-plugin:10.13.0'

    I have noticed that using exactly the same code, deleteAllFromRealm() does NOT work with gradle-plugin:10.13.0 - records are not deleted at all!

    Making the same with with gradle-plugin:10.12.0 all records get deleted as usual.

    This is the piece of code, that has two differents results using it with Realm 10.12.0 or Realm 10.13.0

    public void deleteOrderHistoriesFromDB(final String time) {
        realm.executeTransactionAsync(new Realm.Transaction() {
            @Override
            public void execute(@NonNull Realm realm) {
                RealmResults<OderHistoryOl> results = realm.where(OderHistoryOl.class).equalTo("time", time).findAll();
                results.deleteAllFromRealm();
            }
        });
    }
    

    Am I making some mistake in code?

    Thank you for help.

    Stacktrace & log output

    No response

    Can you reproduce the bug?

    Yes, always

    Reproduction Steps

    Leaving exactly the same java code, but only changing build.gradle dependencies = classpath 'io.realm:realm-gradle-plugin:10.12.0'
    to dependencies = classpath 'io.realm:realm-gradle-plugin:10.13.0' will allways cause the issue

    Version

    classpath 'io.realm:realm-gradle-plugin:10.13.0'

    What SDK flavour are you using?

    Local Database only

    Are you using encryption?

    Yes, using encryption

    Platform OS and version(s)

    Android 7, Android 11

    Build environment

    Win10 64Bit Android Studio Dolphin | 2021.3.1
    Android Gradle Plugin Version 7.3.0
    Gradle version 7.6

    T-Bug O-Community Waiting-For-Reporter 
    opened by LeonardDaVinci 5
  • [Bug]: Hello, do I have bugs collected from an online project?

    [Bug]: Hello, do I have bugs collected from an online project?

    What happened?

    io.realm.exceptions.RealmFileException: Opening Realm files of format version 0 is not supported by this version of Realm (Database has an unsupported version and cannot be upgraded

    Repro steps

    An error is reported when opening the program initialization configuration Could you tell me when this error occurred? The database version upgrade is not involved in the use

    Version

    Android sdk7.0.0版本

    What SDK flavour are you using?

    Local Database only

    What type of application is this?

    Other

    Client OS and version

    Android系统8.0

    Code snippets

    /** * 自定义Realm配置 * * @return */ public void setRealmConfig(String dbName) { MyLog.i(TAG, "RealmUtils.dbName=" + dbName); RealmConfiguration config = new RealmConfiguration.Builder() .name(dbName + ".realm") .encryptionKey(Utils.getRealmKey(REALMKEY)) //设置密钥 .schemaVersion(dbVersion) //版本号 0 .migration(new MyRealmMigration()) //数据库迁移/ // .deleteRealmIfMigrationNeeded()//声明版本冲突时自动删除原数据库,开发时候打开 .build(); Realm.setDefaultConfiguration(config); MyLog.i(TAG, "config=" + config.getRealmFileName()); realm = Realm.getInstance(config); }

    Stacktrace of the exception/crash you're getting

    No response

    Relevant log output

    No response

    O-Community More-information-needed Waiting-For-Reporter 
    opened by LhtIverson 1
  • Update to Core v13.1.1

    Update to Core v13.1.1

    • Updated to Core v13.1.1.
    • Fixed a bug that would result in RealmDictionary not being able to find double values due not taking the precision of the input parameter into consideration when using RealmDictionary.contains.
    • Added a message buffer for our test logger since Core now logs more messages than before when logging. This broke our obfuscator tests.
    cla: yes 
    opened by edualonso 1
  • multi table

    multi table

    Problem

    how can i create double table base on one model?

    Solution

    No response

    Alternatives

    No response

    How important is this improvement for you?

    No response

    T-Enhancement O-Community Waiting-For-Reporter 
    opened by dakexuan 3
  • Fatal Exception: io.realm.exceptions.RealmError: Unrecoverable error. transaction_ended

    Fatal Exception: io.realm.exceptions.RealmError: Unrecoverable error. transaction_ended

    How frequently does the bug occur?

    All the time

    Description

    1. This issue has 64046 crash events affecting 12175 users
    2. We are not able to reproduce this one on our end

    Stacktrace & log output

    <backtrace not supported on this platform> in /tmp/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_Table.cpp line 901
           at io.realm.internal.Table.nativeWhere(Table.java)
           at io.realm.internal.Table.where(Table.java:638)
           at io.realm.RealmQuery.<init>(RealmQuery.java:154)
           at io.realm.RealmQuery.createQuery(RealmQuery.java:94)
           at io.realm.Realm.where(Realm.java:1564)
           at in.bizanalyst.dao.GroupDao.getAll(GroupDao.java:43)
           at in.bizanalyst.dao.GroupDao.getGroupsByParent(GroupDao.java:70)
           at in.bizanalyst.dao.CustomerDao.getQuery(CustomerDao.java:498)
           at in.bizanalyst.dao.CustomerDao.getAllByGroup(CustomerDao.java:235)
    

    Can you reproduce the bug?

    Not yet

    Reproduction Steps

    No response

    Version

    10.11.0

    What SDK flavour are you using?

    Local Database only

    Are you using encryption?

    Yes, using encryption

    Platform OS and version(s)

    Android SDK: 23, 25, 27, 28, 29, 30, 31, 32, 33

    Build environment

    Android Studio version: Android Studio Dolphin | 2021.3.1 Patch 1 Android Build Tools version: 33.0.0 Gradle version: 7.2.2

    T-Bug O-Community More-information-needed Waiting-For-Reporter 
    opened by silicon-pranit 4
Owner
Realm
Realm is a mobile database: a replacement for SQLite & ORMs. SDKs for Swift, Objective-C, Java, Kotlin, C#, and JavaScript.
Realm
A simple ToDo app to demonstrate the use of Realm Database in android to perform some basic CRUD operations like Create, Update and Delete.

Creating a Realm Model Class @RealmClass open class Note() : RealmModel { @PrimaryKey var id: String = "" @Required var title: String

Joel Kanyi 15 Dec 18, 2022
An Android library that makes developers use SQLite database extremely easy.

LitePal for Android 中文文档 LitePal is an open source Android library that allows developers to use SQLite database extremely easy. You can finish most o

Lin Guo 7.9k Dec 31, 2022
SquiDB is a SQLite database library for Android and iOS

Most ongoing development is currently taking place on the dev_4.0 branch. Click here to see the latest changes and try out the 4.0 beta. Introducing S

Yahoo 1.3k Dec 26, 2022
Compile time processed, annotation driven, no reflection SQLite database layer for Android

SqliteMagic Simple yet powerful SQLite database layer for Android that makes database handling feel like magic. Overview: Simple, intuitive & typesafe

Siim Kinks 118 Dec 22, 2022
android 数据库框架,sqlite database

DBExecutor 主要的功能 1.使用了读写锁,支持多线程操作数据。 2.支持事务 3.支持ORM 4.缓存Sql,缓存表结构 这个类库主要用于android 数据库操作。 始终围绕着一个类对应一个表的概念。 只要创建一个实体类,就不用当心它怎么存储在数据库中,不用重新写增删改查的代码。基本的功

null 77 May 31, 2021
LiteOrm is a fast, small, powerful ORM framework for Android. LiteOrm makes you do CRUD operarions on SQLite database with a sigle line of code efficiently.

#LiteOrm:Android高性能数据库框架 A fast, small, powerful ORM framework for Android. LiteOrm makes you do CRUD operarions on SQLite database with a sigle line

马天宇 1.5k Nov 19, 2022
An Android library that makes developers use SQLite database extremely easy.

LitePal for Android 中文文档 LitePal is an open source Android library that allows developers to use SQLite database extremely easy. You can finish most o

Lin Guo 7.9k Jan 4, 2023
Samples demonstrating the usage of Realm-Kotlin SDK

Realm-Kotlin Samples This repository contains a set of projects to help you learn about using Realm-Kotlin SDK Each sample demonstrates different use

Realm 52 Dec 31, 2022
A blazing fast, powerful, and very simple ORM android database library that writes database code for you.

README DBFlow is fast, efficient, and feature-rich Kotlin database library built on SQLite for Android. DBFlow utilizes annotation processing to gener

Andrew Grosner 4.9k Dec 30, 2022
A blazing fast, powerful, and very simple ORM android database library that writes database code for you.

README DBFlow is fast, efficient, and feature-rich Kotlin database library built on SQLite for Android. DBFlow utilizes annotation processing to gener

Andrew Grosner 4.9k Dec 30, 2022
Active record style SQLite persistence for Android

ActiveAndroid ActiveAndroid is an active record style ORM (object relational mapper). What does that mean exactly? Well, ActiveAndroid allows you to s

Michael Pardo 4.7k Dec 29, 2022
greenDAO is a light & fast ORM solution for Android that maps objects to SQLite databases.

Check out ObjectBox Check out our new mobile database ObjectBox (GitHub repo). ObjectBox is a superfast object-oriented database with strong relation

Markus Junginger 12.6k Jan 3, 2023
Active record style SQLite persistence for Android

ActiveAndroid ActiveAndroid is an active record style ORM (object relational mapper). What does that mean exactly? Well, ActiveAndroid allows you to s

Michael Pardo 4.7k Dec 29, 2022
Android SQLite API based on SQLCipher

Download Source and Binaries The latest AAR binary package information can be here, the source can be found here. Compatibility SQLCipher for Android

SQLCipher 2.6k Dec 31, 2022
Extended SQLite functionality for Android

sqlite-provider A simplification of database access for Android. Description sqlite-provider implements a ContentProvider for you that allows database

Novoda 308 Nov 20, 2022
lightweight and minimalist ORM for Java/Android. works with SQLite & MySQL. (not actively maintained)

Description ORMAN is an minimalistic and lightweight ORM framework for Java which can handle your common database usage without writing SQL and strugg

Ahmet Alp Balkan 246 Nov 20, 2022
A Java/Kotlin library for Android platform, to manage bean's persistence in SQLite, SharedPreferences, JSON, XML, Properties, Yaml, CBOR.

Thanks to JetBrains for support Kripton Persistence Library project! Kripton Persistence Library Kripton is a java library, for Android platform, that

xcesco 117 Nov 11, 2022
AndroidQuery is an Android ORM for SQLite and ContentProvider which focuses on easy of use and performances thanks to annotation processing and code generation

WARNING: now that Room is out, I no longer maintain that library. If you need a library to easy access to default android ContentProvider, I would may

Frédéric Julian 19 Dec 11, 2021
lightweight and minimalist ORM for Java/Android. works with SQLite & MySQL. (not actively maintained)

Description ORMAN is an minimalistic and lightweight ORM framework for Java which can handle your common database usage without writing SQL and strugg

Ahmet Alp Balkan 246 Nov 20, 2022