ERROR: Could not find method ndk() for arguments [build_kk89u9tsw8u75i89ts2nuhcf

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.1"
    defaultConfig {
        applicationId "com.wjc.ndkstools"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"


    }

    ndk {
        abiFilters 'armeabi', 'armeabi-v7a','x86'
    }

    externalNativeBuild {
        cmake {
            cppFlags ""
            //生成多个版本的so文件
            abiFilters 'arm64-v8a','armeabi-v7a','x86','x86_64'
        }
    }

    externalNativeBuild {
        cmake {
            path "src/main/java/CMakeLists.txt"  // 设置所要编写的c源码位置,以及编译后so文件的名字
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

修改为

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.1"
    defaultConfig {
        applicationId "com.wjc.ndkstools"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        ndk {
            abiFilters 'armeabi', 'armeabi-v7a','x86'
        }

        externalNativeBuild {
            cmake {
                cppFlags ""
                //生成多个版本的so文件
                abiFilters 'arm64-v8a','armeabi-v7a','x86','x86_64'
            }
        }
    }



    externalNativeBuild {
        cmake {
            path "src/main/java/CMakeLists.txt"  // 设置所要编写的c源码位置,以及编译后so文件的名字
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

你可能感兴趣的:(JNI_NDK)