Hello, fellow game creators.
I’m working on this VR project in which a mobile device is used as a controller.
Currently I’m testing JNI to call Java code on UE4.
Only to fail, though…
So I referred to these two links to figure out what I messed up.
But still, when I build and run it on the device, it crashes at the certain function.
I can’t seem to figure out what’s wrong.
I could really use some help.
Below is the code.
(don’t mind Korean letters)
→ GameActivity.java
generated custom function AndroidThunkJava_Toast(String msg)
→ AndroidJNI.h
declare variable to save Java method ID in order to call Java function
(static jmethodID AndroidThunkJava_Toast;)
→ AndroidJNI.cpp
Add Java method ID
→ declare function to AndroidJNI.cpp
→ AndroidJNI.cpp
Add AndroidThunkCpp_Toast to call cached Jave Method ID
→ AndroidJNI.cpp
add to JNI_OnLoad automatically called by UE4 library load
→ MyActor.h
declare function
(void Toast(FString msg))
→ MyActor.cpp
Call java function
If somebody knows something, please go ahead and leave a comment.
Stay awesome.