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

fix(android): setup JNI support for non-rust Android apps #32

Merged
merged 1 commit into from
Jun 4, 2024

Conversation

berendsliedrecht
Copy link
Member

@berendsliedrecht berendsliedrecht commented Jun 4, 2024

Short ramble time.

When testing the library within React Native I noticed that the JAVA_VM was not set, this is due to the fact the example app in this repository uses android_activity which sets this variable inside another library... This took some time to find :)

After I found that out, I had to set the JAVA_VM pointer myself, I have tried JNI_OnLoad and ANativeActivity_onCreate and both were not triggered (even though this library and AriesAskar had the public symbol in their library...).

Currently this is the best solution I could come up with. It does mean that the user, for Android, needs to create a java file, as described in the README, which is a bit annoying. Would like to revisit this in the future, but for now it unblocks progress for the ARF and Askar at least.

Copy link
Member

@TimoGlastra TimoGlastra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this setup something we can handle in the React Native wrapper for Askar?

Copy link
Member

@Tommylans Tommylans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small thingy for the rest it LGTM

src/android.rs Outdated
let p = jni_call_method!(env, &self.0, KEY_PAIR_GET_PUBLIC, l, UnableToGetPublicKey)?;
let key = unsafe { self.get_object() };

let p = jni_call_method!(env, &key, KEY_PAIR_GET_PUBLIC, l, UnableToGetPublicKey)?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really self explanatory

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean?

@berendsliedrecht
Copy link
Member Author

Is this setup something we can handle in the React Native wrapper for Askar?

Yes, thank god!!!!

@berendsliedrecht berendsliedrecht force-pushed the jni-support-for-non-rust-android-apps branch from 55a293d to b6693c5 Compare June 4, 2024 10:47
@berendsliedrecht berendsliedrecht merged commit 7bd92a8 into main Jun 4, 2024
8 checks passed
@berendsliedrecht berendsliedrecht deleted the jni-support-for-non-rust-android-apps branch June 4, 2024 10:58
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

Successfully merging this pull request may close these issues.

3 participants