Search code examples
androidandroid-studioandroid-ndkbuild.gradlendk-build

I cannot compile and android app in android studio by the ndk


I need to compile a project but i need solve any errors. My Android Grandle Plugin version is 3.1.1 and Grandle Version is 4.4

Build file '/home/javier/Descargas/VisitaOficialArriboOfflinev2/VisitaOficialArriboOffline/app/build.gradle' line: 79A problem occurred evaluating project ':app'.> Could not find method ndkversion() forarguments [21.3.6528147] on object of type com.android.build.gradle.AppExtension.

this is my build:gardle:app the line that have the error is ndkversion '21.3.6528147'

//apply plugin: 'com.android.feature' for instant app
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 27
buildToolsVersion '27.0.3'

defaultConfig {
    minSdkVersion 23
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    ndk{
        abiFilters "x86", "armeabi-v7a", "armeabi-v8a", "x86_64"
    }
    externalNativeBuild {
        cmake {
            cppFlags ""
        }
    }
}
buildTypes {
    release {
        //Remove  minifyEnabled true from release if you are getting error while creating final releasing api.
        minifyEnabled false
        debuggable false
        useProguard true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    debug {
        //Remove  minifyEnabled true from debug if you are getting error while compiling the app. As this time its running debug part.
        minifyEnabled false
        debuggable true
        useProguard true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }

}
externalNativeBuild {
    cmake {
        path file ('CMakeLists.txt')
    }
}
// Configure only for each module that uses Java 8
// language features (either in its source code or
// through dependencies).
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
splits {
//....
}
//The line with error
ndkversion '21.3.6528147'  }

The path route of my ndk is "ndk.dir=/home/javier/Android/Sdk/ndk" Thanks for your help


Solution

  • Edit the local.properties file, and add the following line to it, under sdk.dir - ndk.dir=/path/to/your/Android/Sdk/ndk/21.3.6528147

    and then delete or comment out the ndkVersion '21.3.6528147' line from the gradle file.

    That should solve the issue. If you now get the CMake was unable to find a build program corresponding to "Ninja" error, uninstall cmake 3.10 and install cmake 3.6 instead.

    Now everything should work fine, but just in case it still insists on the wrong cmake for some reason, you can also the following line to your local.properties file: cmake.dir=/path/to/your/Android/sdk/cmake/3.6.4111459