[Solved] Compile Android Error fatal error opening dependency file No such file or directory

I’m trying to build and compile to Android platform. The build was success. But there was an error when I compiled saying that fatal error opening dependency file No such file or directory.

here is the native.log

Building mode: debug
Using Android Studio project : D:\Game_Development\CocosCreatorProjects\LearnReadWriteLocalStorage\build\jsb-default\frameworks\runtime-src\proj.android-studio
Building native...
NDK build mode: debug
running: '"D:\Android\android-ndk-r15c\ndk-build" -C D:\Game_Development\CocosCreatorProjects\LearnReadWriteLocalStorage\build\jsb-default\frameworks\runtime-src\proj.android-studio\app -j4 NDK_MODULE_PATH=D:\Game_Development\CocosCreatorProjects\LearnReadWriteLocalStorage\build\jsb-default\frameworks\cocos2d-x;D:\Game_Development\CocosCreatorProjects\LearnReadWriteLocalStorage\build\jsb-default\frameworks\cocos2d-x\cocos;D:\Game_Development\CocosCreatorProjects\LearnReadWriteLocalStorage\build\jsb-default\frameworks\cocos2d-x\external NDK_TOOLCHAIN_VERSION=4.9 NDK_DEBUG=1'

Android NDK: Found platform level in ./project.properties. Setting APP_PLATFORM to android-15.    
Android NDK: WARNING: APP_PLATFORM android-15 is higher than android:minSdkVersion 1 in ./AndroidManifest.xml. NDK binaries will *not* be comptible with devices older than android-15. See https://android.googlesource.com/platform/ndk/+/master/docs/user/common_problems.md for more information.    
make: Entering directory `D:/Game_Development/CocosCreatorProjects/LearnReadWriteLocalStorage/build/jsb-default/frameworks/runtime-src/proj.android-studio/app'
[armeabi-v7a] Gdbserver      : [arm-linux-androideabi-4.9] libs/armeabi-v7a/gdbserver
[armeabi-v7a] Gdbsetup       : libs/armeabi-v7a/gdb.setup
[armeabi-v7a] Compile++ arm  : cocos2dx_internal_static <= b2ChainAndCircleContact.cpp
[armeabi-v7a] Compile++ arm  : cocos2dx_internal_static <= b2ChainAndPolygonContact.cpp
[armeabi-v7a] Compile++ arm  : cocos2dx_internal_static <= b2EdgeAndPolygonContact.cpp
[armeabi-v7a] Compile++ arm  : cocos2dx_internal_static <= b2PolygonAndCircleContact.cpp
D:/Game_Development/CocosCreatorProjects/LearnReadWriteLocalStorage/build/jsb-default/frameworks/cocos2d-x/cocos/../external/sources/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.cpp:49:1: fatal error: opening dependency file ./obj/local/armeabi-v7a/objs-debug/cocos2dx_internal_static/__/external/sources/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.o.d: No such file or directory
 }
 ^
compilation terminated.
make: *** [obj/local/armeabi-v7a/objs-debug/cocos2dx_internal_static/__/external/sources/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.o] Error 1
make: *** Waiting for unfinished jobs....
D:/Game_Development/CocosCreatorProjects/LearnReadWriteLocalStorage/build/jsb-default/frameworks/cocos2d-x/cocos/../external/sources/Box2D/Dynamics/Contacts/b2ChainAndCircleContact.cpp:53:1: fatal error: opening dependency file ./obj/local/armeabi-v7a/objs-debug/cocos2dx_internal_static/__/external/sources/Box2D/Dynamics/Contacts/b2ChainAndCircleContact.o.d: No such file or directory
 }
 ^
compilation terminated.
make: *** [obj/local/armeabi-v7a/objs-debug/cocos2dx_internal_static/__/external/sources/Box2D/Dynamics/Contacts/b2ChainAndCircleContact.o] Error 1
D:/Game_Development/CocosCreatorProjects/LearnReadWriteLocalStorage/build/jsb-default/frameworks/cocos2d-x/cocos/../external/sources/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.cpp:49:1: fatal error: opening dependency file ./obj/local/armeabi-v7a/objs-debug/cocos2dx_internal_static/__/external/sources/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.o.d: No such file or directory
 }
 ^
compilation terminated.
make: *** [obj/local/armeabi-v7a/objs-debug/cocos2dx_internal_static/__/external/sources/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.o] Error 1
D:/Game_Development/CocosCreatorProjects/LearnReadWriteLocalStorage/build/jsb-default/frameworks/cocos2d-x/cocos/../external/sources/Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.cpp:53:1: fatal error: opening dependency file ./obj/local/armeabi-v7a/objs-debug/cocos2dx_internal_static/__/external/sources/Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.o.d: No such file or directory
 }
 ^
compilation terminated.
make: *** [obj/local/armeabi-v7a/objs-debug/cocos2dx_internal_static/__/external/sources/Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.o] Error 1
make: Leaving directory `D:/Game_Development/CocosCreatorProjects/LearnReadWriteLocalStorage/build/jsb-default/frameworks/runtime-src/proj.android-studio/app'
Error running command, return code: 2.

This is my environment

  • Cocos Creator 1.5.2
  • Android ndk r15c
  • Python 2.7.6
  • Ant 1.9.7

other

  • Window 7
  • Android studio 2.3.3
  • Target android api 15 (selected on Build dialog)
  • I’ve installed android sdk 15

I posted this question so that someone may encounter this similar error in the future.

The reason why you got this error is because your cocos creator project folder is too deep and/or your parent folder and your project folder name is too long.
as you can see in the native.log my cocos creator project is at

D:\Game_Development\CocosCreatorProjects\LearnReadWriteLocalStorage

Try moving it up. Maybe somethings like this

D:\CocosCreatorProjects\MyProject

If it’s still not work. Try

D:\MyProject

Because the whole path is too long so it can’t compile those error files into the target path in my case are

b2ChainAndCircleContact.cpp
b2ChainAndPolygonContact.cpp
b2EdgeAndPolygonContact.cpp
b2PolygonAndCircleContact.cpp

In your case the files that error maybe different.

7 Likes

there goes my hero

1 Like

This should be part of documentation for android studio users

good solution thank you

Solved! I think it’s weird though