When i have move my project to my laptop and import it in file/import project, Android studio alert me
project refresh failed
Error: The device is not ready
Look inside your gradle file for lines something like this (this is mine):
maven {
url "D:/Android/sdk/extras/android/m2repository"
}
I do not have drive D:\ with Android SDK on my new laptop. That is why I met the error:
Gradle sync failed: The device is not ready
Consult IDE log for more details (Help | Show Log)
In the Android Studio's log I found the line:
Caused by: org.gradle.api.UncheckedIOException: Could not normalize path for file 'D:\Android\sdk\extras\android\m2repository'.
Hope this post will help other people to handle this error quickly.
try this algorythm:
File -> Invalidate caches / Restart
Shutdown Android Studio
Rename/remove .gradle folder in the user home directory
Restart Android Studio let it download all the Gradle stuff it needs
Gradle build success
Rebuild your project
You should connect your android device to computer
i think you have driver problem .and you should install your device driver
if you use windows bellows link show you how to install driver
Manually installing Android ADB USB Driver
If you have implemented product flavors in a project then please check implementation and keystore path. In my case it was the reason and i have corrected keystore file path in gradle it is working fine now.
I had system environment variables GRADLE_HOME and GRADLE_USER_HOME set to non existings directory, which I had to remove to fix a similar issue.
Related
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 (v2.2 Preview 3) suddenly failed to update the tools. It keeps giving the error pasted below:
To install:
- LLDB 2.2 (lldb;2.2)
Preparing "Install LLDB 2.2".
Failed to read or create install properties file.
Failed packages:
- LLDB 2.2 (lldb;2.2)
I gave the folder full permissions. Ran android studio on administrator mode. End-tasked adb from task manager. Disabled antivirus. Deleted the folder and then ran the update again. But nothing works.
I also tried to create a new sdk location on my drive. But then that failed to, it gave the same error as above. -> Failed to read or create install properties file.
Any ideas?
I also encountered the same error when trying to update build tools after upgrading Android Studio. Unfortunately, in my case, removing .AndroidStudio2.x folder and re-opened studio with no config imported didn't work.
But then inspired by this answer, I go to Android Studio folder, then to bin folder, right-clicked on studio64.exe, choose Run as administrator. Then when I tried to update the build tools, it worked.
I'll just leave it here as an alternative way in case someone encountered the same problem.
For some reasons, this happens when you import the settings when upgrading Android Studio.
The fix is to delete the .AndroidStudio2.1 or .AndroidStudio2.2 folder in your profile directory. Open android studio and don't import any config.
This will however will ask to download the supporting libraries again.
In Windows 10, I pinned the application to my taskbar, and right-clicked on the icon and chose the option to run as administrator. Then I went through the steps to download my SDKs. Everything worked as it should.
Using Windows7: I unzipped the SDK under C:\Program Files\... but eventually discovered that security permissions in the "Program Files" area prevented sdkmanager.bat from creating folders and files.
It looks like you can give sdkmanager.bat permissions, but there are many complications, especially in cmd.
So I moved the SDK to C:\Users\[admin_name]\.android (or any folder) where it's easy for the sdkmanger to create folders and files and it finally worked !!
Hope this helps someone. Thank-you to all those who have helped me.
When using the sdkmanager command in Linux, you have to run it as root:
sudo sdkmanager --install emulator
On Linux, It's a permission issue. You can resolve the problem quickly by launching Android Studio as root :
gksudo <path_to_file_studio.sh>
If you want to fix this problem on long term and in more secure and better way you should find the right files / folder to alter and change their permissions. I didn't point it for now.
This solution was tested on Debian, but I guess it works on Unbuntu, Mint ...etc.
You cannot edit local.properties it is a generated file, right click your project and select 'Open Module Settings' under SDK Location put your location for your SDK.
paste in /Users/gururaj/Library/Android/sdk
Clean and rebuild your project
Update
Try to delete your local.properties file and create a new one, but do not check it into version control.
Right click top level of project and Create new file 'local.properties' then add: sdk.dir=/Users/gururaj/Library/Android/sdk
Clean and build
It worked for me to uninstall everything, delete the directories created in Program Files and Program Files (x86) and reinstall in another directory.
I'm completely new to android studio. Installed it plus all the skd packages the installation guide told me to. I've been trying a couple of things for the past two weeks now with no success. Can someone direct me to a solution or where more detailed error messages are found?
Im receiving this error message from the "Messages Gradle Sync" Panel:
"Error:(1, 0) Cause: com.google.common.collect.Sets"
edit : I have ubuntu installed on this computer aswell and I decided to install android studio on it. Its woking there so I guess I'll work from it until studio gets a fix or I find one.
Uncheck "Offline work" in File>Settings>Gradle>Global Gradle Settings
Resync the project, for example by restarting the Android Studio.
Once synced, you can check the option again to work offline
Update java if Android L SDK installed
-File -> Invalidate caches / Restart
-Shutdown Android Studio
-Rename/remove .gradle folder in the user home directory
-Restart Android Studio let it download all the Gradle stuff it needs
-Gradle build success !
Open your project where its located
For example:
MyApplication->gradle->wrapper->gradle-wrapper.properties
go into it and change this row:
distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip
with this:
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip
and try to sync with this button in your IDE
At https://code.google.com/p/android/issues/detail?id=71725 I found this answer by (#3 alinmit...#gmail.com) and it solved that problem for me.
In Android Studio go to File>Settings>Gradle>Global Gradle Settings and in Gradle VM options specify the proxy details:
-Dhttp.proxyHost=dummyHost -Dhttp.proxyPort=dummyPort -Dhttp.proxyUser=dummyUser -Dhttp.proxyPassword=dummyPassword
I have Avast antivirus, i closed it and then the problem disappeared! try to disable your firewall and let us know! :-)
I'm creating an Android project with Gradle Android Module, but as soon as I create it, I have an error I don't understand and I have no idea to resolve it. It says
Gradle project sync failed. Basic functionality (e.g editing, debugging) will not work properly" or "Gradle 'myapp' project refresh failed: A fatal exception has occurred. Program will exit. : Gradle settings
If you have an idea of what causes this problem or if you have already encountered it, please tell me what to do.
Came across this issue when I was having similar issue. I solved this problem as follows
Download and extract gradle file to directory of choice
Set the environmental variable for gradle, I think this has no effect in the solution.
Go to intellij and access setting window through File -> Setting
On setting window, go to Build, Execute. Deployment -> Build Tools -> Gradle
Check "Use local gradle distribution"
From Gradle home field access gradle installed path
Please note, I am working with intellij 15.
I have run into the same problem. Part of it may be that you have recently installed the Android SDK and have not accepted the license agreement. Here are the steps you can take. (I was using IntelliJ Ultimate IDEA 14.0.2.)
Stop IntelliJ and restart it with Admin privileges. (You will be expanding zip files in the Program Files (x86) directory, and won't be able to do so unless you are an administrator).
On the "messages Gradle Sync" (bottom window), there is a hyperlink that says Error: "Install Repository and sync project." Click on it.
Accept the License Agreement.
Post the logs from Event Log window. One possibility could be that the gradle setting file is pointing to a non-existing version of gradle. You can find it under gradle -> wrapper -> gradle-wrapper-properties
Problem: If you are getting error as 'gradle sync issue". We have to build very first time from command prompt (not from intellij)
Solution:
Step 1:
Setup user environment variable for jdk 11:
Variable: JAVA_HOME
Value: C:\Program Files\Java\jdk-11.0.14
Step 2:
Go to your project path (File explorer)
Open cmd prompt
type "gradlew clean build"
build should start
no worries, either build success or failed
Step 3:
Open intellij project and open intellij terminal and again run the same command
"gradlew clean build"
Step 4:
Go to build tab (bottom of the intellij window)
Go to sync tab -> Make sure it should show as "BUILD SUCCESSFUL"
Step 5:
now again go to intellij terminal and again run the same command
"gradlew clean build"
Now you will be able to see your test execution results. Please verify report
Please let me know if there is any question.
When I try to build a project on Android Studio, I get this error:
Compilation completed with 1 error and 0 warnings in 9 sec
1 error
0 warnings
org.gradle.tooling.GradleConnectionException: Could not install Gradle distribution from 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.: Could not install Gradle distribution from 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.
What can I do to fix it?
UPDATE:
When I look at the Error Log, I saw this:
org.jetbrains.plugins.gradle.settings.GradleSettings cannot be cast to org.jetbrains.plugins.gradle.settings.GradleSettings:
org.jetbrains.plugins.gradle.settings.GradleSettings cannot be cast to org.jetbrains.plugins.gradle.settings.GradleSettings
Please read the log from:
On Microsoft Windows:
[Windwos Drive]\Documents and Settings\[your username]\.AndroidStudioPreview\system\log
On Mac and Linux: ~/.AndroidStudioPreview/system/log/
And you will find the tmp download path of gradle-1.6-bin.zip. For example, mine is:
2013-05-17 09:42:16,934 [ 283002] INFO - ution.rmi.RemoteProcessSupport - Unzipping C:\Documents and Settings\Kiki.J.Hu\.gradle\wrapper\dists\gradle-1.6-bin\72srdo3a5eb3bic159kar72vok\gradle-1.6-bin.zip to C:\Documents and Settings\Kiki.J.Hu\.gradle\wrapper\dists\gradle-1.6-bin\72srdo3a5eb3bic159kar72vok
...
Caused by: com.intellij.openapi.externalSystem.model.ExternalSystemException: Could not install Gradle distribution from 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.
java.util.zip.ZipException: error in opening zip file
So I know the cause: I downloaded an incomplete ZIP package.
Then I downloaded the full ZIP package from http://services.gradle.org/distributions/gradle-1.6-bin.zip manually and copied this ZIP package to:
Windows: C:\Documents and
Settings\Kiki.J.Hu\.gradle\wrapper\dists\gradle-1.6-bin\72srdo3a5eb3bic159kar72vok\
Mac OS X: ~/.gradle/wrapper/dists/gradle-1.10-all/6vpvhqu0efs1fqmqr2decq1v12/
Everything is OK now.
For OS X:
Install Homebrew as a package manager. Then on Terminal, run:
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
Install Gradle:
brew install gradle
It is the easiest way to get Gradle.
Before you click to new project, go to configure and set your proxy. I recommend set host name and port number, since I had problems with auto-detect proxy settings. Check your connection in settings.
I also had issues downloading Gradle through Android Studio.
This was my workaround:
Download Gradle directly from http://services.gradle.org/distributions/gradle-1.6-bin.zip
Copy the contents of gradle-1.6 to \Android\android-studio\plugins\gradle
Copy gradle.jar to \Android\android-studio\lib\
Restart Android Studio
Hope this helps!
Edit the gradle wrapper settings in gradle/wrapper/gradle-wrapper.properties and change gradle-1.6-bin.zip to gradle-1.8-bin.zip.
./gradle/wrapper/gradle-wrapper.properties :
#Wed Apr 10 15:27:10 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-bin.zip
It should compile without any error now.
In my case this was because the system had low memory. When I closed some applications, the error disappeared.
For me it turned out to be my firewall, which is VIPRE, was blocking the Gradle.org site and quietly causing a bad gradle-1.7-bin.zip to be created under .gradle\wrapper\dists\.
I had to open VIPRE and add gradle.org to "Bad Web Site Exceptions" (menu File -> Settings -> Firewall).
Then I downloaded http://services.gradle.org/distributions/gradle-1.7-bin.zip using a browser and overwrote the bad version. I restarted Android Studio, and all is good.
FYI, on my Mac, it was downloading Gradle into the ~/.gradle directory. You can see how it's progressing by looking there:
du ~/.gradle
I noticed that my MyProject/gradle/wrapper/gradle-wrapper.properties file was completely empty, so I deleted it and Android Studio proceeded to download whatever it needed.
After that it worked.
I tried Kiki Hu's solution, and it worked. After that, there will be more downloads from the Maven repository which includes Dalvik Debug Monitor Server (DDMS), Guava, etc., which again is not required if you are exporting from Eclipse into Android Studio.
If you're like me, you tried to start a version prior to 0.2.0. Following Google's notes
in Getting Started with Android Studio, you'll need to remove and re-install Android Studio.
"Note: There is not a patch update available from 0.1.9 to 0.2. To update from Android Studio 0.1.x to 0.2.x, you must install a new Android Studio bundle from this page. The reason for that is that we have made changes to the bundled SDK such that it includes a pre-configured local Maven repository which can serve up the v4 support library and which is required for creating new projects."
Also be aware that if you have your Android SDK files stored in C:\Program Files (x86)\Android\android-studio\sdk you should move them before the uninstall, or you'll need to download the SDK files again.
After the un-install and re-install, it is now working on my Windows 7 64-bit system.
Remove all files from C:\Documents and Settings\[User]\.gradle\wrapper\dists\, rebuild the project and rebuild your project on Android Studio. It works for me :)
I have noticed one thing: When my Android Studio is build 130.737825, it automatic downloads Gradle 1.6 to C:\Users\yourname\.gradle/wrapper/dists/gradle-1.6-bin/72srdo3a5eb3bic159kar72vok/.
However, when I update my Android Studio to build 132.821530, it automatically downloads Gradle 1.7 to C:\Users\Administrator\.gradle\wrapper\dists\gradle-1.7-bin\2g3i7gan25uopmtc0lnjb1l9ff.
I don't know if it matters.
I had this error under fresh installation of IntelliJ (14.0), the problem was that I had not specified JDK. Fix: press ctrl + A + S (project structure), and check if SDK is correct.
my error looked like this:
Error:Android Gradle Build Target: org.gradle.tooling.GradleConnectionException: Could not execute build using Gradle installation ...