x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

创建C++类后include AndroidJNI.h失败

我尝试https://blog.csdn.net/RhyGame/article/details/79842943中的做法来学习UE4 JNI 但是我在build.cs中引入了Launch后,在我自己创建的C++类中无法include接下来的两个头文件 #include "Runtime/Launch/Public/Android/AndroidJNI.h" #include "Runtime/ApplicationCore/Public/Android/AndroidApplication.h" 项目无法通过编译且报错指向AndroidJNI中的第七行 我想知道该如何使用UE4中的JNIalt textalt textalt textalt text

Product Version: UE 4.20
Tags:
bulidcs.png (30.1 kB)
报错1指向.png (58.2 kB)
报错2指向.png (68.2 kB)
more ▼

asked Nov 28 '18 at 06:23 AM in Chinese

avatar image

crysyal
21 1 1 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hi crysyal,

  • 请检查你的test_JNL.h所在的目录,是public还是private,你可以直接把Launch模块放在PublicDependency List中。

  • AndroidApplication.h在新版本中已经改变了路径,请确定路径正确。

more ▼

answered Nov 28 '18 at 07:37 AM

avatar image crysyal Nov 28 '18 at 08:42 AM

对不起我刚刚开始接触UE4JNI,我尝试将Launch放在最外面的PublicDependency中,确认了AndroidApplication.h并没有更换,我的test_JNL.h并没有放置在任何文件夹中,是放置在source下的项目路径中的,但是出现的错误依旧和上面的相同 alt textalt textalt textalt text

avatar image crysyal Nov 28 '18 at 09:27 AM

我尝试按你说的进行了修改,这个关于宏的问题依旧存在

alt text

new-error.png (30.6 kB)
avatar image Feng.Li STAFF Nov 28 '18 at 10:24 AM

使用 #if PLATFORM_ANDROID #include "Android/AndroidApplication.h" #endif 应该就可以了,你用的是源码版还是登录器下载版的引擎?

avatar image Feng.Li STAFF Nov 28 '18 at 10:29 AM

另外如果你需要AndroidCamera的话,目前引擎提供了一个现成的插件,你可以在插件-》Media中 找到。

avatar image crysyal Nov 28 '18 at 10:51 AM

使用的是登录器下载版的引擎,我尝试了在我同事的环境下走同样的流程也没有成功,出现了同样的错误在映入AndroidJNI.h时找不到源文件,这只是我自己实现JNI的小尝试,但是到现在还没成功,始终卡在#include "Runtime/Launch/Public/Android/AndroidJNI.h" #include "Runtime/ApplicationCore/Public/Android/AndroidApplication.h"这里

avatar image Feng.Li STAFF Nov 29 '18 at 06:37 AM

你可以用#if PLATFORM_ANDROID宏處理下,我測試過可以。 如果是需要這個功能,虛幻已經提供了這個功能的插件,你可以直接使用。不需要自己來寫。 如果是學習目的,你可以查看Engine\Source\Programs\UnrealBuildTool\Platform\Android\UEBuildAndroid.cs文件,瞭解如何配置編譯安卓平臺。

avatar image crysyal Nov 28 '18 at 11:12 AM

我去确认了一下应该就是谷歌版的UE4在登录器下载的

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question