0

I am unable to build a NDK project from the Android Studio environment but can build it manually using the command console.

I get the following error after building:

Error:Execution failed for task ':xxxxxx:compileReleaseNdk'.> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\xxxxx\AppData\Local\Android\SDK\android-sdk\ndk-bundle\ndk-build.cmd'' finished with non-zero exit value 2

I got a similar error while invoking ndk-build.cmd manually using the console from the jni directory where my NDK project is stored.However I fixed it by modifying the following in my Application.mk file as follows:

NDK_TOOLCHAIN_VERSION := 4.9

since 4.9 is the tool chain available on my install. I suspect from the Android Studio environment, the toolchain version is being picked incorrectly, and yet I do not know where to set this option in the GUI.

The build.gradle file has the following NDK block:

    ndk{
        moduleName "xxxxxx"
        ldLibs "log"
        cFlags "-std=c++11 -fexceptions"
        stl "gnustl_static"
        abiFilters "arm64-v8a armeabi armeabi-v7a mips mips64 x86 x86_64"
    }

Please advise me on how to go about solving this problem.

Jim
  • 1
  • 3
  • What was the actual error? No such file? Some compiler error? All we know is that the invocation of ndk-build failed, which isn't enough to go on. – Dan Albert Aug 12 '16 at 20:23
  • The only error message I get after the build is shown in bold above. This is why I don't know what to do next. Thanks. – Jim Aug 14 '16 at 12:15
  • Please have a look here: http://stackoverflow.com/questions/19477500/building-android-project-produces-make-error-2 – Vaiden Aug 14 '16 at 12:18
  • I went through the link you suggested Vaiden. It discusses about building the NDK project from the command line which works for me just fine. My issue is I cannot build the same project from within the Android Studio IDE. I read some where that Android Studio IDE does not use the 'Application.mk' file when building NDK projects. – Jim Aug 15 '16 at 06:22

1 Answers1

0

Just out of curiosity, I moved my project directory to the desktop and tried to build that project. The build was successful.

Finally narrowed down the problem to the NDK compiler not being able to create the following intermediate object file inside my project folder:

C:\Users\xxxxx\GitRepos\REVIEWS\xxx\SMART-xxx\xxxx-xxx-androidnative\xxxLibraries\xxxlibrary\build\intermediates\ndk\debug\obj/local/arm64-v8a/objs/natXXXX/C_\Users\xxxxx\GitRepos\REVIEWS\xxx\SMART-xxxx\xxxx-xxx-androidnative\xxxLibraries\xxxlibrary\src\main\jni\NativeXXXX.o.d

The reason was the well known windows path cannot exceed 255 characters issue. As you can see above the NDK-Build utility tries to append a deep folder hierarchy like "C_\Users\xxxxx\GitRepos\REVIEWS\xxx\SMART-xxxx\xxxx-xxx-androidnative\xxxLibraries\xxxlibrary\src\main\jni\" which exceeds MAX_PATH.

Jim
  • 1
  • 3