Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NDK is not installed

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.

like image 315
Nailuj29 Avatar asked Dec 30 '22 15:12

Nailuj29


2 Answers

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.

like image 106
Aditya Avatar answered Jan 02 '23 06:01

Aditya


  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 ! ! !

like image 32
vinchuli Avatar answered Jan 02 '23 04:01

vinchuli