Skip to content

Commit

Permalink
✨ feat: Update jni version for Android
Browse files Browse the repository at this point in the history
  • Loading branch information
caoccao committed Sep 2, 2024
1 parent 96bede1 commit f27958c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@

use anyhow::Result;
use jni::objects::{JClass, JObject, JString};
use jni::sys::{jint, jobject, jstring, JNI_VERSION_1_8};
#[cfg(target_os = "android")]
use jni::sys::JNI_VERSION_1_6;
#[cfg(not(target_os = "android"))]
use jni::sys::JNI_VERSION_1_8;
use jni::sys::{jint, jobject, jstring};
use jni::{JNIEnv, JavaVM};
use jni_utils::FromJava;

Expand Down Expand Up @@ -52,7 +56,11 @@ pub extern "system" fn JNI_OnLoad<'local>(java_vm: JavaVM, _: c_void) -> jint {
plugin_utils::init(&mut env);
span_utils::init(&mut env);
token_utils::init(&mut env);
JNI_VERSION_1_8
#[cfg(target_os = "android")]
let jni_version = JNI_VERSION_1_6;
#[cfg(not(target_os = "android"))]
let jni_version = JNI_VERSION_1_8;
jni_version
}

#[no_mangle]
Expand Down

0 comments on commit f27958c

Please sign in to comment.