简体   繁体   English

如何设置 Unreal Engine / Visual Studio 以便能够使用 JNI 为 Android 进行编码?

[英]How do I setup Unreal Engine / Visual Studio to be able to code with JNI for Android?

In my project in Unreal Engine 4.25 want to use some native Android functionalities on the Oculus Quest by programming in C++ with JNI.在我的虚幻引擎 4.25 项目中,希望通过在 C++ 中使用 JNI 编程,在 Oculus Quest 上使用一些本机 Android 功能。 However, I have problems with Visual Studio 2019 recognizing JNI specific code.但是,我在 Visual Studio 2019 识别 JNI 特定代码时遇到问题。 I am able to launch an app to the Oculus Quest without adding JNI code, but when I want use #include “Android/AndroidJNI.h” Visual Studio complains it cannot find the source file.我可以在不添加 JNI 代码的情况下向 Oculus Quest 启动应用程序,但是当我想使用#include “Android/AndroidJNI.h”时,Visual Studio 抱怨它找不到源文件。

I have tried installing the Android Game Development Extension for Visual Studio and followed their tutorial on how to add Android as a target platform in the hopes this would fix the problem.我已经尝试为 Visual Studio 安装 Android 游戏开发扩展,并按照他们关于如何添加 Android 作为目标平台的教程,希望这可以解决问题。 However, this did not change anything.然而,这并没有改变什么。 Code that I put within an #if PLATFORM_ANDROID block is greyed out, implying that Visual Studio does not correctly recognize I am targeting Android.我放在#if PLATFORM_ANDROID块中的代码显示为灰色,这意味着 Visual Studio 无法正确识别我的目标是 Android。

Does anybody know how to properly set up Unreal Engine and Visual Studio, so it can work with JNI?有人知道如何正确设置虚幻引擎和 Visual Studio,以便它可以与 JNI 一起使用吗?

The header file is located at UE Engine code. header 文件位于 UE 引擎代码中。

Ex) Program Files (x86)/Epic Games/UE_4.27/Engine/Source/Runtime/Launch/Public/Android/AndroidJNI.h例如)程序文件(x86)/Epic Games/UE_4.27/Engine/Source/Runtime/Launch/Public/Android/AndroidJNI.h

And you can include AndroidJNI.h adding "Launch" module in XXX.Build.cs您可以在 XXX.Build.cs 中包含 AndroidJNI.h 添加“启动”模块

Ex) PrivateDependencyModuleNames.AddRange(new String[] { "...", "Launch", });例如)PrivateDependencyModuleNames.AddRange(new String[] { "...", "Launch", });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM