Search code examples
androidfluttergradlebuild.gradlegradle-plugin

Flutter Android: One or more plugins require a higher Android NDK version


One or more plugins require a higher Android NDK version.

Fix this issue by adding the following to /Users/qqq/data/github/qqq/qqq/android/app/build.gradle: android { ndkVersion 21.3.6528147 ... }

But if I add ndkVersion and my file looks like this:


android {
    compileSdk 31

    ndkVersion 21.3.6528147

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }
...

I receive different error:

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/qqq/data/qqq/qqq/qqq/android/app/build.gradle' line: 61

* What went wrong:
Could not compile build file '/Users/qqq/data/github/qqq/qqq/android/app/build.gradle'.
> startup failed:
  build file '/Users/qqq/data/github/qqq/qqq/android/app/build.gradle': 61: Unexpected input: '{' @ line 61, column 9.
     android {
             ^

  1 error

Solution

  • According to official doc(https://developer.android.com/ndk/downloads) latest ndk version is 25.0.8775105 just update to latest and error should be gone.

    Solution for 2022:

    android {
        ndkVersion "25.0.8775105" <-- add this line
    }
    

    Solution for March 2023:

    android {
        ndkVersion "25.2.9519653"
    }