How to use android AAR or Jar library in Unreal Engine 4?

I’m new with unreal engine4 and I wanna use an android library in my unreal engine c++ project but I didn’t find any step by step documentation for that. I wanna call java functions with callbacks , form c++ or without callback (call c++ function from java). Is it possible?

Yes, you can call Java from C++ with JNI and also call back into C++ from Java. AndroidJNI.cpp shows a number of functions in called from C++. It also has some functions called from

Example: Java side declared as: public native void nativeVirtualKeyboardShown(int left, int top, int right, int bottom);
C++ function called: JNI_METHOD void Java_com_epicgames_ue4_GameActivity_nativeVirtualKeyboardShown(JNIEnv* jenv, jobject thiz, jint left, jint top, jint right, jint bottom)

You can use UnrealPluginLanguage to add AAR or JAR files. Take a look at GoogleVRHMD_APL.xml for an example.

Hi, I am new to UE4 and Java. I wonder that how can I use JNIEnv in my project. Visual Studio couldn’t recognize it, and won’t compile at all. What should I include?

You can get access to JNIEnv with

#include <jni.h>