Hello,
I am a new developer, or I am trying to be and i need to Implement a Android App/function into my Unreal Engine Project. Right now I am using a C++ plus blueprints and after some research, I have found out the best way will be a Plugin for this. So i head to development about 3 weeks ago and still cant finish this plugin. See, i am using ChatGPT which i know is not always a good way to development something, but, when i tried the C++ dev for Android using JNI, i always getting a:
Cannot resolve symbol ‘JNIEnv’
Cannot resolve symbol ‘GetJavaEnv’
and so on…
I have set the SDK NDK, downloaded in options Target platform for Android, i also set JAVA_HOME, ANDOID_HOME NKD and so on for environment variables. So, can someone help me out?.
I am using a Rider for development.
The Code is:
// Copyright Epic Games, Inc. All Rights Reserved.
#include "HealthConnectPlugin.h"
#include "Android/AndroidApplication.h"
#include "Android/AndroidJNI.h"
#define LOCTEXT_NAMESPACE "FHealthConnectPluginModule"
void FHealthConnectPluginModule::StartupModule()
{
if (JNIEnv* Env = FAndroidApplication::GetJavaEnv())
{
// Use JNI functions here
}
}
void FHealthConnectPluginModule::ShutdownModule()
{
// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
// we call this function before unloading the module.
}
#undef LOCTEXT_NAMESPACE
IMPLEMENT_MODULE(FHealthConnectPluginModule, HealthConnectPlugin)
For Build Project is:
// Copyright Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
public class HealthConnectPlugin : ModuleRules
{
public HealthConnectPlugin(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
PublicIncludePaths.AddRange(
new string[] {
// ... add public include paths required here ...
}
);
PrivateIncludePaths.AddRange(
new string[] {
"HealthConnectPlugin/Private",
// Include path for JNI and Android-specific headers
"Runtime/Launch/Public",
"Runtime/Launch/Public/Android"
}
);
PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
// Add Android dependencies
"AndroidPermission",
"Launch"
}
);
PrivateDependencyModuleNames.AddRange(
new string[]
{
"CoreUObject",
"Engine",
"Slate",
"SlateCore",
// Add private dependencies that you statically link with here ...
}
);
DynamicallyLoadedModuleNames.AddRange(
new string[]
{
// ... add any modules that your module loads dynamically here ...
}
);
if (Target.Platform == UnrealTargetPlatform.Android)
{
PrivateDependencyModuleNames.Add("Launch");
// Add JNI libraries
PublicAdditionalLibraries.Add("log");
PublicAdditionalLibraries.Add("android");
// Ensure that the Android runtime is properly configured
PrivateIncludePaths.Add("Runtime/Launch/Public/Android");
}
}
}
The main feature of that android code is to use/access Healthconnect for reading data from smart wearables.