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

Kotlin can not call Rust JNI? #149

Open
Edison0716 opened this issue Jul 3, 2024 · 2 comments
Open

Kotlin can not call Rust JNI? #149

Edison0716 opened this issue Jul 3, 2024 · 2 comments

Comments

@Edison0716
Copy link

Edison0716 commented Jul 3, 2024

I have wrote a JNI function in lib.rs by kotlin, but not call native func.

image

image

When I convert to Java, native func can be called.

image

Looks like kotlin can not call native func ?

@Edison0716
Copy link
Author

Edison0716 commented Jul 3, 2024

image

image

@Edison0716 Edison0716 changed the title No implementation found for JNI func. Kotlin can not call Rust JNI? Jul 3, 2024
@jiangkerLove
Copy link

Because your Java and kotlin codes are not consistent, kotlin uses static methods, you can try this

class Airbag {

    external fun test(input: String)

    companion object {
        init {
            System.loadLibrary("airbag")
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants