Search code examples
androidandroid-ndkndk-build

disabling android.mk auto-generated by AS still return ndk-build.cmd finished with non-zero exit value 2


similar question asked many times before, but i tried every solution i found still getting the same error.

problem ndk-build fails with non-zero exit value 2

Error:Execution failed for task ':app:ndkBuild'.
> Process 'command 'D:\softwares\ndk\android-ndk-r13\ndk-build.cmd'' finished with non-zero exit value 2

as i read on forums reason is AS ignore android.mk and auto generate it's own. to disable that sourceSets.main.jni.srcDirs = [] to android shoudl be added to gradle. still getting the same error.

i tried many examples nothing works for simplicity source code

AS 2.2

GRADLE 2.2

OS windows 10


Solution

  • Android Studio version 2.2.0 and above supports new native build mechanisms -- cmake and ndk-build, refer to documentation. Some samples could be found from github, ndkBuild samples are also there in directory other-builds/ndkbuild

    windows having 260 characters limitation for file path, you might met problem when building some of the samples under windows, in that case, you could copy the sources and the scripts into the same folder [and close to root directory]. Other OS would build as is.

    The version if native support you mentioned is deprecated, new ndkbuild and cmake replace it.