NDK compilation error

  • Replies:0
  • OpenNot stickiedUnanswered
  • Forum posts: 2

May 11, 2017 3:48:59 PM via Website

I'm trying to compile a project with NDK in Android Studio. But I'm getting an error like:
Error: (198) Android NDK: Aborting... . Stop.*
and Error:Execution failed for task ':app:ndkBuild'.
Process 'command finished with non-zero exit value 2

apply plugin: 'com.android.application'

import org.apache.tools.ant.taskdefs.condition.Os

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "prisca.ctest"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags "-frtti -fexceptions"
abiFilters 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'mips', 'mips64'
}
}
}

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

// call regular ndk-build(.cmd) script from app directory
task ndkBuild(type: Exec) {
    Properties properties = new Properties()
    properties.load(project.rootProject.file('local.properties').newDataInputStream())
    def ndkDir = properties.getProperty('ndk.dir')
    if (Os.isFamily(Os.FAMILY_WINDOWS)) {
        commandLine "$ndkDir/ndk-build.cmd", '-C', file('src/main').absolutePath
    } else {
        commandLine 'ndk-build', '-C', file('src/main').absolutePath
    }
}

tasks.withType(JavaCompile) {
    compileTask -> compileTask.dependsOn ndkBuild
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
externalNativeBuild {
    cmake {
        path "CMakeLists.txt"
    }
}

}

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.2.0'
compile "com.android.support:support-v4:25.2.0"
compile "com.android.support:support-v13:25.2.0"
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
testCompile 'junit:junit:4.12'
compile project(':openCVLibrary320')

compile 'com.github.chrisbanes:PhotoView:1.3.1'

}