Android Studio Failed Build Ndk Project Non-zero Exit Value
Solution 1:
This is known problem of Android Studio, caused by very limited support of NDK-enabled projects. Answering to your question: yes, Android Studio now run ndk-build on its own, but it ignore existing Android.mk and generate one on the fly (and do it wrong for any non-trivial NDK-enabled project). Practically, the best way to fix this is to disable Android Studio's limited NDK support and call ndk-build from gradle script. Here I've described it more detailed and how to get it fixed.
Solution 2:
For simple, you can try to insert sourceSets.main.jni.srcDirs = []
to android
block in build.gradle file. This will tell gradle to look for your C++ files in different path.
Solution 3:
To see what is the exact problem do these:
1- Make sure you have set ndk path correctly, for example in my project I put ndk.dir=/usr/local/opt/android-ndk-r13b
in local.properties
file
2- Go to app directory of your android app
3- Run this command: <ndk_build_path> -C <jni_path> NDK_OUT=<jniLibDir> all NDK_DEBUG=1
example :
/usr/local/opt/android-ndk-r13b/ndk-build -C /MYAPP/app/src/main/jni -j 4 NDK_OUT=../jniLibs all NDK_DEBUG=1
then you can see what's going wrong.
Solution 4:
Encountered same error while importing a project from windows to mac, I tried all the above solutions, did not work. Finally noticed that there were "multiple target patterns" which was causing this error.
Solution : Delete the "obj" folder within your NDK and rebuild.
Done !!
Solution 5:
You can disable compileDebugNdk, but still have the jni folder visible in Android Studio. In your build.gradle, add the following clause:
tasks.all { task ->if (task.name.startsWith('compile') && task.name.endsWith('Ndk')) {
task.enabled = false
}
}
Post a Comment for "Android Studio Failed Build Ndk Project Non-zero Exit Value"