Skip to content

Issue: Not able to generate bindings for Gradle hosted library #551

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

Closed
yardexx opened this issue Oct 2, 2023 · 2 comments
Closed

Issue: Not able to generate bindings for Gradle hosted library #551

yardexx opened this issue Oct 2, 2023 · 2 comments

Comments

@yardexx
Copy link

yardexx commented Oct 2, 2023

Hello!

I am trying to implement jnigen to fork of Flutter plugin. Plugin is using Gradle dependency which has classes (library API) from which I want to generate bindings. However, I am unsuccessful and jnigen is throwing exception:
image

I am following your pdfbox example, as well as kotlin plugin example.

Steps to replicate

  1. Clone repository, branch experimental/ffi
  2. Run dart run jnigen --config jnigen.yaml in library root

Maybe it's something I'm doing wrong?

Thanks for help.

@yardexx
Copy link
Author

yardexx commented Oct 3, 2023

Issue resolved.

Found out that there is add_gradle_sources (undocumented) under android_sdk_config section. However, this solution seems to be not bulletproof since dependencies are retrieved from application build.gradle - I have to add Gradle dependency for Java library in build.gradle of example in order to be able to generate bindings.

It's bit odd - plugins add dependencies in build.gradle under android folder (on package level), however, jni doesn't seem to see them there.

@yardexx yardexx closed this as completed Oct 3, 2023
@HosseinYousefi
Copy link
Member

Yes, this is indeed an odd behavior. In general gradle support can be improved, it now uses the place where gradle caches the libraries after running some command likeflutter build apk. This command cannot be run for a project without a main function – that's why currently you need to use example and yes, it doesn't find the "nested" dependencies in the cache either, so you'd have to add the same gradle dependencies again in example.

You can see this here in package:cronet_http as well: https://github.com/dart-lang/http/blob/master/pkgs/cronet_http/example/android/app/build.gradle#L70-L72

Related open issues:

@HosseinYousefi HosseinYousefi transferred this issue from dart-archive/jnigen Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants