Could not find method ndk() for arguments [build_3k23ytju20kdwiqf5u0x5zphe$_run_closure1$_closure4@7

AndroidStudio中配置ndk时报错 :

Could not find method ndk() for arguments 
[build_3k23ytju20kdwiqf5u0x5zphe$_run_closure1$_closure4@76c34344] on object of type
 com.android.build.gradle.AppExtension.

解决方案:

把 ndk 放在 defaultConfig 里面

defaultConfig {
.....
ndk {
}
.....
}

例如:

   defaultConfig {
        applicationId "com.example.li_yx.jgdemo"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        ndk {
            //选择要添加的对应cpu类型的.so库。
            abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a'
            // 还可以添加 'x86', 'x86_64', 'mips', 'mips64'
        }

    }

你可能感兴趣的:(IDE)