Android Studio 3.0 stuck in refreshing project - android

After updating Android Studio 3.0 stable version from 2.3.3 my previous project is refreshing forever. I deleted app folder build file but it's not working.

I have faced similar issue. This what helped me to recover.
Close your Android Studio.
Remove the build, .gradle and .iml files (or use gradle clean)
Open your project path in command prompt. Execute gradlew build.
Once the build is success from cmd, open it in Studio.
If you are using gradle instead of gradle wrapper, use `gradle build'

"Refreshing project" generally means the new version of gradle is being downloaded. About 100MB of file will be downloaded during the process. Make sure you have a stable internet connection and wait for a while.

Related

Android Studio 3.3.2 Stuck at Project Setup:reading from cache

I recently installed the new version of android studio, but every time I reopen a project, the gradle configuration automatically tries syncing to the project, which is perfectly normal.
However, the sync never completes and is stuck at
Project Setup: reading from cache.
Someone know how can I fix this?
I have also found AS to be pretty slow, it just stops/hangs and then resumes. This might not solve the problem completely but can be tried. Destroy the .gradle folder and .idea folder (extreme case destroy the main .gradle folder on you computer home directory). Once that is done, re-import the project in AS. These directories maintain local cache data, which might be causing these issues.
According to known_issues_with_the_android_gradle_plugin:
Configuration on demand with Gradle 4.6 and above: If you're using Android Gradle Plugin 3.0.x or 3.1.x with Gradle 4.6 and above, you should disable configuration on demand to avoid some unpredictable build errors. (If you are using Android Gradle Plugin 3.2.0 or higher, you do not need to take any action to disable configuration on demand.)
Disable configuration on demand in your gradle.properties file as shown below:
org.gradle.configureondemand=false
Also, note that Gradle caches directories
On macOS/Linux: $HOME/.gradle/caches/
On Windows: %USER_HOME%\.gradle/caches/
Try to close your Android Studio and delete those directories then restart Android Studio.
More about build caches is here: Android Studio Build Cache

Error:Failed to open zip file. Gradle's dependency cache may be corrupt

I updated android studio 2.3 and there is a bug, gradle doesn't build and it keeps giving me the same error for all projects.
Error:Failed to open zip file.
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)
Re-download dependencies and sync project (requires network)
I have already searched for a solution, but have not found any. I tried:
Invalidate Caches / Restart...
but nothing has changed.
Repair Gradle Installation
This usually happens when something goes wrong in Android Studio's first launch (eg. system crash, connection loss or whatever).
To resolve this issue close Android Studio and delete the following directory's content, necessary files will be downloaded on IDE's next launch.
macOS: ~/.gradle/wrapper/dists
Linux: ~/.gradle/wrapper/dists
Windows: C:\Users\your-username\.gradle\wrapper\dists
While downloading Gradle manually works, I recommend letting Android Studio do the work for you.
UPDATE 17 JULY 2018:
Even if the following solution still works as of today,I've found (thanks to the answer posted by Hamid Asghari and to the comment posted by Mahendra Dabi) that simply deleting the gradle dist directory and performing a reboot of the ide, will fix the issue (please read Hamid post for a full answer, and remember that OSX and Linux have the same gradle path).
If you still want to follow my original solution, you should at least consider using a more up-to-date version of Gradle (direct link of the gradle distribution repo: https://services.gradle.org/distributions/)
Original answer (dated 7 March 2017):
I've faced the same issue this morning after upgrading Android Studio to 2.3.
To solve the issue:
1) Manually download Gradle 3.3 binary (direct link: https://services.gradle.org/distributions/gradle-3.3-bin.zip)
2) Open your android studio root directory, and extract the zip to the gradle folder (for example in my Debian machine the full path is /opt/android-studio/gradle/gradle-3.3)
3) Open Android Studio, go to File->Settings->Build, Exectution, Deployment->Gradle and set "Gradle home" to point your new gradle-3.3 folder.
4) Sync and you are ready to go!
I faced the same issue 2 days ago and today I was able to solve it like this:
Go to this path C:\Users\user_name\.gradle\wrapper\dists where user_name is your username if its you own PC or your company's name.
Delete the latest gradle-****-all files since your latest update of android studio (ex. 2.3 or another version).
If your android studio is open, close it then reopen it. A newer Gradle version will be downloaded, it will take time depending on your internet speed, the download size is around 150-200 MB before extraction so if android studio takes a long time to refresh just know its downloading. (To check the download progress right click on the new gradle folder, go to properties and check the size).
Find 'gradle-wrapper.properties' in root project
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
Change "https" to "http".
There are Following Steps to solve this issue.
1. Go to C:\Users\ ~User Name~ \.gradle\wrapper\dists.
2. Delete all the files and folders from dists folder.
3. If Android Studio is Opened then Close any opened project and Reopen the project. The Android Studio Will automatic download all the required files.
(The required time is as per your Internet Speed (Download Size will be about "89 MB"). To see the progress of the downloading Go to C:\Users\ ~User Name~ \.gradle\wrapper\dists folder and check the size of the folder.)
just remove and reDownload wrapper gradle.
Mac Home/.gradle/wrapper/dists/
remove gradle version and sync gradle in project and run project.
Go to Project pane> Android > Gradle Scripts and open "graddle-wrapper.properties" file check the distribution URL:
Go to your ".gradle/wrapper/dists/" folder and remove that file for me it was "gradle-5.6.4-all"
Then go back to android studio and click on File > Sync Project with Gradle Files. And it will start to download again
****Following solution is working for me****
Manually deleted all files from C:\Users\Admin.gradle\wrapper\dists\
where Admin is my user name
Android Studio 4.1.1 has this bug,
In gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
This won't download and always gives 'gradle cache corrupt' error, but a small change makes it work fine
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
Now sync the gradle again and it's done.
1.Go to "/Users/****/.gradle/wrapper/dists/gradle-.-all/*****".
2.Delete the "gradle-.-all.zip.lck" file.
3.Invalidate Cache and Restart.
you do not need to clean all files in dir
C:\Users\ ~User Name~ \.gradle\wrapper\dists.
and download all of them again
instead you can just delete the folder of gradle version you failed to download. In my case it was gradle-4.4-all so i just deleted that folder and android studio re downloaded gradle-4.4-all for me
In case you don't know version you was downloading:
Just go to help menu > show logs in explorer
their you will find idea.log open it and search for
Could not install Gradle distribution from 'https://services.gradle.org/distribution`
once you find it you will find gradle version you failed to download
This was the best solution for me, just follow this path C:\Users\yourusername.gradle\wrapper\dists then delete all the files inside this folder. Close your android studio and restart it and it will automatically download the updated gradle files.
I was upgrading gradle from 4.1 to 4.10 and my internet connection timed out.
So I fixed this issue by deleting "gradle-4.10-all" folder in .gradle/wrapper/dists
Taking a cue from #Mikel Yang, I found out that instead of deleting the ~/.gradle/wrapper/dists/ folder (which will means downloading the gradle files for different apps on my Android Studio), I decided to change the gradle.wrapper.properties file to any latest gradle --all.zip. So
Find 'gradle-wrapper.properties' in root project
distributionUrl=https\://services.gradle.org/distributions/gradle-{lastest}-all.zip
this way l get to save some data and time.
This happened to me because of a partially downloaded gradle distribution zip
To resolve simply go to below path
"C:/Users/your_username/.gradle"
OR
pull your gradle path from
File->Settings->Build, Exectution, Deployment-> Gradle -> gradle service directory path.
Delete the partially downloaded distribution gradle folder
Go to Studio (no need to restart) and perform gradle sync
Go to "File" in android studio, Click "invalidate caches/Restart" and "Invalidate and Restart"
That also works
I faced the issue, In my understanding, It is because of invalid combination of Android Studio And Gradle Plugin versions. I was using Gradle version 5.4.1 and Studio version 3.4, hence I updated the Android studio to 3.5 and the issue got resolved
You can delete the latest gradle-.-all folder from the below path
Windows: C:\Users\your-username.gradle\wrapper\dists
find file gradle-wrapper.properties
update with :
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip
1). Android studio-> file-> "Invalidate Caches/Restart" -> "Invalidate and Restart"
wait for gradle sync
2). Download gradle.x.x.x-bin.zip using browser
unzip it and place it in ".gradle/wrapper/dists/gradle-x.x.x-bin\xxxxxxxxxxx(auto generated folder)/
then restart android studio

Android Studio 2.2 Stuck at Building Gradle Project Info on importing existing project

I am using Android studio 2.2 on windows 10.
I am trying to import an existing android project. The problem that it took forever and still showing the message
Building 'ProjecTName' Graedle project info
after that android studio is totally getting stuck and i kill it from the task manager !
I tried the available options on Android Studio list:
Open an existing Android Studio Project
Import Project (Eclipse ADT, Gradle, etc.)
There is downloading of Gradle going on at the background. Just wait for it to finish.
Just Remove Gradle files from your project folder and retry.
Hope this will help.
I also had the problem.
I downloaded the gradle 3.5 binary distribution zip file, deleted the gradle folder from my project, then went to settings of Android Studio, checked "Offline work", used "Use local gradle distribution" and set the path of unzipped gradle folder
on the "Gradle home" and "Service directory path" text fields.
Then I tried to open the project with Android Studio 2.3.
Then a message is shown and I pressed cancel to manually configure the gradle, then I located the unzipped gradle folder again. This solved my problem.
Try the following :
1> Try Removing(Deleting) the gradle files from the project folder and then re-try.
2> Try to go into the android studio and then Files>Invalidate Caches/Restart and then try.
3> If the above two don't work do check the gradle,android Studio versions and see if those need updating.
4> Above 3 usually work for me , if it still persists, then you need to check the dependencies for the project. Also try importing some other project and if the same issue occurs, try a new installation of a STABLE version of the android studio.
Try to remove C:\Users\User.gradle
I had deleted all gradle folder and copied it from another project and pasted it, this worked for me
The above answers didn't work for me well.
I have several projects with different gradle versions, and whenever I tried to open a project the Android Studio started downloading its gradle in the background.
So, things to do before importing old projects to new Android Studio / Gradle.
In file 'build.gradle' replace old line with "classpath 'com.android.tools.build:gradle:2.3.3'"
(Assuming 2.3.3 is the latest. You can check this in your newly/recently created project)
In file 'gradle/wrapper/gradle-wrapper.properties' replace old line with 'distributionUrl=https://services.gradle.org/distributions/gradle-3.3-all.zip'
(Assuming 3.3 is the latest. You can check this in your newly/recently created project)
Now when you'll import, it wont download other gradle version.
I did find-replace for the above lines in my whole directory containing all my old projects, using Notepad++.
Actually the real Problem is that the studio is downloading gradle files throught internet and sometimes it is not able to do so, then it stucks but we can manually fix it through-
Download Gradle Files according to your android Studios version.
You can download gradle files through-https://services.gradle.org/distributions/
See your Gradle vesrion through-https://developer.android.com/studio/releases/gradle-plugin.html in the Update Gradle area.
Download the Gradle and paste it into- c:/Users/username/local/.gradle
and this is It!!!
I found that my gradle files had the gradle version set 2.1.0. So I opened the files in wordpad and first changed that to 3.3 And then it worked fine for me.
And in the gradel-wrapper.properties:
From distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
To distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
Hope that will solve the problem
This worked for me.. Will work for you for sure.
step 1: Delete "only" the Gradle "folder" from your project folder.
step 2: Import your project from Android Studio & a dialog box will appear "press
Ok to use..., or Cancel to... ". Press "Cancel" & locate the path where you have downloaded the latest Gradle File (C:/Gradle/gradle-3.5 ,in my case).
Step 3: it will give an error saying that "no cache version for....". So now check which version of com.android.tools.build:gradle: you have.. so check the path "C:\Program Files\Android\Android Studio\gradle\m2repository\com\android\tools\build\gradle" and select the latest version (2.3.2 in my case). So now, go to Gradle Scripts-> build.gradle(android) in Android Studio and change the dependencie's classpath to (classpath 'com.android.tools.build:gradle:2.3.2')in my case
step 4: Click on "try again". Then it'll ask for upgrading tools, upgrade it by clicking on it & then you're done..
Congrats, your Project is successfully built..
And yeah make sure that In Setting-> Build,Exec...->Gradle-> "check mark on Use local gradle distribution & offline work & Gradle home: C:/Gradle/gradle-3.5 & Service directory path: C:/Gradle/gradle-3.5 (in my case).
Deleting temp and temp% worked for me!
Download manually gradle-3.3-all.zip
and extract into /Users/[yourUsername]/.gradle/wrapper/dists/gradle-3.3-all/55gk2rcmfc6p2dg9u9ohc3hw9/

Android Studio Stuck at opening Project?

I recently updated from Android Studio 2.0 to 2.1.2 and now I have a project which doesn't open. Android Studio is stuck at the following screen for more than 10-15min.
I tried solutions from these answers.[ans1] [ans2]
but none of them work.
I can create new projects and also import projects built on eclipse. But cannot open my own project.
Please help.
Delete the gradle folder in the project folder. It will work.
For many problems such as stuck with opening or downloading something while starting
I use this sequence as an ultimate guide and on one of the steps always works out.
Recently I used it after updating to 3.2
Try File -> Invalidate caches / Restart
Shutdown Android Studio
Remove .gradle folder in the user home directory
Start Android Studio (Studio will download gradle data)
After Gradle build is done, rebuild project
According to Android Studio's Known Issues https://developer.android.com/studio/known-issues under "Configuration on demand with Gradle 4.6 and above:", if you are using Android Gradle Plugin 3.0.x or 3.1.x with Gradle 4.6 and above you should add the following line to gradle.properties:
org.gradle.configureondemand = false
This seemed to solve my issue with Android Studio getting stuck at "Project setup: reading from cache".

Syncing Android Studio project with Gradle files

I was working on a project, and then I got a prompt to update Android Studio. After I did that, I started getting this error when trying to run my app
It says
The project may need to be synced with Gradle files
How do I solve this?
EDIT
Starting with Android Studio 3.1, you should go to:
File -> Sync Project with Gradle Files
OLD
Clicking the button 'Sync Project With Gradle Files' should do the trick:
Tools -> Android -> Sync Project with Gradle Files
If that fails, try running 'Rebuild project':
Build -> Rebuild Project
Old Answer
When trying to run the application, instead of selecting the directory highlighted here in blue
I selected the subdirectory instead
and clicked "run".All the issues with Gradle are automatically resolved and the missing apk directory is automatically created.
New Solution
The Sync project with gradle files button disappeared from Android Studio for a while.Its back and you can find it here:
hit the button and wait for the task to complete
I've had this problem after installing the genymotion (another android amulator) plugin.
A closer inspection reveled that gradle needs SDK tools version 19.1.0 in order to run (I had 19.0.3 previously).
To fix it, I had to edit build.gradle and under android I changed to: buildToolsVersion 19.1.0
Then I had to rebuild again, and the error was gone.
Keys combination:
Ctrl + F5
Syncs the project with Gradle files.
The gradle versions in android studio and your code is not the same. This is why even after you update the gradle version on android studio, the error still persist.
So, edit the Gradle distribution reference in the gradle/wrapper/gradle-wrapper.properties file:
distributionUrl = https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
Ref: https://developer.android.com/studio/releases/gradle-plugin.html#updating-gradle
I am using Android Studio 4 developing a Fluter/Dart application. There does not seem to be a Sync project with gradle button or file menu item, there is no clean or rebuild either.
I fixed the problem by removing the .idea folder. The suggestion included removing .gradle as well, but it did not exist.
i had this problem yesterday. can you folow the local path in windows explorer?
(C:\users\..\AndroidStudioProjects\SharedPreferencesDemoProject\SharedPreferencesDemo\build\apk\)
i had to manually create the 'apk' directory in '\build', then the problem was fixed

Categories

Resources