Kkk.
Kkk.

Reputation: 1

Java android Could not find a method ndk ()

I use a android studio And when I refresh all gradle project in console I have :

Error:(28, 0) Could not find method ndk() for arguments [build_drk092k49tm2cwy3k37ev72l6$_run_closure1$_closure7@6b46899] 
  on object of type com.android.build.gradle.AppExtension. 
<a href="openFile:C:\ app\build.gradle">Open File</a>

And in messages I see :

could not find method ndk() for arguments

This is my build.gradle

apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'


android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "xxx"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }

    ndk {
        moduleName "liblfrfid"
        abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
    }


    task nativeLibsToJar(type: Jar, description: 'create a jar archive of the native libs') {
        destinationDir file("$buildDir/native-libs")
        baseName 'native-libs'
        from fileTree(dir: 'libs', include: '**/*.so')
        into 'lib/'
    }

    tasks.withType(JavaCompile) {
        compileTask -> compileTask.dependsOn(nativeLibsToJar)
    }
}
repositories {
    maven { url "http://dl.bintray.com/bednarthe/maven" }
    mavenCentral()
}

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:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile fileTree(dir: "$buildDir/native-libs", include: 'native-libs.jar')
    compile files('libs/commons-io-2.4.jar')
    compile files('libs/core-2.2.jar')
    compile files('libs/jsr305-3.0.0.jar')
    compile files('libs/ksoap2-android-assembly-3.6.2-jar-with-dependencies.jar')
    compile files('libs/picasso-2.3.4.jar')
    compile('com.crashlytics.sdk.android:crashlytics:2.6.5@aar')

}

Upvotes: 1

Views: 3137

Answers (1)

Kishore Jethava
Kishore Jethava

Reputation: 6834

Add ndk inside defaultConfig

defaultConfig {
    applicationId "smok.pl.pairingcodes"
    minSdkVersion 15
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

 ndk {
    moduleName "liblfrfid"
    abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
 }
}

Edit

You can read more here in Specify ABIs point

Upvotes: 6

Related Questions