-
Notifications
You must be signed in to change notification settings - Fork 820
Add section on JNI / FFI, Android 16KB memory alignment #3575
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
base: v2
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for tauri-v2 ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
| Then in your plugin's Rust code, define the function JNI will look for: | ||
|
|
||
| ```rust | ||
| #[cfg(target_os = "android")] | ||
| #[no_mangle] | ||
| pub extern "system" fn Java_com_example_HelloWorld_helloWorld( | ||
| mut env: JNIEnv, | ||
| _class: JClass, | ||
| name: JString, | ||
| ) -> jstring { | ||
| log::debug!("Calling JNI Hello World!"); | ||
| let result = format!("Hello, {}!", name); | ||
|
|
||
| match env.new_string(result) { | ||
| Ok(jstr) => jstr.into_raw(), | ||
| Err(e) => { | ||
| log::error!("Failed to create JString: {}", e); | ||
| std::ptr::null_mut() | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does Java_com_example_HelloWorld_helloWorld has any correlation with the app name, if so, could you add an aside or note about it. Same about the ios section.
I see patterns but I really don't know if is for illustration or code convention/requirement
thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good note, updated to clarify naming conventions. Thanks for the feedback!
…uri-docs into bclarke/mobile-plugin-tips
…uri-docs into bclarke/mobile-plugin-tips

Description
Hi, thanks for this fantastic project! I could only find a few code examples to explain how to call Rust directly from Swift / Kotlin, so I added a brief section to the mobile plugin development page. Also, I added an explanation on how to configure Android builds to be compatible with the new 16KB memory alignment requirements. All feedback welcome!