Execution Failed For Task ':app:compiledebugndk' Failed To Run This Command Ndk-build.cmd
Solution 1:
Error:Execution failed for task ':app:compileDebugNdk'.
means that the gradle android plugin is trying to call ndk-build itself to compile your sources. You should get more details than the error code in your log window.
Anyway, currently it does this using an auto-generated Makefile and ignores yours, which can't work since you need to integrate ffmpeg.
To overcome this, you should disable the plugin's automatic ndk integration and make it use the standard libs location to get your .so files:
sourceSets.main {
jniLibs.srcDir 'src/main/libs'
jni.srcDirs = [] //disable automatic ndk-build call
}
from there you can call ndk-build yourself, or make gradle call it for you:
import org.apache.tools.ant.taskdefs.condition.Os// call regular ndk-build(.cmd) script from app directory
task ndkBuild(type: Exec) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine 'ndk-build.cmd', '-C', file('src/main').absolutePath
} else {
commandLine 'ndk-build', '-C', file('src/main').absolutePath
}
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
For more information on why all this, you can check this gist and my blog post.
Solution 2:
To help anyone who searched this, but can't figure out where the above statement goes... It is placed in the build.gradle which is under the {project_name}/app folder.
Specifically:
{YourApp} / app / build.gradle
And not the build.gradle at the root of the project.
Place it inside the "defaultConfig" section.
defaultConfig {
....
sourceSets.main {
jniLibs.srcDir 'src/main/libs'
jni.srcDirs = [] //disable automatic ndk-build call
}
Hopefully, this small advice will prevent someone from spending an excessive amount of time trying to figure out which and where this change needs to be made.
Solution 3:
below module:app code work perfectly ..so you can refer this...==>
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.mnthn.liking"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
jni.srcDirs = ['src/main/jniLibs/']
jni.srcDirs = []
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile project(':openCVLibrary331')
}
Solution 4:
I went through this problem today (3 years after posting question) and noticed that if @ph0b and @SpacemanScott answers don't work it may be due to lack of 2.x.x support in newest phones. Try to install latest OpenCV then.
Post a Comment for "Execution Failed For Task ':app:compiledebugndk' Failed To Run This Command Ndk-build.cmd"