1

I am trying to build android project with imported c-libraries and get next error. Error:Execution failed for task ':app:compileDebugNdk'.

com.android.ide.common.internal.LoggedErrorException: Failed to run command: /Applications/Android Studio.app/ndk/ndk-build NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/Users/eugene/KREF14001/app/build/ndk/debug/Android.mk APP_PLATFORM=android-19 NDK_OUT=/Users/eugene/KREF14001/app/build/ndk/debug/obj NDK_LIBS_OUT=/Users/eugene/KREF14001/app/build/ndk/debug/lib APP_ABI=all Error Code: 2 Output: usage: dirname path /Users/eugene/build/core/init.mk:471: * Android NDK: Aborting . Stop.

What does it mean? How can i fix this problem?

3
  • Are you sure you installed the NDK and not just the SDK? Commented Jun 17, 2014 at 12:46
  • Yes, I downloaded it, unzip and add it next line to local.properties ndk.dir=/Applications/Android Studio.app/ndk Commented Jun 17, 2014 at 13:33
  • please post your Build.gradle Commented Jun 17, 2014 at 14:41

2 Answers 2

4

I've read that the NDK_HOME shouldn't contain any space in its path (even if it's \ escaped).

Sign up to request clarification or add additional context in comments.

Comments

2

This is the code i use to build using android-ndk from gradle. For this add ndk directory path in gradle.properties ie . add ndkdir=/home/user/android-ndk-r9d and put all jni files in a folder native in src/main/ as you can see from code posted below. It will create jar with native libs which you can use normally as in System.loadLibrary("library");

dependencies {
    compile fileTree(dir: "$buildDir/native-libs", include: '*.jar')
}

task ndkBuild(type: Exec) {
    commandLine "$ndkdir/ndk-build", "--directory", "$projectDir/src/main/native", '-j', Runtime.runtime.availableProcessors(),
            "APP_PLATFORM=android-8",
            "APP_BUILD_SCRIPT=$projectDir/src/main/native/Android.mk",
            "NDK_OUT=$buildDir/native/obj",
            "NDK_APP_DST_DIR=$buildDir/native/libs/\$(TARGET_ARCH_ABI)"
}

task nativeLibsToJar(type: Zip, description: 'create a jar with native libs') {
    destinationDir file("$buildDir/native-libs")
    baseName 'native-libs'
    extension 'jar'
    from fileTree(dir: "$buildDir/native/libs", include: '**/*.so')
    into 'lib/'
}

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

nativeLibsToJar.dependsOn 'ndkBuild'

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.