3

i am following this tutorial online

https://youtu.be/kFtxo7rr2HQ

and when I tried to build I keep gettingt his:

Error:(15, 0) Gradle DSL method not found: 'ndk()' Possible causes:

  • The project 'NDKTest' may be using a version of Gradle that does not contain the method. Gradle settings
  • The build file may be missing a Gradle plugin. Apply Gradle plugin
  • I have tried this thread:

    Android Studio Gradle DSL method not found: 'android()' -- Error(17,0)

    but it is pretty old now.

    here's my build.gradle file

    apply plugin: 'com.android.application'
    android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    
    defaultConfig {
        applicationId "com.guitarv.www.ndktest"
        minSdkVersion 17
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    
    ndk {
    
                moduleName = "HelloJNI"
        }
    
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    }
    

    Android Studio 1.4.1 android-ndk-r10e

    Anyone knows what is going on?

    thx!

    Community
    • 1
    • 1
    gmmo
    • 2,577
    • 3
    • 30
    • 56

    1 Answers1

    7

    Move the ndk to the defaultConfig scope. Maybe, you'll want to add the sourceSets.main scope too

    apply plugin: 'com.android.application'
    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.2"
    
        defaultConfig {
            applicationId "com.guitarv.www.ndktest"
            minSdkVersion 17
            targetSdkVersion 23
            versionCode 1
            versionName "1.0"
            ndk {
                moduleName = "HelloJNI"
            }
            sourceSets.main {
                jni.srcDirs = []
                jniLibs.srcDir "src/main/libs"
            }
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    Bruno
    • 311
    • 4
    • 4