Search code examples
javaandroidmongodbandroid-studiorealm

Realm Local Database not working with Android Studio (Java)


This is added to my build.gradle Project file:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "io.realm:realm-gradle-plugin:10.15.0"
    }
}

This is added to my build.gradle Application file:

apply plugin: "realm-android"

implementation 'io.realm:realm-gradle-plugin:10.15.0'

Error is:

> java.lang.IllegalAccessError: class io.realm.processor.Utils (in unnamed module @0x319c63c6) cannot access class com.sun.tools.javac.code.Symbol$ClassSymbol (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.code to unnamed module @0x319c63c6

Gradle Sync is successful but Build fails with error described. I am using AGP 8.0.0 and Gradle version 8.1 with Java version VERSION_11 and min sdk 24 and target sdk 33.


Solution

  • I've had the same problem.

    I updated the Realm Gradle plugin to version 10.15.1:

    dependencies {
        classpath 'com.android.tools.build:gradle:8.0.0'
        classpath 'io.realm:realm-gradle-plugin:10.15.1'
    }
    

    The error disappeared after a sync and rebuild of the project.

    My Android studio Grandle JDK are 17.0.6.

    I hope these tips are helpful to you.