I've just tried to use Android Studio. I've created blank project and tried to create Activity which extends AppCompatActivity. Unfortunalty Android Studio "says" that it
Cannot resolve symbol 'AppCompatActivity'
I have compile "com.android.support:appcompat-v7:22.0.+" in dependency list of my "app" module and rebuilt project several times. However I can only use ActionBarActivity. What am I doing wrong?
A little addition to other answers here, for anyone having the same error while using the right lib version and the right class.
When I upgraded to
appcompat-v7:22.1.0
In which ActionBarActivity is deprecated and empty and AppCompatActivty is the way to go, due to some glitch in Android Studio, It didn't quite pick up on version change.
i.e. Even though Gradle ran without errors, the IDE itself kept saying
Cannot resolve symbol 'AppCompatActivity' (and it also wasn't available through the Ctrl+N search)
I looked into the .idea/libraries folder and noticed there's no appropriate metafile for the new version of the lib.
So, using the old-reliable File->Invalidate Caches/Restart did the trick. Always try this when you feel something is magically wrong with Android Studio.
And then Disable offline mode and sync.
If the soft methods via gradle file / "Invalidate caches" and the other IDE tools do not work, use the hard way:
Exit Android Studio
Navigate in your project to the .idea folder
Just Rename the libraries folder
Restart Android Studio. It should now recreate the libraries folder and work again.
This worked for me on
Android Studio 3.1.2
Build #AI-173.4720617, built on April 13, 2018
JRE: 1.8.0_152-release-1024-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.13.0-38-generic
Shahbaz Ali confirmed, it works also on
Android Studio 3.1.3
Build #AI-173.4819257, built on June 4, 2018
JRE: 1.8.0_152-release-1024-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.13.0-38-generic
moujib confirmed, it works on Android Studio 3.2.1
Today (22 April) you can use the new AppCompatActivity released with the support libraries v 22.1.0.
Just change your dependency :
compile "com.android.support:appcompat-v7:22.1.0"
Here you can find more info about this new class.
It is too simple.here are the steps you need to follow
1-Exit Android studio.
2-Go to your project directory.
3-Something like this in my case( F>Android->YourProjectName->.idea).
4)-delete libraries folder present in .idea folder.
5)-restart your android studio.
and your issue is resolved.
I got it fixed by Going to build.gradle file and in dependencies the appcompat one, something like compile 'com.android.support:appcompat-v7:XX.X.X'
Changed it to compile 'com.android.support:appcompat-v7:XX.X.+'
Then click on Sync. All the red squiggly lines should go if everything else in your code is correct.
Check for typos too, i wasted my whole day looking for solutions when i had actually typed AppCompactActivity instead of AppCompatActivity
Cannot resolve symbol AppCompatActivity Issue.
Do the Simple Step to resolve the problem.
i) Exit the Android studio.
ii) Go to your project directory.
iii) Find the .idea folder in your project directory.
iv) Delete .idea folder.
v) Restart your android studio.
vi) The Issue Will be resolved.
I got the Cannot resolve symbol error for AppCompatActivity and many other classes & methods after updating Android Studio from 2.2.3 to 2.3, updating Android Gradle plugin to 2.3.0, and updating Gradle to 3.3.
File -> Invalidate Caches / Restart did not resolve the issue.
Preferences -> Build, Execution, Deployment -> Gradle showed Use local gradle distribution selected with Gradle home: /Applications/Android Studio.app/Contents/gradle/gradle-2.14.1 and a warning displayed saying the gradle location was incorrect.
Resolved issue by selecting Use default gradle wrapper (recommended).
Probably just pointing to the new local distribution location would also work.
When you add AndroidX support in Gradle.properties file e.g.
android.useAndroidX=true
android.enableJetifier=true
If you are using Gradle version greater than 3.2, the conventional Appcompat dependancy e.g.
implementation 'com.android.support:appcompat-v7:27.1.1
wont work.
Replace this dependancy with:
implementation 'androidx.appcompat:appcompat:1.1.0'
Moreover, change the AppCompatActivity import in your class file from this:
import android.support.v7.app.AppCompatActivity;
to this:
import androidx.appcompat.app.AppCompatActivity;
Done
Try this. In Android Studio, after putting the dependency in build.gradle.
Go to Build --> Clean Project.
It worked for me.
Thats really insane, i tried everything, synced with Gradle files, invalidated and restarted android studio. Still the problem persisted. Last resort was deleting .idea/libraries folder and it worked as charm.
You can use new AppCompatActivity appcompat-v7:22.1.+
Just add this to your gradle:
compile 'com.android.support:appcompat-v7:22.1.1'
For me the issue resolved when i updated the appcompact v7 to latest..
compile 'com.android.support:appcompat-v7:25.3.0'
Hope it helps...:)
So my collegue pushed their local.properties which broke everything. I copied my sdk path from another app and did:
File -> Sync Project with Gradle Files
I was getting this same problem with Android SDK 23, while developing on a Mac OS X Yosemite Machine. It turned out that I did not have Java SDK 7.
Once I installed Java SDK 7 and pointed the SDK from with the Android Studio to the new SDK, everything worked for me.
Here are the steps that I followed:
1) Shutdown Android SDK
2) Install Java SDK for Mac OS X from http://www.oracle.com/technetwork/java/javase/downloads/index.html
3) Start the Android SDK and point the SDK for this project to the new 1.7 Java SDK by going to File -> Project Structure -> JDK Location
4) Restart Android Studio
Hope this help
none of below solved my issue
Restart Android
File >> Synch Project with Gradle Files
Build >> Clean Project
Build >> Rebuild Project
File >> Invalidate Caches / Restart
Instead, I solved it by updating the version of appcompat & design dependencies to the recent version
To do so: go to build.grade (Module:app) >> dependencies section and then hit ALT + ENTER on both appcompat & design dependencies then select the shown version in my case it's 24.2.1 as shown in the picture
Remember to press Alt+Enter or add the import.
import android.support.v7.app.AppCompatActivity;
I updated my Gradle 2.3.3 to 4.4 and got an error on AppCompatActivity and also Cardview. I tried with clean project and rebuild project. It won't work, then I go to Project Folder -> .idea -> create backup of libraries folder and remove it -> then Rebuild Project that solved my issue.
Lets get going step by step: first clean project by using
Build->Clean
if this doesn't helps then use your second step
File>Invalidate Caches/Restart...
But the real problem begins when all the above options doesn't works so use your ultimate solution is to close project and go to project location directory and delete
.idea
You can open your project now again.
After upgrading to the latest support library, I had to upgrade to the latest Android studio (beta) version and gradle version before the IDE recognized AppCompatActivity again (invalidating caches and restart did not do the trick)
Add this dependency in project build .gradle.
Follow the example below.
dependencies {
compile 'com.android.support:appcompat-v7:22.1.0'
}
Easist Way
Open app level build.gradle and remove appcompact-v7 dependency & Sync.
Add dependency again & Sync.
Error gone!
Before
After
I solved it adding:
import androidx.appcompat.app.AppCompatActivity;
in the "import" zone of the main .java file. It worked for me.
Hope it helps!
You Have to just Do some change in your Gradle App File by adding some dependency
compile "com.android.support:appcompat-v7:XX:YY:ZZ"
while XX:YY:ZZ is the version code that you are using in your gradle file, otherwise if you set this version lower or higher than that you are using , then your app will face some problems like it will crash sometimes
i just update my android studio from 2.3.2 to 3.1.2 version. and this error occurs.
i clean project, rebuild project, invalidate cache/restart but nothing works.
i resolve this error by updating appcompat library from
compile 'com.android.support:appcompat-v7:23.4.0'
to
compile 'com.android.support:appcompat-v7:25.1.1'
in app build.gradle file.
If Invalidating caches not helps, just close the project then re-open it. Steps:
File > Close Project
Remove the project out of the starting project list
Close Android Studio
Open Android Studio
Open existed Project with this project
This happens because of one the following reasons:
You do not have the SDK API installed (this was my problem)
Your project/Android Studio doesn’t know where the needed files are
Your project references an outdated compile version that does not support AppCompatActivity
There is a typo
Possible solutions:
Check your .gradle file to make sure you’re not referencing an outdated version. AppCompatActivity was added in version 25.1.0 and belongs to Maven artifact com.android.support:appcompat-v7:28.0.0-alpha1, so do not use any version earlier than this. In your build.gradle (Module: app) file you should have the dependency listed:
dependencies {
compile 'com.android.support:appcompat-v7:25.1.0'
}
You may be using a different version, but just make sure you have listed the
dependency.
Open the SDK manager and download every API 7 or newer. If you were missing the needed API it will fix that issue, and downloading all the newer API’s can save you some hassle later on as well.
Check for typos in your import statement. Make sure it doesn’t say “AppCompactActivity” instead of “AppCompatActivity”.
Resync your project (File >Sync project with Gradle files)
Rebuild your project (Build >rebuild)
Clean your project (Build >clean project)
Close and restart Android Studio
Update Android Studio
Regenerate your libraries folder – In Android Studio, view your files in project view. Find the folder YourProjectName >.idea >libraries. Rename the folder to “libraries_delete_me”. Close and reopen Android Studio. Open your project again and the libraries folder should be regenerated with all of the files; you can now delete the “libraries_delete_me” folder.
For me, the issue resolved when I updated the Gradle build version. Don't know why?
I'll tell you how did i solved this problem in eclipse.
Download zip file from this link.https://github.com/dandar3/android-support-v7-appcompat then extract this file,open project, in lib folder you will see one jar file named "android-support-v7-appcompat" , add this jar file into your project. Thats it.
This can might be in the version difference in the app level gradle check it once and then re-build
Related
I updated android studio from 3.3 to 3.4 version and after install and do ./gradlew lint I am getting the next error:
Deprecated Gradle features were used in this build, making it
incompatible with Gradle 6.0.
Then I use the next command to get more details:
./gradlwe build --warning-mode=all
And I get the next message:
Failed to apply plugin [id 'com.android.application']
Minimum supported Gradle version is 5.1.1. Current version is 4.4.1. If using the gradle wrapper, try editing the distributionUrl in .gradle/daemon/4.4.1/gradle/wrapper/gradle-wrapper.properties
to gradle-5.1.1-all.zip
And when I edited my gradle-wrapper.properties, I see that the changes were already done, I.E. the version of the distributionUrl already was gradle-5.1.1.-all.zip
Any idea that how can resolve this?
You could just edit YOUR_APPLICATION_FOLDER/gradle/wrapper/gradle-wrapper.properties and change the last line to:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
Android Studio will download necessary library.
This was my solution.
My_project
/gradle
/wrapper
/gradle-wrapper.properties
Modify this line with the Gradle 5.1.1
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
Finally, I was able to solve this dropping the folders of the oldest version in ~/.gradle/wrapper/dists and leave only the gradle-5.1.1-all
In my case, gradle failed to download the version I specified though I tried all previous solutions.
Apparently, I was opening my project by selecting "MyProject/App" directory. Gradle successfully updated when I opened the same project by selecting the "MyProject" folder.
Check your full project and find all "Gradle-wrapper.properties" files. If your project has multiple modules then there are chances of having multiple. and set -
distributionUrl=https://services.gradle.org/distributions/gradle-5.1.1-all.zip
Gradle sync
If not done then invalidate the cache and restart the project.
Still not working then go to your root directory on Linux and find .gradle folder. Delete it and restart the android studio.
If you use Ubuntu and all above answers didn't solve your problem try to upgrade gradle on your Ubuntu with this commands from this answer https://askubuntu.com/a/975018/714791
sudo add-apt-repository ppa:cwchien/gradle
sudo apt-get update
sudo apt upgrade gradle
It will help I hope
I resolved by two below steps.
delete gradle folder
check your classpath 'com.android.tools.build:gradle:{$gradleVersion}
My gradleVersion is 3.5.3.
I solved this by changing the distributionUrl in gradle-wrapper.properties in gradle/wrapper, not gradle.properties
Maybe it's your gradle environment variable.
execute 'gradle -v'
Check that the gradle version of the project matches the gradle environment variable version
those who are still facing issue with Cordova/Ionic, this is due to CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL which is being checked at platforms/android/cordova/lib/builders/GradleBuilder.js
set CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL to desired distributional
for MacOs
export CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL = https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
I think it's very important to mention which IDE you're using and what are the configurations.
What made me upset was, I had a setting in gradle-wrapper.properties file which was "ignored" to my mind.
I've found the settings in the IDEA application settings, there:
and then selecting:
and everything works as expected.
Deleting 'all other' locally cached versions can never be the right solution ;)
Good luck!
My app is using Cordova v9.0.0
distributionUrl is set at platforms\android\cordova\lib\builders\ProjectBuilder.js
You can set distributionUrl from the command line with
set CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL="https://services.gradle.org/distributions/gradle-[version]-all.zip"
Replace [version] with your preference
it solved for me
get the flutter SDK directory
this is my flutter Sdk
C:\flutter\.pub-cache\hosted\pub.dartlang.org\connectivity_macos-0.1.0+2\android\gradle\wrapper
change gradle-wrapper.properties
Modify this line with the Gradle 5.1.1
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
I had the same error: Error "Minimum supported Gradle version is 6.1.1. Current version is 5.1.1" but when I opened the gradle.properties and I found this "distributionUrl=https://services.gradle.org/distributions/gradle-6.1.1-all.zip" which was correct but wasn't working. To solve this, I deleted the ".gradle" file in the explorer, reopened the app and found out the distributionUrl had change to 5.2.2-all.zip in gradle.properties; I then edited to 6.1.1-all.zip and sync and everything worked like a charm. I hope this can help someone else.
Try to download manually Gradle-5.1.1 from https://gradle.org/releases then go to file/project structure/project and put the new version in gradle version. (You can also use this link - jenv.io/candidate/gradle)
I was having the same problem after migrating from android.support library to androidx where junit library start with androidTestImplementation and not
testImplementation.
So i changed
testImplementation "junit:junit:$rootProject.junitVersion"
to
androidTestImplementation androidx.test.ext:junit:1.0.0-beta01
or
androidTestImplementation "junit:junit:$rootProject.junitVersion"
Remember to append android before testImplementation
also, try removing all older/unwanted versions of gradle using:
cd usr/local/Cellar/gradle/
Don't forget to run the gradle wrapper in your project: https://docs.gradle.org/6.4.1/userguide/gradle_wrapper.html#sec:adding_wrapper
Delete gradle folder from your project directory as well as from the app directory.
restart Adroid studio and resync gradle.
it will solve your problem. If not you might be opened the project yourproject/app. close Android studio and import your project after selecting yourproject. Then resync gradle. This will solve your problem.
For Windows 10:
Go to C:\Users\<user-name>\.gradle\wrapper\dists and delete everything there. Android studio will download the appropriate version afterwards.
If anyone is still searching for a solution after trying literally everything, here's what worked for me.
In the .gitlab-ci.yml file, my image: key was outdated and was writing in the script that Gradle was set to 5.1.1 even though everything in my Android Studio was 7.0.2. After talking to the guy who wrote the image script, I just had to increment the version of that.
https://forum.gitlab.com/t/set-specific-version-of-gradle-for-ci-build/41716/4
This error was solved by restarting Android Studio.
I have tried to solve this problem for 3 months but I always failed to solve it?
Error:The project is using an unsupported version of Gradle.
Please point to a supported Gradle version in the project's Gradle settings or in the project's Gradle wrapper (if applicable.)
Fix Gradle wrapper and re-import project<br>Gradle settings
change your gradle version to latest in project level build.gradle file.
Open your android studio. Go to Tools -> Android -> Sync project with Gradle File.
Happy Coding...
Just like they said, Open your studio. Go to file->settings->Build,Execution,Deployment->Gradle.
My friend in university had the same problem like you. I think that he solved it. I will talk to him and dm you what he said.
I am using android studio 2.3.1 and it was working fine yesterday But now it throw me an error Error:Cause: invalid stream header: 000900D9
this message throw from Messages Gradle Sync dialog.
Below are the steps which i did to fixed this problem but nothing works for me
1.invalidate cache and restart
Delete scripts and scripts-remapped files from C:\Users\suraj.gradle\caches\3.3
and also checked many post in stackoverflow but nothing work for me and most of the questions put here are not answered by anyone yet .
Under my project structure
Compile Sdk version :Api 25
Build tool version :25.0.2
I was facing the same problem and was not able to figure out what exactly causes this problem.
But removing the whole .gradle folder (/home/$USER/.gradle in my case) and rebuilding the app fixed it.
I noticed that many users (me included) faced this issue using the 3.3 gradle version; update to 3.5 and it will be fine
Go to your console, run
./gradlew --stacktrace
If it says
GradleException: Could not read cache value from '[...]/.gradle/daemon/3.3/registry.bin'
go to this folder and delete the file registry.bin.lock. No need to delete the whole .gradle directory and download everything again.
Andrea's answer worked for me, too (i.e. upgrading gradle from 3.3 to 3.5). For the shake of completeness, I'd just like to add that you can update gradle in your Android Studio by going to:
File > Project Structure > Project
You might have to update your Android Plugin Version, too. Check the version compatibility table for more information.
File > Invalidate Caches / Restart
Error: Gradle sync failed: Cause: invalid stream header: 005C0044, 000900D9, ... or other some of the Gradle sync failed
There is a good method for this issue. you should update the android gradle as following in three steps:
1) Download latest gradle version form link: https://gradle.org/releases/
2) Unzip the download file and copy it in address: C:\Program Files\Android\Android Studio\gradle
3) In the android studio, change gradle version to the latest gradle version (4.5.1 based on the unzip file, which had been named as the gradle-4.5.1) in path: File>Project structure>Project>gradle version
4) In the android studio, change the gradle home file (File>Settings>Build,Execution,Development>gradle>gradle home) to address: C:\Program Files\Android\Android Studio\gradle\gradle-4.5.1.
It's gradle version.
I've updated gradle from 4.6 to 4.10.1 on one branch. Switched to another branch without gradle update and couldn't sync it. Updating gradle to the latest version on all branches helped solved the problem.
So check which gradle version you have in gradle/wrapper/gradle-wrapper.properties file and try to update it to match your .gradle directory (or just update to the latest one)
E.g.
there is a .gradle/4.10.1 directory
gradle/wrapper/gradle-wrapper.properties is pointing to the same gradle version
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
This Works
Delete
caches in .gradle
caches in folder where your android studio project is located
delete all iml files
delete .gradle in folder where your project is located
happy coding
I am doing a project in Android Studio and today I saw that suddenly all my code has errors and even the line:
import com.google.android.gms.appindexing.Action;
has error: cannot resolve symbol android
any suggestions why this might have happened?
Please ensure you have mention in your project grades it has been tested and working fine
dependencies {
...
compile 'com.google.android.gms:play-services-appindexing:8.4.0'
...
}
clean your project and rebuild again and wait till android studio make indexing and loaded all resource some time due to system it will slow.
please comment if you found something else. happy coding :)
1st update your SDKs ( Android tools SDK & Google play service)
in your build.gradle "modules" include this code in your dependencies
compile 'com.google.android.gms:play-services-places:<version>
where is the latest version available...my version at the time of this answer is 11.0.4
Please try as follows
Exit Android Studio
Back up your project
Delete all the .iml files and the .idea folder
Relaunch Android Studio and reimport your project
or
Exit Android Studio
Back up your project or rename your project
Clone new project
solved this issue by -> clean project - > save all - > close all tabs ->
Close entire project ->
Reopen it again.
The issue solved
After I updated Android Studio to version 0.2.7, I got the following error:
org.gradle.tooling.GradleConnectionException: Could not execute build
using Gradle distribution
'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.: Could
not execute build using Gradle distribution
'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.
This is my build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
dependencies {
compile files('libs/android-support-v4.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 10
targetSdkVersion 17
}
}
Does anyone know this error?
I had the same issue, can't say I know what caused it, but I just closed Android Studio, renamed the c:\users\MY USERNAME\.gradle directory to old-.gradle and then re-launched Android Studio.
Android studio then re-created the directory and automatically downloaded the gradle zip file and set it all up.
Seems to all be fine but to be honest I don't know what this directory is nor what the root cause of the problem was either, so proceed with caution and keep the old .gradle folder around for a bit until you're happy all is working fine.
For me the following two steps fixed the issue:
Make sure the Gradle build was successful
Android Studio - File - Invalidate Caches / Restart...
I suddenly had this issue in the morning after it working the night before. I tried all solutions here and failed.
I also tried installing another version of Gradle 1.8 and setting the gradle_home.
Tried restarting studio.
Eventually the tried and trusted method of restarting Windows worked for me.
All in all a frustrating waste of time.
I updated to 0.3.0 and had the same issue. I had to end up changing my Gradle version to classpath 'com.android.tools.build:gradle:0.6.1+' and in build.gradle and also changing the distributionUrl to distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-bin.zip in the gradle-wrapper.properties file. Then I did a local import of the Gradle file. That worked for me.
I had this issue as well and jaywhy13 answer was good but not enough.
I had to change a setting: Settings -> Gradle -> MyProject
There you need to check the "auto import" and select "use customizable gradle wrapper". After that it should refresh gradle and you can build again. If not try a reboot of Android Studio.
First of all, JDK environment variable settings :
e.g) JAVA_HOME -> C:\develop\java\jdk\jdk1.8.0_25
path -> %JAVA_HOME%\bin;
eclipse
Window -> preferences -> Gradle -> Arguments -> Worksapce JRE check -> jdk(jdk1.8.0_25) choice
again Run -> gradle build :)
1- delete .gradle folder in the root directory of the app
2- invalidate cache and restart
As per answer by WarrenFaith, go to:
Settings -> Gradle -> Project-level settings
Change to Use customizable gradle wrapper.
Click OK and watch it build. If you still get an error at that stage, go back to:
Settings -> Gradle -> Project-level settings
Change it back to Use default gradle wrapper (recommended)
Click OK. That fixed it for me.
I had the same issue and i solved it by deleteing gradle-wrapper.jar and gradle-wrapper.properties file of Gradle wrapper then clean rebuild work for me.
I entered:
[C:\Users\user\].gradle\caches\1.8\scripts directory and deleted its content.
I didn't had to restart anything, just removed scripts content any rerun it.
For me, when using IntelliJ IDEA, this error arose because I had the Java SDK, rather than an Android SDK, set at the Project level.
My fix:
IntelliJ > File > Project Structure ...
Project > Project SDK > [Select] 'Android API 19 Platform (java version "1.7.0_40")'
I'm on:
IntelliJ IDEA: 13.1.3
Gradle: 1.10
Android Plugin for Gradle: 0.9.+
I had the same problem on Ubuntu with Eclipse 4.3 (Kepler) and the problem was that I created the project with a minus-sign in it.
I recreated the project with no specialchars and it all worked fine
I had the same Gradle build problems in Eclipse and by doing the following steps, the problems were solved:
set up project to use correct java version of java
project properties-> java build path -> jre system (edit the current one, and add the correct java jdk or jre there)
window->Preferences ->Gradle->Arguments-> Workspace JRE (set to the correct one)
Hope this will help those who have the same problems.
This happened to me after a java update, few things to check if you are sure your path has been set before:
if the path doesn't match the latest java install folder, change it (if your in eclipse check the eclipse.ini too to make sure your using your systems default vm (ie no VM tag) )
go to the java directory, there should be a 'jdk' and a 'jre' in the path, for example:
C:\Program Files (x86)\Java\jdk1.8.0_72\jre
if not you probably installed the JRE only not the JDK that
finally if the lib folder of the jdk (not jre) doesnt contain tools.jar then you have a problem with the install
I had a similar problem after doing brew install gradle. Perhaps it was because it was an older version. So I uninstalled and instead followed the gradle website's install instructions and then when I did gradle eclipse I no longer had the could not execute build using gradle distribution error.
This problem occurred to me when I edited the configurations in Android Studio to use the Desktop. However, using the default(android) seems to work well without any issues.
To correct this mistake very easily,
If you read logs. The problem occurs because of the sudden shutdown of the IDEA. And the log files do not correctly write data. Just delete the file on the path
C:/Users/{UserName}/.Gradle/demon/{gradleVersion}/registry.bin.lock.