Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

NDK Resolution Outcome: Project settings: Gradle model version=5.4.1, NDK version is UNKNOWN error

Ask Question

NDK Resolution Outcome: Project settings: Gradle model version=5.4.1, NDK version is UNKNOWN

I changed the Gradle version in build-gradle back to 3.4.2 but it didn't help.

What version is your NDK? How was it installed? How are you using it in your project (specified in build.gradle, local.properties, or ANDROID_NDK_HOME )? What's in the source.properties file in the NDK? Dan Albert Aug 22, 2019 at 16:49 Where did you get this "error"? I get this message after Android Studio update in all of my projects in the Event Log but it has no impact. Everything builds and runs as it should. I never used NDK - so I don't care if it would not work. The incredible Jan Aug 28, 2019 at 6:11 i think ... the "NDK version" is not main problem.... i import project again... and the problem resolved Farhad Farzin Aug 28, 2019 at 16:05 It's possible none of the solutions work for you (they did not work for me). The issue is being tracked by google, you can star it there issuetracker.google.com/issues/140403764 Mike Hardy Sep 17, 2019 at 16:47 That did not solve it for me. I still have the error even with gradle 5.6.1 / plugin 3.5.0 / Android Studio 3.5.0 after importing the project again Mike Hardy Aug 28, 2019 at 19:58 For completeness (since I said it did not work for me) this actually does work for me - and is required even - to fix a separate silly sort of gradle + react-native native module compile issue. So as a "Android Studio / gradle" trick to have in your bag of tricks, it's a good one. Mike Hardy Sep 6, 2019 at 15:15 go to File>Project Structure>DownloadNDK which will download and add path to your local properties which might fix things up if this answer didn't work KingKongCoder Sep 16, 2019 at 19:35 I closed project, deleted all Build folders, .iml files, .idea folder. Then opened project and it built successfully Dmitriy Pavlukhin Nov 8, 2019 at 11:39 @KingKongCoder I found that link at File > Project Structure > SDK Location > Download Android NDK bitlather Jan 7, 2020 at 16:57 The question is about the error message and an answer shouldn't require installing it to get rid of the message. The NDK is an optional package Mike Hardy Aug 28, 2019 at 19:59 The answer is for anyone who uses NDK and faces this error and in the question is not mentioned that he uses NDK or not .@The Zahra Aug 29, 2019 at 7:30 NDK takes almost 1GB of your previous hard drive! And I'm not sure if there is some other impact (like memory, performance, CPU, etc.). Why do we need to download it if it is never used ? Can we just ignore the error ? Pablo Alfonso Nov 5, 2019 at 14:48

I was having the same issue after upgrading my android studio. You just need to open local.properties & change ndk.dir path to your NDK path.

Code:

ndk.dir=D\:\\Android\\SDK\\ndk-bundle
sdk.dir=D\:\\Android\\SDK
                This makes no sense if you do not have and do not want the NDK. It is an optional component
– Mike Hardy
                Aug 28, 2019 at 19:59
                local.properties says "This file is automatically generated by Android Studio. Do not modify this file -- YOUR CHANGES WILL BE ERASED!"
– leoneboaventura
                Feb 9, 2020 at 15:28

I don't use NDK in my project, but I had the same problem. The problem disappeared after I updated the SDK version to the newest compileSdkVersion 29

Interesting - I thought that had potential so I tried it, it still did not solve it for me. There is an open issue here issuetracker.google.com/issues/140403764 – Mike Hardy Sep 4, 2019 at 16:45 @MikeHardy currently I'm using Gradle plugin version 3.5.0 and gradle version 5.4.1. Try to change this versions, while bug will be fix. Hope it's help you. – Vlad Sep 5, 2019 at 9:01

I had a previous answer (since deleted by moderators) where I detailed that there are workarounds (as listed here) that work for some but that there is an underlying bug in gradle because the workarounds don't work for everyone (specifically: none of them work for me)

The related google issue is here: https://issuetracker.google.com/issues/140403764

Update: As of today (20190920) they indicate that they have fixed the underlying issue, so I would expect a future release of gradle after today (20190920) will contain the fix.

Update2: Today (20190926) I received a response from a googler that the problematic code was in Android Studio and it is contained on the 3.6-release branch but is not available on any publicly available build at the moment (Android Studio 3.6 Canary 12 was released just before this fix was made). That lets you know which component to update and which versions to pay attention to, anyway. Looks like Android Studio 3.6 Canary 13 and later should have it https://issuetracker.google.com/issues/140403764#comment13

Until then you can try the workarounds but when there's a vendor bug and workarounds don't work you just have to wait for a vendor patch.

I first got this issue after upgrading from Android Studio 3.5.0 to 3.5.1 today.

I simply did a rebuild from the top menu Build --> Rebuild Project.

This might not work for everyone depending on what caused the issue but it worked for mine. Give it a shot.

(Also, I do not use the NDK and never have downloaded it before. Still don't have it downloaded)

I am using AS 3.5.1, my project need NDK. Got the exact error, clean and rebuild fixed it. Easier enough to try it first before doing anything else. – Sean Oct 14, 2019 at 23:56 @Sean Nice, glad it worked! By the way, I think the rebuild also starts out with a clean. I realized that once when I had the lower build toolbar open and it had 'clean' as the first task. Ever since then I just started hitting the rebuild only. (Hopefully it's doing what I think it is lol). – Ryan Oct 15, 2019 at 0:44

After my recent Android Studio upgrade I had the same error message. I tried the other answers here and none worked. But @Zahra's answer pointed me to something that did work:

Go to File->Project Structure... Under "Android NDK Location", click the dropdown and select the "DEFAULT NDK Recommended" option.

There was a slightly different path in there before I selected the default. Somewhere upgrading using the SDK manager, the path seems to have changed.

And now in the local.properties file sdk.dir is set to the same directory as the "DEFAULT NDK Recommended" option.

After trying at least 5 different 'solutions' this one finally got me back on track, now to move on to whatever the next Android Studio bug happens to be... – norlesh Dec 10, 2019 at 15:53 go to 'file > project structre > SDK location ' and download the last NDK and go to project 'local.properties' and specific the NDK location like this 'ndk.dir=C\:\\Users\\Lenovo\\AppData\\Local\\Android\\Ndk' – Hocine Djouamaa Oct 5, 2019 at 13:30

I uninstalled CMake 3.10 by SDKManager. (installed CMake is 3.6 only)

Gradle sync and build succeeded.

android-gradle-plugin 3.1.2 used CMake 3.10.

In android-gradle-plugin 3.1.2 (or 3.1.+), feature of support for CMake 3.7 and higher is a preview feature.

(from output message of gradle assembleDebug or gradle sync.)

https://developer.android.com/studio/projects/add-native-code.html#use_a_custom_cmake_version

The SDK Manager includes the 3.6.0 forked version of CMake and version 3.10.2. Projects that don't set a specific CMake version in build.gradle are built with CMake 3.6.0.

Perhaps this behavior is android-gradle-plugin 3.3 or higher. (it is from android-studio 3.3 that can be downloaded CMake 3.10)

android-gradle-plugin 3.1.2 used latest version from installed CMake.

I had the same issue on a mac as well.

Suggestion: Force the .gradle folder to rebuild itself..

This still shows the 'NDK Version is UNKNOWN' in the Event Log yet it builds successfully and doesn't give me any issues. (I don't have NDK downloaded)

  • Open your /Users/macuser/ folder
  • Press CMD + SHIFT + . (dot/period) to view hidden folders
  • DELETE .gradle folder
  • Restart Android Studio
  • This will cause Android Studio to rebuild and re-download your .gradle folder fixing your conflicting files in the process.

    This worked for me but only on the first time. If I reopened the project without first deleting .gradle then I would get the same error as before. – Kyle Abens Nov 30, 2019 at 5:44 Yes, it seems the error will stay in the log. Mine has it as well on-going but project builds and runs just fine. – Fox Dec 2, 2019 at 22:20 The answer might be made more valuable by stating how you knew where to find the file in android studio or on the file system and your reasoning in determining that was the change to make. – Reenactor Rob Aug 24, 2019 at 22:51 ndk.dir is not set in my projects. I never used NDK. Nevertheless I get this "error" in Android Studio 3.5. – The incredible Jan Aug 28, 2019 at 6:14 Same as The Incredible Jan, this was not in my local.properties yet I still get this message. So it is not a complete solution but perhaps it could help some – Mike Hardy Aug 28, 2019 at 20:00

    I had the same error after adding a couple of libraries in the app-level build.gradle file.
    The solution was just to clean the project.
    In the menu bar choose: Build >> Clean Project
    After that, the error was gone for me. I didn't do anything else.

    I got this error (and several others) after importing a project from version control via Bitbucket hyperlink.

    Once imported, close the project and re-import it using File > New > Import Project. After that everything built correctly. (The NDK path was already specified properly, and only importing as new worked)

    Meta: Android Studio 3.5 Build #AI-191.8026.42.35.5791312, built on August 8, 2019 JRE: 1.8.0_202-release-1483-b49-5587405 x86_64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o macOS 10.13.6 Gradle 3.4.0

    I had the same problem after updating Android Studio. My problem is solved by after updating Android SDK Build-Tools. [Tools->SDK Manager->SDK Tools->Android SDK Build-Tools].

    Then try to Clean the project [Build->Clean Project].

    Finally restart the Android Studio IDE......

    I just closed project, closed android studio, restarted my PC, tracked my project and deleted the .Idea folder in "B:/PROJECTNAME/.idea" and voila.

    Problem solved. It resyncs. N/B: my gradle is androidx. goodluck to someone.

    Ok. I recently downloaded the latest version of Android studio and got similar error. So eventually I created a new project. Selected Kotlin Language then Jelly Bean (talking 'bout the options to pick from). Then the whole synching began but the 1st sync failed and eventually it auto-synced again and everything began to work. Did modify the default codes (text) since I'm a beginner but got no error messages. The preview was OK and I continued my learning. Sorry I couldn't explain it better. I'm just a beginner. Oh! You need to be connected to the Internet for it to work.

    If this problem occurred after an Android Studio upgrade and you initiated a plugin update from right bottom notification: Open File > Project structure, then change the Android Gradle version to your Android Studio version and downgrade the Gradle version to the previous one.

    In my case, I downgraded the Android Gradle plugin from 3.5.3 to 3.2.1 and the Gradle version from 5.4.1 to 4.6.

    I had this problem and none of the solutions worked for me. Problem is, this error or warning might appear for very broad reasons. You can follow these steps to find out what is wrong:

    NDK is missing

    When Gradle starts to compile native dependencies it creates ".cxx" folder in your "app" folder. inside that folder you can find "ndk_locator_record.json" file, which is very strange type of log file. It is basically all the paths Gradle checks to find NDK folder. If there is any error or mismatch on NDK version numbers you can see in this file.

    NDK build fails

    for some unknown reasons (maybe bug in Gradle) ndk build does not show actual error on event log window, instead it shows a failure, like Gradle sync failed: executing external native build for ndkBuild .... following by NDK Resolution Outcome: Project settings: Gradle model version=5.4.1, NDK version is UNKNOWN.

    In this case go back to .cxx > ndkBuild > debug > x86(x64 or any other cpu arch) Here in this folder you can find "json_generation_record.json" file, it is same type of log, usually last entry has the actual error. For example, for me was

     ../../sdk/native/jni/OpenCV.mk: No such file or directory
     make: *** No rule to make target '../../sdk/native/jni/OpenCV.mk'.  Stop.
    

    From here you have a starting point to find out what is going wrong under hood.

    If the NDK is not install, and the Android Project requires it then first install the NDK.

    On windows OS add the NDK path to PATH environment variable. This will fix the version issue.

    In my case the NDK path is C:\Users\\AppData\Local\Android\Sdk\ndk\21.0.6113669

    I faced this issue before and I fixed it by making sure to have the right permissions to the app directory.

    I am using macOS, so I did:

    chmod -R 777 your_android_project
    

    and the issue was gone.

    i have this problem too when I updated the Android Gradle Plugin Version from 3.1.2 to 3.5.1

    Here is how to solve this issue :

    Go to gradle.properties file in root folder of your project and add android.useDeprecatedNdk=true

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.