android-ndk - 找不到方法ndk()作为参数

标签 android-ndk

我正在关注Create Hello-JNI With Android Studio

MAC OX 10.11.5

Android Studio 2.2稳定

Java版本:1.7.0_79

gradle-2.14.1

这是我的app.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"
    defaultConfig {
        applicationId "com.chenql.helloandroidjni"
        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'
        }
    }
    ndk {
        moduleName "hello-android-jni"
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    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:23.3.0'
    compile 'com.android.support:design:23.3.0'
    testCompile 'junit:junit:4.12'
}

这是错误:
The Error Message
Error:(20, 0) Could not find method ndk() for arguments [build_13jh6qtzl4f08f8c1of3mvsys$_run_closure1$_closure5@5b127949] on project ':app' of type org.gradle.api.Project.

打开文件

最佳答案

原来,这段代码

ndk {
    moduleName "hello-android-jni"
    }
应该放在“defaultConfig”块下:
defaultConfig {
    applicationId "com.chenql.helloandroidjni"
    minSdkVersion 22
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    ndk {
        moduleName "hello-android-jni"
    }
}
而不是在“buildTypes”块之后。

关于android-ndk - 找不到方法ndk()作为参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40501986/

相关文章:

android - AssetManager 无法在 NDK 中运行

android - Android 上 USB 设备的 Linux 文件权限

android - FFMPEG 在 ubuntu 上为 android 构建

android - 使用 ndk clang 3.4/3.5 编译 __thread 不走运

android - 如何在 ADT 项目中使用 ffmpeg4android?

android - 如何用Android APP发送MAC广播数据帧

android - 如何修复 gradle 任务 ':app:mergeDebugJniLibFolders' in flutter gradle build for opencv native with NDK?

android - 如何将 WCHAR_T* 转换为 jstring?

android - ndk-构建错误.opencv2/core/core.hpp : No such file or directory

android - 将 native opencv 集成到 android studio 时 R.styleable 的问题