在ndk-build android中找不到add-application.mk文件

时间:2017-11-03 13:10:09

标签: android android-ndk android-gradle

我正在使用此https://github.com/quiet/org.quietmodem.Quiet链接传输声音。这是一个库,所以在项目和buld.gradle中添加它,我已经将项目编译为:  compile project(':quiet')

我的build.gradle代码(Module:quiet)是

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

apply plugin: 'com.android.library'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"


    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }


        debug {
            debuggable = true
            jniDebuggable = true
        }
    }

    sourceSets { main {
        jniLibs.srcDir 'src/main/libs'
        jni.srcDirs = []
    } }
    externalNativeBuild{
        ndkBuild{
            path "$projectDir/src/main/jni/Android.mk"
        }
    }

}

    dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    androidTestCompile 'com.android.support:support-annotations:23.0.0'
    androidTestCompile 'com.android.support.test:rules:0.5'
    androidTestCompile 'com.android.support.test:runner:0.5'
    compile 'com.android.support:appcompat-v7:23.1.1'
}

def getNdkDir() {
    if (System.env.ANDROID_NDK_ROOT != null)
        return System.env.ANDROID_NDK_ROOT

    Properties properties = new Properties()
    properties.load(project.rootProject.file('local.properties').newDataInputStream())
    def ndkdir = properties.getProperty('ndk.dir', null)
    if (ndkdir == null)
        throw new GradleException("NDK location not found. Define location with ndk.dir in the local.properties file or with an ANDROID_NDK_ROOT environment variable.")

    return ndkdir
}

    def getNdkBuildCmd() {
    def ndkbuild = getNdkDir() + "/ndk-build"
    if (Os.isFamily(Os.FAMILY_WINDOWS))
        ndkbuild += ".cmd"

    return ndkbuild
}

    task ndkBuild(type:Exec, description: "Compile JNI Sources") {
    workingDir file('src/main')
    commandLine getNdkBuildCmd()
}

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

    task ndkLibsToJar(type: Zip, dependsOn: 'ndkBuild', description: 'Create a JAR of the native libs') {
    destinationDir new File(buildDir, 'libs')
    baseName 'ndk-libs'
    extension 'jar'
    from(new File(buildDir, 'libs')) { include '**/*.so' }
    into 'lib/'
}

现在,当我构建我的项目时,它会抛出图像中显示的ndk问题

我面临的问题显示在图片

image

0 个答案:

没有答案