Search code examples
androidgradleandroid-ndkandroid-gradle-pluginjava-native-interface

Using 'model.android.ndk' command in build.gradle


I'm using gradle 4.4 and I can't the 'ndk' command is not found. This is my build.gradle of the application:

 apply plugin: 'com.android.application'
apply plugin: 'cpp'


android {
    System.setProperty('SYS', 'android')
    compileSdkVersion 23
    buildToolsVersion "27.0.3"

    defaultConfig {
        applicationId "xxx"
        minSdkVersion 23
        targetSdkVersion 23
        versionCode 1
        versionName "1"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }


}
model {
    android.ndk {
        moduleName "native-lib"
      }
}

I don't know what the problem is but i get the error:

The following model rules could not be applied due to unbound inputs and/or subjects:

android.ndk { ... } @ app\build.gradle line 27, column 5 subject: - android.ndk Object [*]

[*] - indicates that a model item could not be found for the path or type.

which refers to the line of the 'ndk' command.

Thanks!


Solution

  • Google essentially discontinued the experimental NDK plugin. Please follow their official guide to migrate to the stable plugin: Migrate to Stable Gradle for NDK Support using CMake and ndk-build.

    If you have problems with this tutorial, and you need more guidance, please don't hesitate to ask here.