UBT ERROR: Failed to produce item, Unrealtype.h

I have a problem with Android packaging, The packaging works fine without plugin, but the plugin makes lots of errors ( I was able to package it before I reinstalled Windows).
Using VS2015, CodeWorks1R7 (tried with 1R6-same problem, Windows SDK 8.1)
All the errors are about UNREALTYPE.H
Example of error:

In file included from Runtime/CoreUObject/Public/UObject/ScriptMacros.h:12:
Runtime/CoreUObject/Public\UObject/UnrealType.h(3277,37): error: lambda capture ‘LocalMapLayoutForCapture’ is not used [-Werror,-Wunused-lambda-capture]
[LocalKeyPropForCapture, KeyPtr, LocalMapLayoutForCapture](void NewElementKey)
Runtime/CoreUObject/Public\UObject/UnrealType.h(3290,41): error: lambda capture ‘LocalMapLayoutForCapture’ is not used [-Werror,-Wunused-lambda-capture]

[LocalValuePropForCapture, ValuePtr, LocalMapLayoutForCapture](void
NewElementValue)
Runtime/CoreUObject/Public\UObject/UnrealType.h(3786,47): error: lambda capture ‘LocalSetLayoutForCapture’ is not used [-Werror,-Wunused-lambda-capture]
[LocalElementPropForCapture, ElementToAdd, LocalSetLayoutForCapture](void* NewElement)**

full log attached

link text

Hi.

From the log you attached, i see that you are using NDK19. Am i mistaken? Please post a screenshot. Go to Editor, and there Edit->ProjectSettings->AndroidSDK. Make a screenshot please.

Yes, 19 were used.
I ended up reinstalling Windows and the whole thing with it. Works as expected now :slight_smile:
Do you know what the problem was, so I can avoid it in the future?

Reinstalled Windows WTF!!!

Aww those Epic d0r#s, what they make people to do. Ok. First of all Unreal build tool doesn’t swallow NDK19 for several reasons, one of which being for example that Unreal uses PhysX3.4 of Nvidia as external library, and thus is pinned down to their Android configurations, which are NDK15 tops. If you managed to compile your thing with NDK19 u r awesome, and please post here the manual how.

Now, the reason for the error you posted is this:

In the very basic, lowest level include files of Unreal Engine there are several lambda expressions that capture more variables in the capture list, then used in actual expression body. This will compile and work. It’s like, say, you are preparing for hiking trip, and took your favorite origami along. Not a big deal if you r careful.

Now, Android NDK compiles with rather uptight configuration. And this is veeery legit, since Android is meant to run on rather weak hardware. Look at IOS certification tests and compare if you like. It is configured on purpose to throw warning on gratuitous lambda captures. That’s your hiking buddy legitimately warning you, that taking origami into a hiking trip might just be not the best idea for origami lifetime. Again, it’s up to you. Legit? Yes.

Now, UBT (UnrealBuildTool) gives the compiler few more flags, one of which being f@#1ng -WarningsAsErrors ! It’s hypothetical you deciding, that if your hiking buddy will have literally ANY complain or constructive critics about your gear, you will SHOOT YOURSELF IN THE HEAD! Rather harsh, isn’t it?

The solution will be next:
Add next lines to the topmost header of your include hierarchy

#pragma warning (push)
#pragma warning (disable:4668) // 'symbol' is not defined as a preprocessor macro, replacing with '0' for 'directives'. This is for Unreal to stop complaining, when u r not building 4 Android.
#if defined( __clang__ ) && ( __clang_major__ < 6 )
// clang-5 gives a spurious warning about not using the captured `ohandle`. Unreal uses NDK15, which falls into this category.
#pragma clang diagnostic warning "-Wunused-lambda-capture" // Downgrade -Wunused-lambda-capture to warinig.
#pragma clang diagnostic ignored "-Wunused-lambda-capture" // Ignore it.
#endif
#pragma warning (pop)

Hopefully it’ll solve. If u r getting the error still, complaining about YourProjectName.generated.cpp
then u r screwed. Post here, and i will post a workaround, which is ugly, bad, but unfortunately the only way i found to pacify UHT(UnrealHeaderTool).

ALTERNATIVELY

If u r not developing plugin, or can use Unreal locally, just go to UnrealType.h and fix the d@mn problem by commenting out the unused variables in the capture list. This will be right and gracious thing to do.

Thank you, I am definitely trying this next time I get same error in order to reinstall everything (: