【问题标题】:Java android Could not find a method ndk ()Java android 找不到方法ndk()
【发布时间】:2017-04-19 07:11:58
【问题描述】:

我使用 android studio 当我在控制台中刷新所有 gradle 项目时,我有:

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:\Users\ElteGps 022\Desktop\PairingCodes\app\build.gradle">Open File</a>

在我看到的消息中:

找不到参数的方法 ndk()

这是我的 build.gradle

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


android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "smok.pl.pairingcodes"
        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')

}

【问题讨论】:

    标签: java android android-ndk


    【解决方案1】:

    defaultConfig内添加ndk

    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"
     }
    }
    

    编辑

    您可以在Specify ABIs点阅读更多here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-11
      • 2014-05-30
      • 2021-11-26
      • 1970-01-01
      • 2017-03-22
      相关资源
      最近更新 更多