Compiling Android - fatal error : 'wchar.h' file not found

Hi,

We’ve been developing exclusively with blueprints up until this week, but have decided to port some of our logic to native. We also need to implement an engine fix for Android save games not working correctly, so decided to grab the full engine source code and build it ourselves.

Everything’s gone fine and we managed to compile the engine, created some C++ files for our project and build/run the game on PC. But we’ve not been able to get Android to work at all.

Initially we were trying to run the game on an Android phone via the editor (like we’d been doing when it was blueprints only) but that failed to deploy (can’t remember what the error was now, sorry). I tried publishing an apk too, but that didn’t work either. After some investigation, I came to the conclusion that this was because the code for our game project wasn’t compiled for Android, and so it couldn’t deploy

If I’ve got this right, after making changes to our own project’s native code, we need to select the Android development configuration and build it? Then we should be able to deploy to an Android device in the editor as usual? Every time I’ve tried to do that I’ve run across the following compile errors:

1>------ Build started: Project: UE4, Configuration: Development_Game Tegra-Android ------
1>  Compiling Native code with NDK API 'Android 19'
1>  Performing 195 actions (4 in parallel)
1>  [1/195] clang++.exe EnginePrivate.h [armv7-es2]
1>  [2/195] clang++.exe RendererPrivate.h [armv7-es2]
1>  [3/195] clang++.exe CorePrivatePCH.h [armv7-es2]
1>  [4/195] clang++.exe Module.Paper2D.cpp [armv7-es2]
1>  In file included from E:/Subversion/Unreal/Engine/Intermediate/Build/Android/UE4/Development/Renderer/RendererPrivate.h:4:
1>  In file included from E:\Subversion\Unreal\Engine\Source\Runtime\Renderer\Private\RendererPrivate.h:10:
1>  In file included from Runtime/Engine/Public\Engine.h:9:
1>  In file included from Runtime/Core/Public\Core.h:16:
1>E:\Subversion\Unreal\Engine\Source\Runtime\Core\Public\HAL\PlatformIncludes.h(6,9): fatal error : 'wchar.h' file not found
1>  #include <wchar.h>
1>           ^
1>  In file included from E:/Subversion/Unreal/Engine/Intermediate/Build/Android/UE4/Development/Engine/EnginePrivate.h:4:
1>  In file included from E:\Subversion\Unreal\Engine\Source\Runtime\Engine\Private\EnginePrivate.h:8:
1>  In file included from Runtime/CoreUObject/Public\CoreUObject.h:7:
1>  In file included from Runtime/Core/Public\Core.h:16:
1>E:\Subversion\Unreal\Engine\Source\Runtime\Core\Public\HAL\PlatformIncludes.h(6,9): fatal error : 'wchar.h' file not found
1>  #include <wchar.h>
1>           ^

(And so on…)

I tried building Development Android both for the UE4 project and our own, but I always get those errors. I tried a ton of suggestions online to fix it, but nothing helped. In the end, I figured I must have a broken configuration and wiped everything out (Android SDK, Visual Studio, the Unreal build) and started again from scratch, doing the following:

  1. Installed Program Files\Epic Games\4.8\Engine\Extras\Android\tadp-2.0r8-windows.exe, using all of the default settings and making sure everything installed properly.
  2. Installed a cleanly downloaded version of Visual Studio 2013 Community edition and installed it with default options. Everything seems fine from there.
  3. Forked Unreal 4.8.1 from git hub and downloaded it as a .zip (last time I used git directly and decided to try it a different way this time). Extracted it to a folder, ran Setup.bat and then ran GenerateProjectFiles.bat. Again, no problems.
  4. Switched to Development Editor Win64 and rebuilt the whole thing. Compiled without issues and the editor runs successfully.
  5. Switched to Development Android and tried to build UE4. Exactly the same error.

At this point I’ve run out of things to try. I’ve either got the wrong end of the stick about deploying to Android, or there’s a problem that I can’t seem to find a solution for.

Thanks for any assistance you can provide,

  • Phil

Hi Triblade,

Everything looks square, can you try packaging a Learn tab project such as Tappy Chicken for development and ETC1 and attach the build output logs to this thread as a txt file?

Thanks!

I was running into this problem with my android tablet, I installed tadp-3.0r4 and everything started working. You might want to check it out and see if it helps you.

As requested, downloaded Tappy Chicken (it played without issues in our built version of the editor) and packaged it for Android (ETC1). It failed right at the end (same as our own project). Output log attached.link text

Hi Triblade,

Can you delete the intermediate folders in your Engine version and the projects and try packaging again?

Thanks!

Thanks for the suggestion, Thumper. I uninstalled my current tadp, installed 3.0r4 and tried again. Same issues (wchar.h not found when compiling and tappy chicken won’t package).

Deleted all three intermediate (Unreal/Our Game/Tappy Chicken) folders, opened the editor and loaded the tappy chicken sample again. Packaged ETC1. No improvement. Log attached in case it’s useful* link text

*Note I forgot to clear the log the first time, so I cleared it and re-packaged it. It was pretty fast (~10-20 seconds) both times.

Looking over that thread you provided there is only one thing that springs to mind that I might have missed. I’ll ask about that and if it’s not the problem, I’ll list all of the steps I went through from GenerateProjectFiles.bat through to trying to build Android and you can see if I’ve missed anything :slight_smile:

So the question: I believe (I’m not 100% sure at this point any more) that I’ve built ‘UE4 Development Editor Win64’, then jumped straight to trying to build ‘UE4 Development Android’. Will ‘UE4 Development Android’ fail to compile if I don’t build ‘UE4 Development Win64’ fully first?

This is certainly a puzzlement, because it looks like it’s all going right. You’re definitely compiling the solution for UE4Game/Development/Tegra-Android like in this thread, right?

Have you tried packaging in binary from the launcher? If so are you seeing anything funky on that end?

I can double check on this, but my instincts say yes, because you’re setting up the engine initially, and then the second compile for Android is then adding those libraries that aren’t included in the initial engine compile.

I’m doing a bit reshuffle/clean-up after the day’s shenanigans, then I’m going to kick off a new build of ‘UE4 Development Editor Win64’. I’ll follow it up with a full build of ‘UE4 Development Win64’, then try building ‘UE4 Development Android’ again and see if everything finally works. Going to take a long time though on my machine, so I’ll let you know the results tomorrow.

Thanks for the help today though.

Ok, still no luck I’m afraid. Steps are as follows (after setting up UE4 directory for the first time, and already having VS and tadp-2.0r8-windows.exe installed):

  1. Run setup.bat
  2. Run GenerateProjectFiles.bat.
  3. Open UE4.sln from the root of the install folder.
  4. Once VS has loaded, switch to Development Editor, Win64. Right-click on Engine → UE4 in the UE4 solution and choose rebuild.
  5. Wait ages for that to finish. End of build reports success, no errors.
  6. Switch configuration to Development, leaving it on Win64. Right-click on the Engine → UE4 again in the UE4 solution and choose rebuild.
  7. Wait ages for that to finish too. End of build reports success, no errors.
  8. Leave configuration on Development, switch to Android. Rightclick on Engine → UE4 again and choose rebuild. Same old error (wchar.h not found)
  9. Just in case the code error is a red herring, I switched back to Development editor, Win64 and ran the editor from visual studio. Once the editor opened, I browsed to the Tappy Chicken project, opened it and tried to package it (ETC1) again. Still fails.

Back in visual studio I rebuilt Development Android. Just to confirm I’m not going crazy, here’s what the environment looks like for me:

Upon finished, 1 project failed to compile. Tried Tappy Chicken again. Yup, you guessed it - still not working.

Also, I don’t clue what “Have you tried packaging in binary from the launcher? If so are you seeing anything funky on that end?” means from your suggestion earlier…

Guessing the project launcher? If so, I don’t really use it, but I went in there, switched to Android_ETC1 and hit launch (don’t have a clue about the ‘packaging in binary’ part though).

As you might imagine, this was the result:

Well, I finally fixed it! I simply backed up, wiped my hard drive and re-installed windows from scratch!

Weirdly enough though, I did a windows re-install only 6 weeks ago, so I have no idea how something like this would happen so soon after a clean windows install.

Anyway, thanks for the suggestions. I can now finally move on with my life :slight_smile:

hoo buddy, I am glad to hear it. This issue was making me nuts cause everything appeared to be correct.

Let us know if you run across any other problems. Thanks!

Yeah, I’ve never been so disheartened to hear the words “You’ve done everything correctly!” before. Thanks again for taking the time to look into this :slight_smile:

bumped into this today. fixed by setting Project Settings->Platforms->Android SDK->NDK API Level to “latest”

UnrealBuildTool: NDK version: 21,
GccVersion: 4.9

where previously GccVersion was 4.8

YMMV.

same problem by me found the fastest and simplest solution. in your epic games launcher right click on the preferd engine → options → uncheck android-> confirm. This will delete it. Then the same again and check android for installing it again. like a charm! no worries anymore!

last but not least! same problem by me found the fastest and simplest solution. in your epic games launcher right click on the preferd engine → options → uncheck android-> confirm. This will delete it. Then the same again and check android for installing it again. like a charm! no worries anymore!