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
Support adding a Flutter add-to-app module to a Flutter-created app #64542
Comments
Similar to #39707, though it's not quite the same. This proposal is to add a Flutter module to a Flutter app, and that one is to add multiple modules to a native app. |
I also need this. any updates? |
It is quite different from adding a Flutter module to a Flutter app which is integrated in source code level,that means Flutter app can touch the flutter module‘s dart codes。In my situation,the target flutter app can only integrate my SDK,the SDK contains no dart source code,but the libapp.so that is the AOT shared library。 |
@chandarlee it's similar in that it needs to handle the problem |
we lost one custom for their app is written in flutter and our SDK was written in flutter and android; |
@wanjm Can you ship your functionality as a Flutter plugin instead? Flutter plugins contain dart and native code, and are made to be consumed by other Flutter apps. |
out sdk can't be open sourced; |
You can distribute the native code or FFI as a binary but you're right, I don't think you can with the dart code. |
This comment has been minimized.
This comment has been minimized.
For now, I have found a workaround for Android which need to load the flutter engine a second time , and lead to much more memory consume. Beyond that , everything just work fine. For iOS to work, I am still trying. |
@chandarlee could you please share me the steps and how to build it; |
This comment has been minimized.
This comment has been minimized.
/cc @gaaclarke @cbracken |
I'm also very much interested in this feature. @chandarlee, could you share the basic idea of the android workaround you found? This would be very much appreciated! And did you meanwhile find a solution for iOS? |
Given #72009 and https://github.com/flutter/samples/tree/master/add_to_app/multiple_flutters this may just be a request for additional documentation to special-case Flutter modules when the host app is also using Flutter. @gaaclarke does that sound right, or would there be additional work needed? |
@jmagman No, this sounds like it would need some tooling support and documentation. For example, a flutter module is going to try to incorporate the flutter dynamic library and the flutter app is going to try the same thing. Multiple-flutters just helps you launch multiple instances of the same flutter module (with different entry-points) in a low memory / time cost way. It doesn't do any tooling work to support multiple flutter projects on disk. |
Great to see activity on this issue! @gaaclarke could you please shed some light about the effort and time horizon it needs to solve the issue? As this issue is very important for us, I could also work on that issue if you could point me towards the places where the work is to do. |
@wanjm @bottee I am sorry to be late for response. My workaround on Android is a little bit hack and memory consumed. The main point is a custom ClassLoader. Follows are the key steps: Rename the generated libapp.so to libapp-new.so and libflutter.so to libflutter-new.so, this is to avoid file conflict with host application which also built with flutter. It is easy to do this either by gradle or manually. For iOS platform , I am still working on that. I think if flutter engine support binding to one or more aot-shared-library or kind of tool to merge them when building apk/ipa, it is easy to fix the problem. |
Any news on this issue? Really need it. |
There isn't anyone working on this as far as I know. I'd interpret that as people deemed this lower priority than the other issues, not that they don't think it's a legitimate issue. May I propose another avenue to get what you want? You have Flutter code you want to provide to customers, but you don't want to be open source, correct? If you were a Unity developer making a plugin, you'd have 2 options: 1) Ship the source code with your plugin 2) Ship a .dll file with your plugin. The dll is a compiled artifact, that will get compiled again, this time for AOT, when the final app is built. The Dart equivalent would be a Kernel, which I think the Dart team has explicitly stated isn't stable. You might want to see if you can get them to support plugins that have Kernels tied to a specific version of Dart. That way you could distribute your compiled code as a plugin, but you'd have to say something like it only works for Flutter 2.0.2 (you could supply multiple version to download). edit: FWIW I posed the question about a stable Kernel to the Dart team and standardizing an interface for the VM isn't something they're working on. The language is still changing a lot under the hood. That means allowing a kernel plugin tied to a specific version would be the best bet. |
is there any way to minify the dart code? |
Hello @xster , I saw your github profile that you're one of the flutter contributor. Do you by any chance have some information on this issue? |
I don't have more insights into this issue. @gaaclarke's comment is the right one imo. We either figure out a way to add a dependency restriction to the module itself and require a specific version of the engine and ditch the flutter.so from the module and have the app's flutter.so somehow load 2 libapp.so (difficult), or ship pre-built dart code instead of shipping pre-built modules (also difficult). @mossmana or @leighajarett are likely the right people to evaluate the investment there. |
FYI @reidbaker |
This comment was marked as off-topic.
This comment was marked as off-topic.
any news on this front? I believe since flutter is used more and more, this is quite important. We must have a way to develop module in flutter, pack it as AAR and 3rd party could just use our AAR and integrate. Unfortunately, there are lot's of situations where developers don't want to share source code in plain text. At least is there some minifier / obfuscator which could change our dart code so that it's hard to read? |
同求,要是flutter能像luajava那样,在lua脚本中直接调用jar和so就好了,但是现在好像只有platform channel?很麻烦 |
Use case
I have been working on a SDK project which is written with flutter. We implement our common business logic with flutter, and then provide Android/iOS native interfaces which just forward API request from native to flutter to work.
Then we build and assemble all the things together(generated libapp.so, flutter asserts and else), deliver as SDK in the form of AAR and Framework to developers.
To integrate the SDK to the projects which do not use flutter , it is simple and just works great.
But for those project which also use flutter, it does not work. As our SDK already has its own libapp.so, and the target project will also generates its own libapp.so too, but flutter engine does not support load two or more aot library simultaneously.
For now or future, our sdk just cannot be open source, so we cannot provide a flutter package to use. So we have to figure out another way to work out this situation.
Proposal
The text was updated successfully, but these errors were encountered: