Skip to content
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

Mechanism for using static library on Android? #75492

Closed
buzmeg opened this issue Feb 5, 2021 · 3 comments
Closed

Mechanism for using static library on Android? #75492

buzmeg opened this issue Feb 5, 2021 · 3 comments
Labels
r: invalid Issue is closed as not valid

Comments

@buzmeg
Copy link

buzmeg commented Feb 5, 2021

I can install my dynamic library libopus.so into my Flutter project by placing it in the android/src/main/jniLibs/arm64-v8a folder. That works fine and DynamicLibrary.open() finds it.

However, if I try to use a static library, "libopus.a" that fails.

Where do I put the ".a" file on Android? And how do I lookup the symbol?

This is the Dart/Flutter code I am using:


final DynamicLibrary lib_opus_native = DynamicLibrary.process(); // This fails on symbol lookup
//final DynamicLibrary lib_opus_native = DynamicLibrary.open("libopus.a");  // This fails immediately
//final DynamicLibrary lib_opus_native = DynamicLibrary.open("libopus.so");  // This succeeds but is pulling in dynamic not static

final int Function(int channels) opus_encoder_get_size = lib_opus_native
    .lookup<NativeFunction<Int32 Function(Int32)>>("opus_encoder_get_size")
    .asFunction();  // This worked for the dynamic library

Thanks.

@pedromassangocode
Copy link

Hi @buzmeg
It seems you are asking for assistance on personal code. Please see https://flutter.dev/community for resources and asking questions like this,
you may also get some help if you post it on Stack Overflow and if you need help with your code, please see https://www.reddit.com/r/flutterhelp/
Closing, as this isn't an issue with Flutter itself. If you disagree, please write in the comments and I will reopen it.
Thank you

@pedromassangocode pedromassangocode added the r: invalid Issue is closed as not valid label Feb 5, 2021
@buzmeg
Copy link
Author

buzmeg commented Feb 5, 2021

Perhaps. But you will note that the case of "Static Library For Android" is missing from:

"Binding to native code using dart:ffi"
https://flutter.dev/docs/development/platform-integration/c-interop

And, having already looked rather extensively through both Google and StackOverflow, it seems like nobody who asked this question actually got any solution.

At minimum, this is a documentation fault. At maximum, this can't be done and is a genuine bug.

I know that I certainly don't have enough knowledge about Flutter to determine which category this falls into.

So, I'd at least like this issue to stay open until we determine this much.

Thanks.

@github-actions
Copy link

github-actions bot commented Aug 6, 2021

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 bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
r: invalid Issue is closed as not valid
Projects
None yet
Development

No branches or pull requests

2 participants