Execution failed for task ': app: compileDebugNdk' when trying to compile an Android Studio project with NDK source code

No matter how many tutorials I followed, every time I try to create a project containing C gradle source files, an error is thrown:

Error:Execution failed for task ':app:compileDebugNdk'.

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command' C: \ Users \ svprdga \ Downloads \ android-ndk-r10d_x86 \ ndk-build.cmd '' completed with non-zero value of output 2

For example, I downloaded the following tutorial, which also throws the same error:

https://github.com/mpospelov/android-studio-ndk-hello-world

I saw the following questions, but I don’t understand exactly what I should do:

crash for task ': app: compileDebugNdk' failed to run this command ndk-build.cmd Unable to create project using android-ndk and Android Studio

Any help?

+4
source share
2 answers

Perhaps this answer will help: fooobar.com/questions/358330 / ... Msgstr "Try adding an empty .c file to your jni file (for example, empty.c)." It worked in my case - Android Studio 1.1.0 with android-ndk-r10d-windows-x86_64

+1
source

The version code of compileSdkVersion and buildToolsVersion must be consistent in the module build.gradle file. eg.

android { 
    compileSdkVersion 20 
    buildToolsVersion "20.0.0"
    ...
}
0
source

All Articles