Projects cannot be built using Android NDK and Android studio

I have an Android project with ffmpeg and other external libraries. I downloaded the latest version of NDK (ndk-r10) and ran Android studio 0.8.0. I am also running Windows 8 64 bit with the latest version of cygwin

There is no problem with my project construction. I add ndk.dir to local.properties. When I try to run, I receive this error message:

The System cannot find the path specified

Error:Execution Failed for task ':app:compileDebugNdk'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\John1\AppData\Local\Android\android-ndk-r10\ndk-build.cmd

NDK_PROJECT_PATH=null      
APP_BUILD_SCRIPT=C:\Users\John1\AndroidstudioProjects\android-project\app\build\intermediates\ndk\debug\Android.mk 
APP_PLATFORM=android-18 
NDK_OUT=C:\Users\John1\AndroidstudioProjects\android-project\app\build\intermediates\ndk\debug\obj 
NDK_LIBS_OUT=C:\Users\John1\AndroidstudioProjects\android-project\app\build\intermediates\ndk\debug\lib 
APP_ABI=all

Error Code:
    1
Output:
    The system cannot find the path specified.

Seek advice. Thank you

resolvent:

Using Android studio, NDK support is preliminary, and your *. MK files will be ignored. You can disable the default NDK integration to make Android studio / gradle reuse them, let it call NDK build (. CMD) by itself, and use the standard LIBS / location to integrate. So files:

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

apply plugin: 'android'

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.3"

    defaultConfig{
        minSdkVersion 15
        targetSdkVersion 19
        versionCode 101
        versionName "1.0.1"
    }

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

If you need more information, please refer to my blog post: http://ph0b.com/android-studio-gradle-and-ndk-integration/

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>