Weird Android Studio build problems under Windows

Over the past several months, I’ve been experiencing problems when building for an Android device using
Android Stuido under Windows: the compilation reports a file not found - bullet/BulletCollision/CollisionDispatch/btGhostObject.h - although it is present. I get this with a freshly created HelloWorld lua-based project. I’m not sure the problem is specific to lua-based projects, but it might be,

I’ve seen similar problems in the past, and thought it was to do with the Windows path-name length restriction, so I put cocos2d-x in the root of the drive and create my projects there to, but I still get that error.

I wonder if anyone else can confirm this or whether it is caused by something wrong in the set up of my PC.

I’m using Android Studio 3.2.1 with NDK 16b and cocos2d-x v3.17

Here’s the error:

Build command failed.
Error while executing process C:\Home\android-ndk-r16b\ndk-build.cmd with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=C:\WebViewLua2\WebViewLua\frameworks\runtime-src\proj.android\app\jni\Android.mk NDK_APPLICATION_MK=C:\WebViewLua2\WebViewLua\frameworks\runtime-src\proj.android\app\jni\Application.mk APP_ABI=armeabi-v7a NDK_ALL_ABIS=armeabi-v7a NDK_DEBUG=1 APP_PLATFORM=android-14 NDK_OUT=C:/WebViewLua2/WebViewLua/frameworks/runtime-src/proj.android/app/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=C:\WebViewLua2\WebViewLua\frameworks\runtime-src\proj.android\app\build\intermediates\ndkBuild\debug\lib NDK_TOOLCHAIN_VERSION=clang -j8 NDK_DEBUG=1 C:/WebViewLua2/WebViewLua/frameworks/runtime-src/proj.android/app/build/intermediates/ndkBuild/debug/obj/local/armeabi-v7a/libcocos2dlua.so}
[armeabi-v7a] Compile++ arm  : cocos2d_lua_static <= lua_cocos2dx_physics3d_manual.cpp
[armeabi-v7a] Compile++ arm  : cocos2d_lua_static <= lua_cocos2dx_physics3d_auto.cpp
[armeabi-v7a] Compile++ arm  : cocostudio_static <= CCProcessBase.cpp
[armeabi-v7a] Compile++ arm  : cocostudio_static <= CCTween.cpp
[armeabi-v7a] Compile++ arm  : cocostudio_static <= CCDatas.cpp
[armeabi-v7a] Compile++ arm  : cocostudio_static <= CCBatchNode.cpp
[armeabi-v7a] Compile++ arm  : cocostudio_static <= CCDecorativeDisplay.cpp
[armeabi-v7a] Compile++ arm  : cocostudio_static <= CCDisplayFactory.cpp
[armeabi-v7a] Compile++ arm  : cocostudio_static <= CCDisplayManager.cpp
In file included from C:/WebViewLua2/WebViewLua/frameworks/runtime-src/proj.android/app/jni/../../../../cocos2d-x/cocos/scripting/lua-bindings/proj.android/../auto/lua_cocos2dx_physics3d_auto.cpp:3:
C:/WebViewLua2/WebViewLua/frameworks/runtime-src/proj.android/app/jni/../../../../cocos2d-x/cocos/3d/..\physics3d/CCPhysics3D.h:57:10: fatal error: 'bullet/BulletCollision/CollisionDispatch/btGhostObject.h' file not found
#include "bullet/BulletCollision/CollisionDispatch/btGhostObject.h"
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[armeabi-v7a] Compile++ arm  : cocostudio_static <= CCSkin.cpp
[armeabi-v7a] Compile++ arm  : cocostudio_static <= CCColliderDetector.cpp
1 error generated.
make: *** [C:/WebViewLua2/WebViewLua/frameworks/runtime-src/proj.android/app/build/intermediates/ndkBuild/debug/obj/local/armeabi-v7a/objs-debug/cocos2d_lua_static/__/auto/lua_cocos2dx_physics3d_auto.o] Error 1
make: *** Waiting for unfinished jobs....
In file included from C:/WebViewLua2/WebViewLua/frameworks/runtime-src/proj.android/app/jni/../../../../cocos2d-x/cocos/scripting/lua-bindings/proj.android/../manual/physics3d/lua_cocos2dx_physics3d_manual.cpp:33:
C:/WebViewLua2/WebViewLua/frameworks/runtime-src/proj.android/app/jni/../../../../cocos2d-x/cocos/3d/..\physics3d/CCPhysics3D.h:57:10: fatal error: 'bullet/BulletCollision/CollisionDispatch/btGhostObject.h' file not found
#include "bullet/BulletCollision/CollisionDispatch/btGhostObject.h"
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [C:/WebViewLua2/WebViewLua/frameworks/runtime-src/proj.android/app/build/intermediates/ndkBuild/debug/obj/local/armeabi-v7a/objs-debug/cocos2d_lua_static/__/manual/physics3d/lua_cocos2dx_physics3d_manual.o] Error 1

This does look to be related to not accounting for restricted path names in Windows. I’ve found that I can build projects that have names as small as four letters long and placed in a four letter long directory in the root drive.