Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle sync failed, NDK not configured, download it with SDK manager

I am completely new to Android development and just installed Android Studio. I'm doing a very basic HelloGL2 exercise, and I opened up the HelloGL2.iml file. I tried running it, but it said that the gradle project sync failed and that the NDK is not configured. In the simplest terms (to a complete beginner in Android), how do I fix this?

like image 887
Karina H Avatar asked Dec 03 '16 02:12

Karina H


People also ask

How do I know if Android NDK is installed?

You'll need to point to your NDK in your eclipse by adding the path of ndk-build to Window > preferences > android > NDK. Right click on your project folder. Choose android tools -> add native support (the bottom one) and click finish. Now it will ask for a name for your .

Where is NDK installed?

Android Studio installs all versions of the NDK in the android-sdk /ndk/ directory. Each version is located in a subdirectory with the version number as its name.


1 Answers

disclaimer: I work on Android Studio

With newer version (3.6+) of Android Gradle Plugin, please download with "NDK (Side by side)" option from the SDK manager and then specify ndkVersion in the build.gradle with the full version of NDK that is locally available from your machine.

For example, after you downloaded NDK 20.1.5948944 under "NDK (Side by side)" from the SDK manager, the downloaded NDK would be, by default, under ~/Android/Sdk/ndk/20.1.5948944. Then in your module level build.gradle, you need something like the following.

android {     compileSdkVersion 29       defaultConfig {         // ...     }      buildTypes {         // ...     }      externalNativeBuild {         // ...     }      ndkVersion "20.1.5948944" // <<==== Here } 
like image 88
tgeng Avatar answered Sep 28 '22 21:09

tgeng