12

When building a flutter app, I get an error stating

FAILURE: Build failed with an exception.                                
                                                                        
* What went wrong:                                                      
Execution failed for task ':app:extractReleaseNativeDebugMetadata'.     
> NDK is not installed                                                  
                                                                        
* Try:                                                                  
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
                                                                        
* Get more help at https://help.gradle.org                              
                                                                        
BUILD FAILED in 822ms                              

However, the android NDK is installed.

Nailuj29
  • 750
  • 1
  • 10
  • 28
  • 1
    Have you had any luck with answer from this [post](https://stackoverflow.com/questions/29122903/ndk-is-not-configured-issue-in-android-studio) ? – javdromero Mar 12 '21 at 17:06
  • Yes; can you write a answer so I can accept it @javdromero? – Nailuj29 Mar 12 '21 at 17:38
  • It's ok, if an answer from that post worked for you, upvote that one so I don't duplicate an answer just for this post. – javdromero Mar 12 '21 at 17:49

7 Answers7

20

I had the same issue. I wanted to extract the debug symbols for better debugging in the production environment.

Solution

Step 1: Installing NDK and CMAKE SDK tool from android studios (You can skip it, if already installed)

Open any project in Android studio. (Doesn't matter which project. We just want to access SDK manager)

  1. With a project open, click Tools > SDK Manager.

  2. Click the SDK Tools tab.

  3. Select the NDK (Side by side) and CMake checkboxes.

Image of SDK Manager

enter image description here

  1. Click OK.

  2. A dialog box tells you how much space the NDK package consumes on disk.

  3. Click OK.

  4. When the installation is complete, click Finish.

Step 2

1. Check which version of NDK is installed in your system.

To check, find the NDK folder inside the Android SDK folder. For mac users, it is located at - ~/Library/Android/sdk/ndk/

You will find a folder with the NDK version name inside this directory. For example - in my case, the installed NDK version was 23.0.7599858. So, I was able to find this directory at this location ~/Library/Android/sdk/ndk/23.0.7599858/

Note: For Ubuntu or windows users sdk/ndk directory's location will be different.

2. Ensure you have the same NDK version mentioned in the android/build.gradle file.
buildscript {
    ext {
        ...
        ndkVersion = "23.0.7599858"  # the installed version of ndk.
    }
    ...
}

EDIT:

Make sure you have ndkVersion initialized in the app/build.gradle like this:

android {
    ...
    ndkVersion rootProject.ext.ndkVersion
    ...
}

Or you can also directly write the version here like this:

android {
    ...
    ndkVersion "23.0.7599858"
    ...
}

You don't have to add the ndkVersion in android/build.gradle if you do this.

Aditya
  • 699
  • 6
  • 9
  • 2
    @Nailuj29 this seems to be the right answer. Please accept this. – Sahil Sep 10 '21 at 09:02
  • Specifying the ndkVersion as above didn't work for me. This worked: https://stackoverflow.com/a/59275504/60620 – dan-gph Sep 20 '21 at 17:22
  • On Ubuntu my ndk was located here: `~/Android/Sdk/ndk` . You can also check the "Show Package Details" checkbox in the `Tools > SDK Manager` to see the installed version of ndk. – dan-gph Sep 20 '21 at 17:26
8
  1. Using android studio open a. Go to settings, System settings, android sdk,on the tabs select SDK Tools confirm if NDK (side by side) and CMake Tool are installed b. If not installed check them and press apply to download and install them.SDK TOOLS confir, NDK and CMake

  2. After successfull confirmation. Open your project android folder find local.properties file, android/local.properties. You will find Something like thislocal.properties file

Add your NDK path as followsadding ndk path

To find yoour NDK path

  1. Go to home files if linux, android folder, sdk folder, inside find ndk folder, ie /Android/Sdk/ndk/24.0.8215888

Happy Coding ! ! !

vinchuli
  • 409
  • 5
  • 6
1

I got that error on React Native 0.64 app on AppCenter build for Android. The solution is to go to android/app/build.gradle file and comment ndk { debugSymbolLevel 'FULL' } line if you have so (defaultConfig { ndk { debugSymbolLevel } })

The solution was found by my colleague Jose, so all credits to him)

  • im using flutter, but my solution was very similar, so I'll accept this – Nailuj29 May 26 '21 at 19:25
  • 6
    Although this solves the error, I don't think its a very good solution to the problem. Having debug symbols is important. How about providing informatino about how to install the missing NDK? – JCutting8 May 27 '21 at 12:44
  • 2
    This is not a solution – Tony Sep 08 '21 at 06:53
1

After I added

ndk {
    debugSymbolLevel 'FULL'
}

in app build.gradle file I got this error about NDK not installed.

I resolved the same problem by making this change in main build.gradle file

    dependencies {
        classpath 'com.android.tools.build:gradle:7.1.3'
...
    }

This Gradle upgrade forced me to upgrade the url in gradle/wrapper/gradle-wrapper.properties file

distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip

I have Android Studio Bumblebee 2021.1.1 Patch 3

Boris
  • 363
  • 3
  • 12
  • This is the one that did the job for me. It is much better than adding a specific ndk version to build.gradle, which could be really annoying when working in a team. – Rob Lyndon Aug 23 '22 at 09:22
1

I also faced this problem and fixed it. As of 27 March 2023, with the latest Android Studio on Windows 10, follow these steps:

  1. You have to install "NDK (Side by side)" option from the SDK manager.

  2. Specify ndkVersion in the build.gradle with the full version of NDK that is locally available from your machine. The path is usually

C:\Users<username>\AppData\Local\Android\Sdk\ndk\25.2.9519653

  1. Please note that you may still see this error if the project you are working on has the wrong ndkVersion hardcoded. Please correct it, it my case it was

- ndkVersion '22.0.7026061'
+ ndkVersion '25.2.9519653'

Note: You may try to do this from File->Project Structure but I would recommend against it. For instance for me even with a successful NDK build with my steps I was getting the Android NDK location blank and the download option downloads an obsolete version of the NDK which does not help.

enter image description here

You may also try to fix this issue by doing step 1) and then choosing the NDK version from File->Project Structure->Modules but this just tries to automate step 2) but you still have to follow step 3).

enter image description here

References:

  1. https://stackoverflow.com/a/66527752
  2. https://stackoverflow.com/a/59275504
zeitgeist
  • 852
  • 12
  • 19
0

I have only installed ndk from the android studio and My problem just got solved, After including ...

local.properties

ndk.dir=<ANDROID_SDK>\\ndk\\XX.X.XXXXXXX

android/app/build.gradle

android {
    // ...

    ndkVersion "XX.X.XXXXXXX"
    // ...

    buildTypes{
        release{
            signingConfig signingConfigs.release
            ndk {
            debugSymbolLevel 'SYMBOL_TABLE'
             }
        }
    }
}

This could help someone and save his/her time.

Spsnamta
  • 479
  • 6
  • 11
0

If you are using Flutter Please use this approach(according to your ndk version from checkin android studio), it solved my problem and I used it for debug symbols native crashes

android { ... ndkVersion "23.0.7599858" ... }

utkudenis
  • 119
  • 6