Why is Android Studio trying to concatenate filenames during the build process?

Issue

I’m trying to build this project: https://github.com/sureshjoshi/android-ndk-swig-example

It’s a small example project that uses SWIG to wrap a C++ library for use on Android. I’m getting this error when it builds:

C:\Users\elarson\Desktop\Downloads\android-ndk-swig-example-master\NDKExample\app\src\main\jni\SeePlusPlus_wrap.cxx:802:1: fatal error: opening dependency file C:\Users\elarson\Desktop\Downloads\android-ndk-swig-example-master\NDKExample\app\build\intermediates\ndk\debug\obj/local/arm64-v8a/objs/SeePlusPlus/C_\Users\elarson\Desktop\Downloads\android-ndk-swig-example-master\NDKExample\app\src\main\jni\SeePlusPlus_wrap.o.d: No such file or directory

Breaking that up, I see that it’s trying to open this file:

C:\Users\elarson\Desktop\Downloads\android-ndk-swig-example-master\NDKExample\app\build\intermediates\ndk\debug\obj/local/arm64-v8a/objs/SeePlusPlus/C_\Users\elarson\Desktop\Downloads\android-ndk-swig-example-master\NDKExample\app\src\main\jni\SeePlusPlus_wrap.o.d

Breaking that down further, I see that this filepath contains the absolute path to the project twice, but with the colon replaced with an underscore:

C:\Users\elarson\Desktop\Downloads\android-ndk-swig-example-master\NDKExample\app\build\intermediates\ndk\debug\obj/local/arm64-v8a/objs/SeePlusPlus/

C_\Users\elarson\Desktop\Downloads\android-ndk-swig-example-master\NDKExample\app\src\main\jni\SeePlusPlus_wrap.o.d

I’m wondering what might cause this. I have the NDK in a path with no spaces, as that’s been known to cause problems. You can see my project has no spaces in its path, either.

The actual line executed during the build that’s failing is this, broken up for clarity:

C:\Dev\Android\android-ndk-r10d\ndk-build.cmd

NDK_PROJECT_PATHnull

APP_BUILD_SCRIPTC:\Users\elarson\Desktop\Downloads\android-ndk-swig-example-master\NDKExample\app\build\intermediates\ndk\debug\Android.mk

APP_PLATFORMandroid-21

NDK_OUTC:\Users\elarson\Desktop\Downloads\android-ndk-swig-example-master\NDKExample\app\build\intermediates\ndk\debug\obj

NDK_LIBS_OUTC:\Users\elarson\Desktop\Downloads\android-ndk-swig-example-master\NDKExample\app\build\intermediates\ndk\debug\lib

APP_STLgnustl_shared

APP_ABIall

Solution

This seems to have to do with filepath length. Also had it not work in D:\production\Pong\Devel2010\Src\UnityGames\BhvrDemo\BHVRSWIGTest\

I moved my project folder from

C:\Users\elarson\Desktop\Downloads\android-ndk-swig-example-master

to

D:\Almo\Work\android-ndk-swig-example-master

And now it works, but perhaps only because the filenames are shorter:

D:\Almo\BinkSWIGTest2\NDKExample\app\build\intermediates\ndk\debug\obj\local\arm64-v8a\objs\SeePlusPlus\D_\Almo\BinkSWIGTest2\NDKExample\app\src\main\jni\SeePlusPlus_wrap.o.d

is still created.

Answered By – Almo

Leave a Comment