0

I just cloned my code from repository and I got this error after adding ndk path and run the project. Have seen many related solutions but nothing worked.

:sdk:buildNdk FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task :sdk:buildNdk.

    Process 'command '/home/suneel/Android/Android/adt-bundle-linux-x86_64-20140702/ndk/ndk-build'' finished with non-zero exit value 2

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Here is my build.gradle file

android { compileSdkVersion 22 buildToolsVersion "23.0.2"

defaultConfig {
    testApplicationId "androidTest.com.xyz"
    testInstrumentationRunner "android.test.InstrumentationTestRunner"
    minSdkVersion 14
    targetSdkVersion 21
    versionCode 1
    versionName "1.0" 
}

sourceSets {
    main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src']
        resources.srcDirs = ['src']
        res.srcDirs = ['res']
        assets.srcDirs = ['assets']
        jni.srcDirs = []
        jniLibs.srcDir 'libs'
    }
    androidTest {
        java.srcDirs = ['src/androidTest']
    }
 }

 lintOptions {
    abortOnError false
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}

testOptions.unitTests.all {
    testLogging {
        events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
        outputs.upToDateWhen { false }
        showStandardStreams = true
    }
}

}

Thanks in advance.

Ahmad Aghazadeh
  • 16,571
  • 12
  • 101
  • 98
  • Can you double-check to make sure there isn't a previous error in the output? You'll need to scroll back through the ndk-build output to see if anything failed. Often an error like that is printed after a more descriptive error message that occurred during a specific phase of ndk-build. – Francesca Nannizzi Feb 22 '16 at 18:52

1 Answers1

0

Set multiDexEnabled true in defaultConfig in build.gradle file

 defaultConfig 
 {   
 testApplicationId "androidTest.com.xyz"
 testInstrumentationRunner "android.test.InstrumentationTestRunner"
 minSdkVersion 14
 targetSdkVersion 21
 versionCode 1
 versionName "1.0" 
 multiDexEnabled true
 }

Add

 sourceSets.main {
    jniLibs.srcDir 'src/main/libs'
    jni.srcDirs = [] //disable automatic ndk-build call
}

// 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
}

More details Refer Here

Community
  • 1
  • 1
sasikumar
  • 12,540
  • 3
  • 28
  • 48