32

I am getting the above error

My gradle looks like this

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"

    defaultConfig {
        applicationId "com.example.hypersignwalletcorekotlin"
        minSdkVersion 23
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

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

}
project.ext {
    walletcore_version = "2.0.5"
}
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation "com.trustwallet:wallet-core:$walletcore_version"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

Not able to understand why is this happening.

Thanks

Vikram Anand Bhushan
  • 4,836
  • 15
  • 68
  • 130

8 Answers8

25

The Fix: add ndkVersion to your module's build.gradle

    android.ndkVersion  "your-installed-ndk-version"

as in some examples. You could find your NDK version from the file $NDK/source.properties.

Background Info: You probably using AGP/Android Studio version 3.6+: "From Android Gradle Plugin ( AGP ) 3.6+, there is a known good NDK concept added, which is the known good/tested NDK version when that AGP version was released". AGP will use that internal NDK version if:

  • you are not using the ndkVersion feature added in AGP 3.5

That internal NDKs are expected to be installed as side-by-side NDK place: $SDK\ndk
if not installed:

  • AGP 3.6, AGP 4.0 will error out
  • AGP 4.1 would auto install it.

The internally embedded NDK version, most likely, will be out-of-date pretty quickly as newer NDKs are constantly being released: if you want to use a newer NDK version, you do need to configure gradle with ndkVersion.

Additional Doc: Refer to the official documentation for details.

Gerry
  • 1,223
  • 9
  • 17
7

To install a specific version of the NDK, do the following:

With a project open, click Tools > SDK Manager.

Click the SDK Tools tab.

Select the Show Package Details checkbox.

Select the NDK (Side by side) checkbox and the checkboxes below it that correspond to the NDK versions you want to install. Android Studio installs all versions of the NDK in the android-sdk/ndk/ directory.

5zellsb
  • 181
  • 2
  • 7
5

I do not use NDK, but still got this error. Clean project worked for me.

Build -> "Clean Project" and then rebuild.

Otziii
  • 2,304
  • 1
  • 25
  • 34
3

That error happened to me when I run cordova build with Android Studio open. :D

I closed it and that's it.

1antares1
  • 1,146
  • 2
  • 11
  • 19
2

You need to click the tool on above the bar option. Then you need to download the current ndk if not installed.

Prateek Gupta
  • 2,422
  • 2
  • 16
  • 30
1

I just create a new emulator using the newest Android Studio version. It solved my problem. Hopefully, it may be an alternative...

Rudi Wijaya
  • 872
  • 1
  • 10
  • 25
0

Install NDK from SDK Manager -> SDK tools and then just add this line in the android/app/build.gradle

android{ 
   ndkVersion flutter.ndkVersion
 }
Amitabh Sarkar
  • 1,281
  • 1
  • 13
  • 26
-1

You can install only the NDK that you need.

Go SDK Manager -> SDK tools -> Click in Show Package Details

Click and install.

Şafak Gezer
  • 3,928
  • 3
  • 47
  • 49