Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No implementation found for void io.realm.kotlin.internal.interop.realmcJNI.set_log_callback #1508

Closed
ronjunevaldoz opened this issue Sep 8, 2023 · 11 comments

Comments

@ronjunevaldoz
Copy link

ronjunevaldoz commented Sep 8, 2023

How frequently does the bug occur?

Always

Description

Trying to setup using the latest Kotlin compose multiplatform 1.5.0. The dependency is working properly but when accessing the realm it gives an error.

val realm by lazy {
    val config = RealmConfiguration.create(setOf(Task::class))
    Realm.open(config)
}

Stacktrace & log output

`No implementation found for void io.realm.kotlin.internal.interop.realmcJNI.set_log_callback(int, java.lang.Object) (tried Java_io_realm_kotlin_internal_interop_realmcJNI_set_1log_1callback and Java_io_realm_kotlin_internal_interop_realmcJNI_set_1log_1callback__ILjava_lang_Object_2)`

Can you reproduce the bug?

Always

Reproduction Steps

Setup the realm using kotlin compose multiplatform template 1.5.0 https://github.com/JetBrains/compose-multiplatform-template#readme

Additional changes made:

android {
    compileSdk = (findProperty("android.compileSdk") as String).toInt()
    namespace = "com.myapplication.common"

    sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
    sourceSets["main"].res.srcDirs("src/androidMain/res")
    sourceSets["main"].resources.srcDirs("src/commonMain/resources")
    defaultConfig {
        minSdk = (findProperty("android.minSdk") as String).toInt()
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }

    kotlin {
        jvmToolchain(17)
    }
}



// work around realm
project.afterEvaluate {
    kotlin.targets .all {
         compilations.all {
            (kotlinOptions as? org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions)?.jvmTarget = "17"
        }
    }
}

configurations.all {
    resolutionStrategy.cacheChangingModulesFor(0, "seconds")
}

Version

1.11.1

What Atlas App Services are you using?

Local Database only

Are you using encryption?

No

Platform OS and version(s)

Windows 11

Build environment

Android Studio version: Android Studio Giraffe | 2022.3.1 Patch 1
Android Build Tools version: 8.0.2
Gradle version: 8.2.1

@cmelchior
Copy link
Contributor

It looks like the native code doesn't contain that particular method. It was added in 1.8.0, so perhaps you are somehow loading an older version of the native code.

Two questions:

@ronjunevaldoz
Copy link
Author

  1. I was using 1.11.1 for both plugin and library
    id("io.realm.kotlin").version(1.11.1)
    io.realm.kotlin:library-base:1.11.1
  2. No I'm not overriding any java.libraries.path

@cmelchior
Copy link
Contributor

I just tried to run https://github.com/realm/realm-kotlin-samples/tree/main/JVMConsole with Realm 1.11.1 on Windows and it loads fine.

So I still suspect it is a problem somewhere in your setup. Have you tried to reproduce it on multiple machines? (if available)

If you can reproduce in a small sample project, can you share that?

@ronjunevaldoz
Copy link
Author

ronjunevaldoz commented Sep 8, 2023

@cmelchior I found the root cause, adding a custom worker provider making it error.

<provider
  android:name="androidx.startup.InitializationProvider"
  android:authorities="${applicationId}.androidx-startup"
  tools:node="remove" />

@timonmw
Copy link

timonmw commented Oct 4, 2023

i have the same problem but i don't have any provider in my project. Did you solve it by just removing the Provider?

@langsmith
Copy link

langsmith commented Oct 4, 2023

I'm using io.realm.kotlin:library-base:1.11.1, and like @ronjunevaldoz , had the InitializationProvider in my manifest. Removing the InitializationProvider got the Realm set_log_callback 💥 to go away. However, I need(ed) the InitializationProvider to get WorkManager working with Hilt 😕. I'd be interested to see whether the Mongo team could get all three libraries working in conjunction with one another...

@timonmw
Copy link

timonmw commented Oct 5, 2023

        val appInitializer = AppInitializer.getInstance(this)
        appInitializer.initializeComponent(RealmInitializer::class.java)

This solved the Problem for me without removing the InitializationProvider

@langsmith
Copy link

        val appInitializer = AppInitializer.getInstance(this)
        appInitializer.initializeComponent(RealmInitializer::class.java)

This solved the Problem for me without removing the InitializationProvider

@timonmw , where did you run that code?

@timonmw
Copy link

timonmw commented Oct 10, 2023

@langsmith I put it in the onCreate of the Application

@kenhuang
Copy link

any suggestion how we can apply similar changes to a react-native Android project? seems facing a similar issue when we upgraded to react-native 0.72, our project use both realm-js and realm-kotlin.

Getting the following error on MainApplication.java and followed this installation guide.

 Getting compile error:  MainApplication.java:67: error: <identifier> expected appInitializer.initializeComponent(RealmInitializer::class.java);

finding similar changes on AndroidManifest.xml after react-native 0.72 upgrade:

 <provider
            android:name="androidx.startup.InitializationProvider"
            android:authorities="com.example.androidx-startup"
            android:exported="false" >
...

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants