mb64 / android-ndk-rs Goto Github PK
View Code? Open in Web Editor NEWRust bindings to the Android NDK
License: Apache License 2.0
Rust bindings to the Android NDK
License: Apache License 2.0
Since currently different alternatives to jni crate can be used for interfacing with java runtime I propose avoid jni wrappers in favor low level jni-sys types.
#[link(name = "android")] // add this
extern "C" {
pub fn AAssetManager_fromJava(env: *mut JNIEnv, assetManager: jobject) -> *mut AAssetManager;
}
Hey there! thanks for this library!
I ran into this issue, possibly related to my build process, when I build some code using android_ndk
. When I add android_ndk
My .so
file now has the symbol AConfiguration_getScreenRound.
Which makes sense because you create the bindings for android/configuration. But Android can't seem to find the thing to link it to!
I also get this issue when adding AConfiguration_getScreenRound(state->config)
to the native-activity sample in ndk-samples.
Maybe I didn't link some library? I looked at the symbols in all of the lib*.so in the ndk and I didn't see a symbol for AConfiguration_getScreenRound
either (but I see symbols for AConfiguration_getScreenLong
). So I don't think I'm forgetting to link something.
Maybe if you too can't get it working, then AConfiguration_getScreenRound
should be behind a cargo feature?
Or am I missing something really obvious?
I don't sure, this problem actually related to android-ndk-sys nor jni crate but it looks very strange for me.
Also I don't quite familiar with JNI, so I may do wrong things here.
My rust code looks like a piece below:
let app = unsafe { AndroidApp::from_ptr(android_glue::get_android_app()) };
let activity = app.activity();
let sdk_version = activity.sdk_version();
println!("SDK VERSION: {}", sdk_version);
let env = vm.attach_current_thread()?;
println!("ENV: {:?}", env.get_version());
println!("Activity: {:?}", activity);
let class = env.find_class("android/app/NativeActivity")?;
println!("Found NativeActivity class: {:?}", class);
let class = env.get_object_class(activity)?;
println!("Actual Activity class: {:?}", class);
But application failed on last line.
12-30 21:33:17.419 10414 10429 D RustStdoutStderr: SDK VERSION: 28
12-30 21:33:17.420 10414 10429 D RustStdoutStderr: ENV: Ok(V6)
12-30 21:33:17.420 10414 10429 D RustStdoutStderr: Activity: JObject { internal: 0x99f0a60c, lifetime: PhantomData }
12-30 21:33:17.420 10414 10429 D RustStdoutStderr: Found NativeActivity class: JClass(JObject { internal: 0x1, lifetime: PhantomData })
12-30 21:33:17.522 10414 10430 F .rust_oboe_dem: java_vm_ext.cc:542] JNI DETECTED ERROR IN APPLICATION: use of invalid jobject 0x99f0a60c
It seems, activity instance object is invalid.
But I understand that it may not be what it seems.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.