-
Notifications
You must be signed in to change notification settings - Fork 0
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
Integration with Flutter #3
Comments
The current workaround is to configure environment variables according to https://docs.rs/android-build/latest/android_build. The error is from https://docs.rs/android-build/latest/src/android_build/env_paths/mod.rs.html#68-84. This should be considered as a bug of "is it possible to avoid using calls to Java classes?" Since version 0.2.1, "Sounds like nusb has everything we need to interoperate with USB interface." Currently it is not the case even with v0.2.0 (which shouldn't cause this build error). kevinmehall/nusb#86 |
I've released |
It seems that I still have an issue but now of a different kind. The library failes on match android_usbser::CdcSerial::probe() {
Ok(devices) => {
rinf::debug_print!("Devices (android_usbser): {:#?}", &devices);
}
Err(err) => {
rinf::debug_print!("Error (android_usbser): {:#?}", &err);
},
}; This gives me:
Just in case. I had an error before related to the uninitialized Android context that I've fixed in a way described in flutter_rust_bridge/issues/1323. |
I suspect that this is related to the way how context is initialized in Flutter. It seems that we need to cache classes during JVM |
The error message came from https://docs.rs/jni/0.21.1/src/jni/wrapper/jnienv.rs.html#1370. Since it's got in
I guess it's unlikely that the error came from some other location. Please add Self-note: I found another possible improvement for |
Thank you for reopening the issue. Here is what I have for: let ctx = jni_min_helper::android_context();
rinf::debug_print!("Android context: {:?}", ctx);
match android_usbser::CdcSerial::probe() {
Ok(devices) => {
rinf::debug_print!("Devices (android_usbser): {:#?}", &devices);
}
Err(err) => {
rinf::debug_print!("Error (android_usbser): {:#?}", &err);
},
}; Result:
I must add that I initialize android context in the way descibed here (method 1). Without such initialization Android context is not present. |
I've also tried the same with Flutter Rust Bridge in case that Rinf has issues. Still the same (but they have a better logging out of the box):
|
The problem is shown: Looking into I think the JVM pointer got from I haven't learnt Flutter previously, and I'm afraid that I can't help with the issue any further. The issue may still be closed because it's not a bug of my crate. |
It seems that this is indeed a Flutter issue. I've created an issue in Flutter Rust Bridge. |
|
Thank you a lot, @wuwbobo2021! It works on Flutter with FRB with your fixes. I've performed a dirty test with my device, written a command and receive an output. This means that this issue is resolved. |
BTW, how the workaround for this issue works? |
See <https://docs.rs/crate/jni-min-helper/0.2.5/source/CHANGELOG.md>. Note: Version 0.2.4 is a bad version that always use `ActivityThread.currentActivityThread().getApplication()` which should be used as a fallback, it is yanked.
…________________________________
发件人: Mykhailo Ziatin ***@***.***>
发送时间: 2024年12月25日 5:26
收件人: wuwbobo2021/android-usbser-rs ***@***.***>
抄送: wu bobo ***@***.***>; Mention ***@***.***>
主题: Re: [wuwbobo2021/android-usbser-rs] Integration with Flutter (Issue #3)
BTW, how the workaround for this issue works?
―
Reply to this email directly, view it on GitHub<#3 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AVFLUNSQF4HE4PCXLPJ6B5T2HHGR7AVCNFSM6AAAAABUBSXVKKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNRRGQ2TSMRWGM>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
I see. You mean this. Thank you a lot again for the quick fix. |
Not sure it 100% belongs here. Nevertheless, let's give it a try.
I am trying to integrate your library with Flutter (I've tied both Rinf and Flutter Rust Bridge). But it fails to build:
All other Rust code successfully builts for Android.
I am also curious: is it possible to avoid using calls to Java classes? Sounds like nusb has everything we need to interoperate with USB interface.
The text was updated successfully, but these errors were encountered: