fzyzcjy / flutter_rust_bridge

Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.
https://fzyzcjy.github.io/flutter_rust_bridge/
MIT License
4.23k stars 291 forks source link

Is it possbile to build an Android app with a third party library as dependent on rust side? #399

Closed dbsxdbsx closed 2 years ago

dbsxdbsx commented 2 years ago

From the rust side, if there is a crate like this, which need to install some libraries as dependency, is it possible to transfer the whole as an app without issue on Android?

fzyzcjy commented 2 years ago

Sure. Indeed I have opencv + rust in my app in production, using exactly that crate.

dbsxdbsx commented 2 years ago

Sure. Indeed I have opencv + rust in my app in production, using exactly that crate.

@fzyzcjy, Is it essential to install the opencv linux library manually on Android, or do nothing just wrap the whole project with flutter_rust_bridge as an Apk and do installation normally?

If the second one is the case, does it mean that I can debug and test it even on windows? Does the dependencies copied to android when doing installation?

And also, how do you solve the cuda issue, since cuda canot be installed on android.

fzyzcjy commented 2 years ago

Is it essential to install the opencv linux library manually on Android, or do nothing just wrap the whole project with flutter_rust_bridge as an Apk and do installation normally?

Just bundle libopencv.so or something like that in the android app and everything is fine. Just like when people use opencv with c++ for android app. In other words, the user only see a very normal apk and nothing special.

fzyzcjy commented 2 years ago

If the second one is the case, does it mean that I can debug and test it even on windows? Does the dependencies copied to android when doing installation?

Surely you can run rust+opencv+flutter on windows. you need a new compilation pipeline, but the code is the same.

fzyzcjy commented 2 years ago

And also, how do you solve the cuda issue, since cuda canot be installed on android.

opencv does not need cuda, and cuda is for nvidia GPU which android usually do not have. If you want to run neural networks, try tflite (I have used it in android and ios and it works very well).

dbsxdbsx commented 2 years ago

If the second one is the case, does it mean that I can debug and test it even on windows? Does the dependencies copied to android when doing installation?

Surely you can run rust+opencv+flutter on windows. you need a new compilation pipeline, but the code is the same.

@fzyzcjy, thanks your answer. But I mean that I have no doubt on windows, as I am coding on windows. I curious on how to transfer the opencv lib to android, since the complied opencv lib shouln't be able to run on android directly.

fzyzcjy commented 2 years ago

I curious on how to transfer the opencv lib to android, since the complied opencv lib shouln't be able to run on android directly.

opencv has android build on official website.

dbsxdbsx commented 2 years ago

@fzyzcjy , now I see. So generally, if the 3rd dependencies has no target-platform library, It is impossible to work it around through by flutter_rust_bridge.

fzyzcjy commented 2 years ago

So generally, if the 3rd dependencies has no target-platform library, It is impossible to work it around through by flutter_rust_bridge.

frb is just a tiny bridge. You will then need to discuss with that lib's owner.

github-actions[bot] commented 2 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue.