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

前端 未结 11 2813
难免孤独
难免孤独 2020-12-24 01:25

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 runni

相关标签:
11条回答
  • 2020-12-24 01:43

    with android studio 3.0 + this issue is approached differently.

    Go to File > Settings > Android SDK > and select the SDK entry and update. It should fix the issue.

    the other approach to the same problem is when you do a gradle project sync it will automatically identify the issue of requiring version upgrade and provide you clickable link in the console. Through these steps it might also prompt you to update other dependencies, such as CMake.

    0 讨论(0)
  • 2020-12-24 01:45

    You can install these components using the SDK Manager:

    1. From an open project, select Tools > Android > SDK Manager from the main menu.
    2. Click the SDK Tools tab.
    3. Check the box next to NDK, CMake, and LLDB
    4. Click apply

    (Using Android Studio 3.6.1)

    Edit: Following above process on later versions of Android Studio still gives an NDK not installed error during the build process. This answer given by Violet Giraffe solved the issue. Once the necessary files are installed, go to File > Project Structure > SDK and select the NDK version.

    See this guide for more details.

    0 讨论(0)
  • 2020-12-24 01:47

    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
    }
    
    0 讨论(0)
  • 2020-12-24 01:48

    I ran into this error while trying to run SQLite Android Bindings. It still uses a very old gradle configuration (included below).

    TLDR

    Please take protossor's advice and use NDK (Side by side) and set an ndkVersion in your build.gradle. Only use this on very old projects.

    For old projects, you must install the obsolete NDK from the SDK manager. In Android Studio, open the SDK Manager and choose the SDK Tools tab. Uncheck Hide Obsolete Packages, and then scroll to the bottom to find NDK (Obsolete).

    More Details

    I ran ./gradlew assembleRelease per the instructions, and I got the following:

    FAILURE: Build failed with an exception.
    
    * What went wrong:
    A problem occurred configuring project ':sqlite3'.
    > NDK not configured.
      Download it with SDK manager.
    
    * 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 7s
    

    I got a similar error in Android Studio when it attempted to configure the project. After I installed the NDK (Obsolete) package, everything configured properly.

    SQLite's woefully out of date gradle configuration:

    $ROOT/build.gradle:

    buildscript {
        repositories {
            jcenter()
            google()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.1.4'
    
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    

    $ROOT/sqlitetest/build.gradle:

    android {
        compileSdkVersion 25
    
        defaultConfig {
            minSdkVersion 16
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
    ...
    }
    
    0 讨论(0)
  • 2020-12-24 01:53

    For Linux:
    Create file local.properties:

    ndk.dir=/home/username/Android/Sdk/ndk/21.3.6528147
    

    Now close the project and import it again.

    0 讨论(0)
提交回复
热议问题