After updating Android Studio and Gradle to 3.5,
I now get this error:
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.
I had similar problem and solved it by opening project using Import project (Gradle, Eclipse, etc.) instead of Open existing Android Studio project.
You can download NDK from File>Project Structur>Choosing SDK location from left panel and pressing Download from NDK location part.
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
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
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.
You need to install NDK using the SDK manager
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)
If you are not using NDK, ignore the error.
I have installed NDK to see if this makes any difference. There is no difference (except for an unused NDK folder of more than 2 GB :). So I removed it (i.e. delete the ndk folder and remove NDK environnent variable you have set previously).
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.
i fix it by going to file > Invalidate Caches\Restart
the IDE will restart and the problem will fix
I had same problem. My environment is:
Android Studio 3.5.1
Gradle 4.4
Android-Gradle-Plugin 3.1.2
CMake 3.10 and 3.6
I uninstalled CMake 3.10 by SDKManager. (installed CMake is 3.6 only)
Gradle sync and build succeeded.
(1)
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.)
(2)
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.
The problem is solved when I updated the Android Gradle Plugin Version from 3.1.4 to 3.4.0 and the Gradle Version from 4.4 to 5.1.1 at the same time. Of course, I downloaded the newest NDK(Side by Side) with SDK manager.
In my case, Android Studio was installed on a new mac. Just needed to download Android 9 (my target/compile SDK was 28) and build tools. The problem was solved after this.
In my case i fix it by upgrade to SdkVersion 29 and migrate to AndroidX.
After upgrading I've got the very same problem in one of my projects.
I solved it just deleting the line ndk.dir=D:\Android\SDK\ndk-bundle from the local.properties file.
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
Problem solved for me after checking Suggestions in Project structure and updated the two suggested updates. Sorry I can't remember the module names as they disappeared as soon as I pressed update for each of them and graddle sync. started automatically and after this problem disappeared
downgrading ndk version from 20 to r17c and cmake version from 3.10 to 3.6.411459 solved the problem for me
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.
Change the claaspath to 'com.android.tools.build:gradle:3.5.2' in build.gradle script
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 modified the gradle version of the gradle-wrapper.properties file from 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
I'm using IntelliJ IDEA 2017.3 and having trouble with a basic project in Grails in it - when Gradle starts syncing the project after starting up the IDE, all the checkmarks are green and labeled as "OK", my Messages tab is empty but still I get an alert on top of the editing pane reading "Gradle project sync failed. Basic functionality (e.g. editting, debugging) will not work properly".
I've tried removing the .gradle folder, the Restart and Invalidate option, giving IntelliJ a local path to Gradle as opposed to just telling it to use the default - all to no avail. I'm behind a corporate proxy but it is set up in IntelliJ so it shouldn't be blocking anything (especially since all the syncing seems to be working just fine).
What could be the problem? Versions of my stack:
Grails Version: 3.3.8
Groovy Version: 2.4.15
JVM Version: 1.8.0_181
Gradle Version: 3.5
I've tried ensuring that proxy's not the problem according to #dkb suggestion but it does not seem to be malfunctioning - I did Invalidate and Restart again and after running bootRun, Gradle correctly downloaded Apache Ant to run the application so it doesn't seem likely to be the culprit here.
IntelliJ also kept nagging me for Android SDK (who knows why but OK) which I could not install "normally" in the corporate setting but in the end I did provide it through IDEA's Settings -> System Settings -> Android SDK -> Edit and downloading some arbitrary API and the SDK tools through there so it shouldn't be the problem either (or at least I presume it shouldn't).
In line with #y.bedrov's suggestion, I am attaching the log after reproducing the issue (external link cause it exceeds SO's post character limits).
i just imported some project that i bought from my friend.
Once i import it to Android Studio 2.1.2 i just get this messages
"Error:Gradle 3.3 requires Java 7 or later to run. You are currently using Java 6."
I have install Java 7 and 8 in my mac. I have change the directory in Default Project Structure, but still that messages always appear and i can't do anything with the code.
Please master, help me.
Ran into the same issue, but I needed to keep java 6 for macOS legacy reasons (as I commented on Shubhendu's post). So I ended up downloading java 8 jdk found here
and on android studio 3.3 at least here is the rough path I took:
I right clicked project -> open module settings -> sdk location -> uncheck use embedded jdk -> added path to new 1.8 jdk which for me it was
/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home
Use this path in the Default Project Structure by using the browse option go up to this Directory named home.
/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home
May it works for you.
Deleting java 6 worked for me:
Run below command on your mac terminal:
sudo rm -rf /Library/Java/JavaVirtualMachines/1.6.0.jdk
Ctrl-Alt-Shift-S to reach Project Structure window. Change Project SDK
I'm getting this error
Error:java: Fatal Error: Unable to find package java.lang in classpath or bootclasspath
in IntelliJ when I try to build/compile any project. Something that should be stated here is that NetBeans, Eclipse and even the javac command line can compile, build, and execute the same project without errors. This is why I suspect that the problem lies with IntelliJ, all other IDEs work well.
In IntelliJ I already:
Restarted, reinstalled
Invalidate Caches / restarted
Deleted / readded the JDK in Project JDK
Deleted / readded the JDK in Platform Settings
Rebuild / recompile
In Windows I already:
Deleted / Reinstalled Java SDK
Deleted / Readded the JAVA_HOME, PATH and CLASSPATH on System Variables
Tried the above on User Variables
Deleted and reinstalled IntelliJ IDEA
I already seached for issues like this on the Internet, here on Stack Overflow I found:
Question #1 | Question #2 | Question #3 | Question #4 | Question #5
And 30+ sites, and tried every answer...
Here you can see my IntelliJ Project Structure the last time that I tried to build/compile
I was using Java 1.8 when I got this error, after some hours, I installed Java 1.7 and the project worked fine. Maybe IntelliJ doesn't support Java 1.8?
Anyway, it would be great if anyone knew a way to make Java 1.8 work with IntelliJ.
I just spent quite few hours on this and found a solution which might work for you as well. IntelliJ seems to have a bug which expects the JDK to be in a different directory than is specified. I followed these steps:
open intelliJ, click help -> show log in explorer
modify build-log/build-log.xml and change <priority value="info" /> to <priority value="debug" />, you may have to run the editor as an administrator
run the compilation which fails with "Error:java: Fatal Error: Unable to find..."
open build-log/build.log and search for rt.jar, you should find it in a block with a set of other JRE libraries and the directory which points to the file should be wrong
In my case the JDK is included in D:\Development\software\jdk1.8.0_20, while the log points to C:\Users\Vladimir\Development\software\jdk1.8.0_20
I fixed the issue by copying my JRE to the place which is expected in the log. And just like in your case this seems to only happen with JDK 1.8.
The problem comes from IntelliJ bug (existing at least in version 14).
It happens when your JDK directory is under the user profile directory. For example, JDK located in this directory (for Windows):
C:\Users\myuser\jdk1.8.0_20
will be stored in IntelliJ internal configuration (file 'jdk.table.xml') as:
$USER_HOME$\jdk1.8.0_20
But your %USER_PROFILE% environment variable could point at some other (non default) location. Then IntelliJ will look at the wrong directory.
Possible fix:
Install your JDK at different directory, which is outside your profile directory. Like:
C:\Programs\jdk1.8.0_20
Then register this JDK for use in your IntelliJ project settings.
I encountered this on Arch Linux 4.16.13 with IntelliJ 2018.1.4 after importing a Java project using Gradle. I made sure that there is a registered JDK in "Project Settings" -> "Project" but IntelliJ was unable to find the classes from the JDK, java.util.List for example.
The solution was to add a new JDK entry at the same path as the existing JDK (/usr/lib/jvm/java-8-openjdk in my case). This will cause IntelliJ to put the files under jre onto the classpath whereas with the old JDK entry, only the files under lib were on the classpath.
Had the same problem. Simple fix to others in case the other answers are complex.
Go to File -> Project Structure
Under Project SDK, choose new and add another JDK.
The default use in my case was 1.8 that was of build 181. I choose the 1.8.0_192 I had recently downloaded.
After applying, the project loads itself.
When I re-ran the test, it works!
If this problem occurs when importing a project in netbeans then try to create a new project then check the properties of your new created project and match those properties with the project that you imported in my case there was a difference between target of android package version.
From what I understood, debugging for hours, the problem is with the location where the jdk1.8 gets installed(/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home), instead of under System/Library).
So the following has to be done to fix in intellij
1. For an existing project, right click and select module settings, and SDK and add 1.8 as a version.
2. Using a terminal go to ~/Library/Preferences//options/. Remove the old JDK specific lines in jdk.table.xml. Update the default version in project.default.xml
Clean you project in intellij and build. It should use the new jdk and sync.
I'm getting error:
"Gradle project sync failed. Basic functionality (e.g. eiditing) will not work properly."
And Error Log:
Error:Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at http://gradle.org/docs/1.10/userguide/gradle_daemon.html
Please read below process output to find out more:
-----------------------
Error occurred during initialization of VM Could not reserve enough space for object heap Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
I was trying to delete .gradle folder as I read here. This worked yesterday but today when I started Android Studio the error showed again and deleting .gradle folder doesn't help.
I realy don't know what to do.
Does anyone have any suggestions?
Just a blind guess: try to add something like this to your gradle.properties file in the project:
org.gradle.jvmargs=-Xmx512m -XX:MaxPermSize=512m
Same issue solve in Android studio by
File -> Settings -> Compiler (Gradle-based Android Projects)
Change the "**VM options**" to
-Xmx512m -XX:MaxPermSize=512m
It worked for me .
The only way I've been able to fix this when it happens is by doing
./gradlew clean
and
./gradlew --refresh-dependencies
and then restarting Android Studio.
If that doesn't work I usually resort to reimporting the project.
I had the Same Issue, and Searched for almost 4 Days but can't able to solve the problem.
But at Last I can able to solve the problem, and for that please follow the steps.
Step 1: Check Your Java Version.
Step 2: If It is 1.7 then Download the New Version i.e JDK 1.8
Step 3: Install JDK 1.8
Step 4: Change the Java Version of Android Studio to 1.8 and the
problem solved...
It Worked for me.
changing compile setting to this worked for me
I was getting the same error in version 2.2.3,So I downloaded the latest Android Studio version 2.3.3, even in the latest version, I was getting the same error, below is my solution :-
Download the latest version of Android Studio from the official site.
In File>Project Structure>SDK Location, JDK Location should refer a 64-bit JDK ex. C:\Program Files\Java\jdk1.8.0_131, even after this, error was not fixed completely.
I checked the project structure, In the File>Project Structure>Project , the Android Plugin version was still 2.2.3, I changed it to 2.3.3 and the build is successful and everything is working smoothly.
This one worked for me.
Close the Android Studio
Delete .gradle folder from c:\users\{username}\.gradle
Open the Android Studio
Clean Project
Rebuild Project
Sync Project with gradle files. See screen shot
Cheers!
Check if the gradle path in File -> Settings -> Build, Execution -> Gradle is correct. I had incorrect path to local gradle distribution there.
None of these worked for me, so this is how I eventually solved my problem:
In the top-level build build.gradle file, remove
'classpath 'com.android.tools.build:gradle:some version number'
sync your project and make sure your gradle location is pointing at the correct directory
Updating Java and the problem is solved!
Control panel > Java > Update Now
I was in that situation, finding near no solution; finally I realized that my firewall was blocking java executable from opening ports/connecting. Try adding a firewall exception for the Java executable. This solved the problem for me.