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

AttachCurrentThread JNIEnv** instead of void**? #4

Open
amos-yau opened this issue Jul 2, 2022 · 2 comments
Open

AttachCurrentThread JNIEnv** instead of void**? #4

amos-yau opened this issue Jul 2, 2022 · 2 comments

Comments

@amos-yau
Copy link

amos-yau commented Jul 2, 2022

thanks for providing this auto binding way, to save writing JNI bridge effort (and I'm not familiar with c++).

But I hit this error when compiling:
ktbind.hpp:453:54: error: cannot initialize a parameter of type 'JNIEnv **' (aka '_JNIEnv **') with an rvalue of type 'void **'

I'm writing an Android app, NDK version 21.4.7075529, see if any more detail need to be provided?

@amos-yau
Copy link
Author

amos-yau commented Jul 2, 2022

image

@hunyadi
Copy link
Contributor

hunyadi commented Dec 27, 2022

Android appears to have a different signature for the member function AttachCurrentThread; while standard JNI has type void** as the first function parameter, Android has JNIEnv**, thus the type mismatch. Simply removing the reinterpret_cast should make the compiler succeed:

if (_vm->AttachCurrentThread(&_env, nullptr) == JNI_OK) {

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