Download

Android plugin that includes jni.h failing to build. How to build plugin for Android?

Hello,

I wrote a test Android plugin, using GameActivity.java and the logic contained in Runtime/Launch/Private/Android/AndroidJNI.cpp in order to communicate from Java to C++.

In my plugin I have this example code just to test the calls:


extern "C" void Java_com_epicgames_ue4_GameActivity_nativeMyPluginStarted(JNIEnv* jenv, jobject thiz, jboolean isStarted)
{
	if(isStarted)
		FPlatformMisc::LowLevelOutputDebugString(L"===> CUSTOM --- STARTED");
	else
		FPlatformMisc::LowLevelOutputDebugString(L"===> CUSTOM --- NOT STARTED");
}

In this cpp file I’m including the native Android headers:


#include <jni.h>
#include <android/log.h>

But when I try to build the plugin naturally I get the error:


Error	1	error C1083: Cannot open include file: 'jni.h': No such file or directory

How can I do that kind of external communication in my plugin? (Call a C++ function from the Java activity, just like the engine’s code does, but in the plugin code? If I manage to include jni.h it will work.

Any help would be appreciated, thanks.

EDITED:

  1. Managed to build the project targeted to Android directly into Visual Studio, but it doesn’t build the plugin.

Since it’s been 15 days that I posted this without success yet, anyone has an idea? :slight_smile:

Can you paste the contents of the *.cs files for your plugin? I’m not sure why all Android code wouldn’t be able to include <jni.h>

Also, what do you mean by “Managed to build the project targeted to Android directly into Visual Studio, but it doesn’t build the plugin.”?