Related
I'm having an issue with running a test suite through Jenkins and I can't figure out why it's failing.
My job is set up with maven and according to others, maven is set up on the jenkins server (I don't have permission to check myself). The job is set to run on a specific node using labels (can't check the settings on the labels myself either).
This is the error I get when I run (more or less).
Running as SYSTEM
Installer "Extract *.zip/*.tar.gz" cannot be used to install "mvn.3.5.2" on the node "SELECTEDNODE"
[EnvInject] - Loading node environment variables.
Building remotely on SELECTEDNODE in workspace E:...
Installer "Extract *.zip/*.tar.gz" cannot be used to install "mvn.3.5.2" on the node "SELECTEDNODE"
using credential ABCD
Installer "Extract *.zip/*.tar.gz" cannot be used to install "mvn.3.5.2" on the node "SELECTEDNODE"
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
...
...
Installer "Extract *.zip/*.tar.gz" cannot be used to install "mvn.3.5.2" on the node "SELECTEDNODE"
Installer "Extract *.zip/*.tar.gz" cannot be used to install "mvn.3.5.2" on the node "SELECTEDNODE"
ERROR: Maven Home null doesnt exist
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
Finished: FAILURE
This message keeps repeating
Installer "Extract *.zip/*.tar.gz" cannot be used to install "mvn.3.5.2" on the node "SELECTEDNODE" even though I have this version of maven installed on the selected node (I do not know if this version is on the Jenkins server, just that a maven version is on the server. I am assuming it is the correct version as I mentioned it needed to be this version and have not heard otherwise). Is this what is causing the issue?
There are usually 2 ways to get maven installed for you build. One is on the node server itself and define that maven path in the jenkins node configuration and the other way is to have the maven automatically installed from internet which appears to be the case in your case..when you have multiple maven defined you need to specifically select the maven for your job.
Installed clean windows10(1607) and intellij idea(2020.1.2 community edition). When i create new gradle project
Invalid Gradle JDK configuration found. Open Gradle Settings
"gradle-wrapper.properties not found".
How can I fix it?
Install gradle 6.7
sdk install gradle 6.7
brew install gradle
Go to IntelliJ and set gradle version:
On File >> Settings >> Build, Execution , Deployment >> Gradle
or
Preferences >> Gradle
In Use Gradke from specific the correct location
If IDEA is set to use the Gradle wrapper (as it is in your screenshot: "Use Gradle from:" is set to "gradle-wrapper.properties"), IDEA expects the following file structure:
Gradle wrapper JAR: [project root]/gradle/wrapper/gradle-wrapper.jar
Gradle wrapper properties: [project root]/gradle/wrapper/gradle-wrapper.properties
Gradle wrapper script: [project root]/gradlew.bat
If you are missing one of these three elements, IDEA will attempt to generate the wrapper by calling the gradle wrapper task. It will do this using the Gradle JDK, which may or may not be the project SDK (File > Settings > Build, Execution, Deployment > Build Tools > Gradle > Gradle JVM).
I'm not sure how it selects the version of Gradle it uses - I only have 6.8.3 installed on my machine, and I had my wrapper properties set to 7.0-rc-1, yet somehow it used 6.7.0 when generating the wrapper.
I tried various options for clearing the cache, but did not get the result.
Openjdk-14 installed by default and does not work. From site adoptopenjdk.net install OpenJDK 11 (LTS). When creating the project, I chose 11 version. Then the program suggested updating gradle to version 6 and it worked.
I ran into this problem a while ago when I upgraded to intellij 2020.* The first time I created a new project there was no problem: gradle daemon did its work and the project was created with no problems.
In my case, the project would start a new gradle daemon, and attempt to build the project, would get rejected by windows Security, and nothing would happen, so intellij goes ahead and starts another (unsuccessful) daemon. Soon, I had 20+ gradle daemon processes running on my system, all of them doing nothing.
So, it looks like intellij has messed in enabling that it places the appropriate permissions it requires for these folders that it depends on to run properly. So, you need to manually give these permissions, and then things (should) work.
The real issue here is security on your machine: either a virus checker or the security software, Windows Security on Windows 10, for example. The first time you make a project, Intellij goes and produces a number of folders that they need access to.
However, once these folders are available, for whatever, intellij doesn't make sure to give itself access.
On windows 10, in AppData, you'll find several folders required by Intellij to produce, in my case, produce gradle projects.
Try finding the various folders that Intellij has produced on your system, and give them exceptions on your virus checker and on whatever firewall/security software programs that may block access.
I have the latest Android Studio IDE installed on my Windows 10 laptop, and it was working fine until my windows operating system made a huge automatic update.
Now, when start my Android Studio IDE, I get the following error and it doesn't build.
Gradle sync failed: Read timed out Consult IDE log for more details
(Help | Show Log) (3m 34s 195ms)
I need help on this.
I encounter this error "Read Time Out", and I simply choose menu item: File -> Invalidate Caches / Restart... to fixed it.
[UPDATE]
I just encounter this error for second time, this time Invalidate Caches / Restart... not able to fix it, but then I try close the android Studio, killall -9 java to ensure all java process has been terminated, then relaunch Android Studio, no more error.
[UPDATE 2]
I just encounter this error and I fixed it by replug the phone cable and rerun.
I got around this issue by turning on Offline Mode in the Gradle tool window.
I have just synced the Project with Gradle files and it worked
Editing global gradle.properties with the following line was the fix for me:
org.gradle.jvmargs=-Dorg.gradle.internal.http.connectionTimeout=120000 -Dorg.gradle.internal.http.socketTimeout=120000
For Chinese users who often use a proxy to download dependency jars, the cause is often proxy settings.
We should check multiple places if the proxy is correctly configured.
Android Studio Settings - Appearance & Behavior - System Settings - HTTP Proxy
${project_root}/gradle.properties
~/.gradle/gradle.properties
In my case, I somehow once configured an HTTP proxy in ~/.gradle/gradle.properties, which was forgotten later. Then when I dealt with a SOCKS5 proxy in IDE Settings and project-level gradle.properties, things always run into trouble. Finally, deleting invalid proxy settings in ~/.gradle/gradle.properties save my day.
I fixed the error by inserting following lines in gradle.properties:
systemProp.org.gradle.internal.http.connectionTimeout=180000
systemProp.org.gradle.internal.http.socketTimeout=180000
This sets the Gradle's connection timeout from the default 30s to 180s (3m).
In my case the read timeout occurred because my computer is behind a HTTP proxy, and it failed to timely connect to http://jcenter.bintray.com.
For more info about the Gradle options, you can refer to https://github.com/gradle/gradle/issues/3370
Simple Answer:
Check the Internet Connection - it should not fluctuate while building the project
File-->>Sync Project with Gradle File
Build>> Clean Project Or Rebuild Project.
I just removed
include ':app'
from setting.gradle and then sync project
it will fails again
then write it back an re-sync and then error gone and will start downloading.
Here's what worked for me (on Windows):
From C:\Users\{$user}\.gradle
Delete these 3 folders:
caches
daemon
wrapper
Then restart Android Studio and Gradle should start downloading automatically
None of the answer worked for me.
I solved it by
Delete project>.gradle directory
File>Sync Project with Gradle Files
In my case it was due to Jitpack.io server down, causing my project unable to build. So I just enabled the Offline Mode for gradle to continue developing my project while Jitpack.io is resolving their server issue.
You will see more info when you click "build" on top of the "read time out" message in build output. In my case, it was a facebook dependency issue so I just had to upgrade it to a newer version.
In my case, it was a firewall issue. After adding Android Studio to its whitelist everything is working fine.
A simple Clean Project + Rebuild Project worked for me
I resumed working on my project after a long time and I was using an Old version of navigation dependency.
after updating version to versions.navigation = "2.3.0" from versions.navigation = "2.3.0-aplha01" my issue was resolved.
so in short make sure you are using latest version of gradle and all libraries (compatible with your gradle version).
Above fixes didn't work for me on MacOS Big Sur 11.5.1 after updating to the new version of Arctic Fox 2020.3.1 Patch 3.
My issue with this was resolved by doing the following:
Close your Android project
Navigate to the root folder of you project
Remove the '.gradle' and '.idea' folders
Start your Android project, which will start the build process. Let this finish
Now the build should succeed. If not, also do an 'Invalidate caches/restart'
In my case, this error was showing up while I am trying to create a new project,
and the default Kotlin Gradle plugin API version was the culprit,
While building/Gradle sync I noticed that the sync process is always getting stuck at the downloading kotlin.gradle.plugin.api:1.5.21,
So I searched for 1.5.21 in the build.gradle and updated it to the latest version, and it worked.
Just Simple Step and you Got Solution.
Android Studio -> FILE -> Invalid Caches / Restart -> Invalidate and Restart
Done Keep Code ☻♥
In my case, Android Studio Arctic Fox | 2020.3.1 Patch 4 (Windows)
I have try 3 step/solution;
Delete 2 root folder .gradle & .idea but still give 'Read timeout'
Invalid Caches/Restart also resulted 'Read timeout'
Close Android Studio, repeat solution 1, monitor 'Build Output' log, then choose 'Disable gradle offline..." , wait and let Android Studio do its thing, then on the log Build showed "BUILD SUCCESSFUL in 28s". Then, I try to run the app just to check and my apps still work as usual.
*Remark: This case happened might be because of my Android Studio IDE Version outdated. As for now, latest version is Android Studio Dolphin | 2021.3.1 Patch 1 .
This error got due to the internet connection during gradles files connection interrupts.
I tried the following techniques but unfortunately, didn't get any solution.
File->Invalidate Cache.
File->Sync Project with .gradle files
Delete Project .gradle and .idea files.
I got the solution to update gradle-wrapper.properties 6.8 to 7.1 after successfully sync revert back from 7.1 to 6.8
#distributionUrl=https://services.gradle.org/distributions/gradle-7.1-bin.zip
distributionUrl=https://services.gradle.org/distributions/gradle-6.8-bin.zip
Use the following code in gradle.properties :
systemProp.http.proxyHost=www.somehost.org
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=userid
systemProp.http.proxyPassword=password
systemProp.http.nonProxyHosts=*.nonproxyrepos.com|localhost
org.gradle.daemon=false
I have created a Smart Device CAB Deployment Project and contains dependencies eg: Test.dll.
Where Test is a seperate class library. I have created a build definition for this solution(contains Test Proj + CAB deployment Proj). When i trigger queue new build for this definition Test.dll is not getting updated in CAB deployment project in Build Agent folder of TFS Server.
PLease let me know how can i reload this dependencies on checking in / queuing new build.
Thanks in advance
Check your Workspace option on Process tab. It should be All or Outputs if you wish to have always fresh version. None option is for incremental builds. If your project is really small "All" is the best option for you.
All - erase entire workspace and download and build everything again
Outputs - like All but only output bin folders are erased and new
version is downloaded (get latest version) from source control.
(incremental get) (like Rebuild (cleen + build) in your solution)
None - sources are build incrementally. Like Get latest version +
Build command in VS
How can I tell gradle to redownload dependencies from repositories?
Generally, you can refresh dependencies in your cache with the command line option --refresh-dependencies. You can also delete the cached files under ~/.gradle/caches. With the next build Gradle would attempt to download them again.
What is your specific use case? Do you use dynamic dependency versions or SNAPSHOT versions?
On Unix systems, you can delete all the existing artifacts (artifacts and metadata) Gradle has downloaded using:
rm -rf $HOME/.gradle/caches/
Note that --refresh-dependencies won't always re-download every artifact; it will use existing copies if they match what exists in the repository. From the Gradle User Guide, refreshing dependencies:
The --refresh-dependencies option tells Gradle to ignore all cached entries for resolved modules and artifacts. A fresh resolve will be performed against all configured repositories, with dynamic versions recalculated, modules refreshed, and artifacts downloaded. However, where possible Gradle will check if the previously downloaded artifacts are valid before downloading again. This is done by comparing published SHA1 values in the repository with the SHA1 values for existing downloaded artifacts.
[...]
It’s a common misconception to think that using --refresh-dependencies will force download of dependencies. This is not the case: Gradle will only perform what is strictly required to refresh the dynamic dependencies. This may involve downloading new listing or metadata files, or even artifacts, but if nothing changed, the impact is minimal.
If you are using a recent version of Gradle, you can use --refresh-dependencies option.
./gradlew build --refresh-dependencies
you can refer to the Gradle manual.
The --refresh-dependencies option tells Gradle to ignore all cached entries for resolved modules and artifacts. A fresh resolve will be performed against all configured repositories, with dynamic versions recalculated, modules refreshed, and artifacts downloaded.
You can tell Gradle to re-download some dependencies in the build script by flagging the dependency as 'changing'. Gradle will then check for updates every 24 hours, but this can be configured using the resolutionStrategy DSL. I find it useful to use this for for SNAPSHOT or NIGHTLY builds.
configurations.all {
// Check for updates every build
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
Expanded:
dependencies {
implementation group: "group", name: "projectA", version: "1.1-SNAPSHOT", changing: true
}
Condensed:
implementation('group:projectA:1.1-SNAPSHOT') { changing = true }
I found this solution at this forum thread.
For MAC
./gradlew build --refresh-dependencies
For Windows
gradlew build --refresh-dependencies
Can also try gradlew assembleDevelopmentDebug --refresh-dependencies
For Windows...in order to make gradle re-download specific dependencies:
delete the dependencies you want to re-download from the directory below:
C:\Users\%USERNAME%\.gradle\caches\modules-2\files-2.1
delete all metadata directories at the path:
C:\Users\%USERNAME%\.gradle\caches\modules-2\metadata-*
run gradle build (or gradlew build if using gradle wrapper) in the project's root directory.
note: the numbers in the file paths above might be different for you.
None of the solutions above worked for me.
If you use IntelliJ, what resolved it for me was simply refreshing all Gradle projects:
One can remove folder with cached jars.
In my case, on Mac the library was cached at path:
/Users/MY_NAME/.gradle/caches/modules-2/files-2.1/cached-library-to-remove
I removed the cached library folder ("cached-library-to-remove" in above example), deleted the build folder of my project and compiled again.
Fresh library was downloaded then.
To refresh cached 'release' version the only option is to clear local cache.
rm -rf $HOME/.gradle/caches/
To refresh cached 'snapshot' version you can:
./gradlew build --refresh-dependencies
For those who are wondering where to run gradle commands:
Open Android Studio
Click on Terminal(You will find it in the base of Android Studio)
The command tool will open
Type your command gradlew build --refresh-dependencies
Instead of removing your entire gradle cache, like some answers here are suggesting, you can delete the cache for a specific group or artifact id. I added the following function to my .bash_profile:
deleteGradleCache() {
local id=$1
if [ -z "$id" ]; then
echo "Please provide an group or artifact id to delete"
return 1
fi
find ~/.gradle/caches/ -type d -name "$id" -prune -exec rm -rf "{}" \; -print
}
Usage:
$ deleteGradleCache com.android.support
Then, on the next build or if you resync, gradle will re-download dependencies.
There is 2 ways to do that:
Using command line option to refresh dependenices cashe.
You can delete local cache where artefasts are caches by Gradle and trigger build
Using --refresh-dependencies option:
./gradlew build --refresh-dependencies
Short explanation --refresh-dependencies option tells Gradle to ignore all cached entries for resolved modules and artifacts.
Long explanantion
WIth –refresh-dependencies’ Gradle will always hit the remote server to check for updated artifacts: however, Gradle will avoid downloading a file where the same file already exists in the cache.
First Gradle will make a HEAD request and check if the server reports the file as unchanged since last time (if the ‘content-length’ and ‘last-modified’ are unchanged). In this case you’ll get the message: "Cached resource is up-to-date (lastModified: {})."
Next Gradle will determine the remote checksum if possible (either from the HEAD request or by downloading a ‘.sha1’ file)..
If this checksum matches another file already downloaded (from any repository), then Gradle will simply copy the file in the cache,
rather than re-downloading. In this case you’ll get the message: "“Found locally available resource with matching checksum: [{}, {}]”.
Using delete:
When you delete caches
rm -rf $HOME/.gradle/caches/
You just clean all the cached jars and sha1 sums and Gradle is in situation where there is no artifacts on your machine and has to download everything. Yes it will work 100% for the first time, but when another SNAPSHOT is released and it is part of your dependency tree you will be faced again in front of the choice to refresh or to purge the caches.
For Android Studio 3.4.1
Simply open the gradle tab (can be located on the right) and right-click on the parent in the list (should be called "Android"), then select "Refresh dependencies".
This should resolve your issue.
Seems change is changed to isChange for gradle version 6.3, kotlin version 1.3.70, Groovy 2.5.10
The working configuration is
implementation("com.sample:commons:1.0.0-SNAPSHOT") {
isChanging = true
}
Also, run this command to fetch the latest
./gradlew assemble --refresh-dependencies
This worked for me.
Make sure Gradle is not set to offline by unchecking button at File>Settings>Gradle>Offline Work.
Add this to the top level of your build.gradle, nice to have above dependencies
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
I made sure my dependencies are written like this:
implementation('com.github.juanmendez:ThatDependency:ThatBranch-SNAPSHOT') {
changing = true
}
Thereafter, I open the Gradle panel in Android Studio and click the blue circle arrows button. I can always see my updates getting a new fresh copy.
If you are using Intellij, you can right click the root project and then select refresh gradle dependencies.
Mb I'm too late however my solution is for single repository. I think deleting ~/.gradle/* is overkill.
The problmem I've bumped into was that I was deleting directory where sources were and gradle was getting another version not from nexus.
To avoid that I run the next:
~/.gradle$ find . -type d -name 'group.plugins.awssdk'
./caches/modules-2/files-2.1/group.plugins.awssdk
./caches/modules-2/metadata-2.23/descriptors/group.plugins.awssdk
~/.gradle$ rm -r ./caches/modules-2/files-2.1/group.plugins.awssdk ./caches/modules-2/metadata-2.23/descriptors/group.plugins.awssdk
After that gradle is dragging files from nexus.
In my case none of the above worked, what I did was:
In build.gradle, commenting the dependencies related to the unresolved imports I had
Clicking "Sync Now"
Uncommenting what I just commented
Clicking "Sync Now" again
Then my imports were properly resolved again.
Deleting all the caches makes download all the dependacies again. so it take so long time and it is boring thing wait again again to re download all the dependancies.
How ever i could be able to resolve this below way.
Just delete groups which need to be refreshed.
Ex : if we want to refresh com.user.test group
rm -fr ~/.gradle/caches/modules-2/files-2.1/com.user.test/
then remove dependency from build.gradle and re add it.
then it will refresh dependencies what we want.
I think gradle 2.14.1 fixes the issue. The accepted answer is correct, but there is a bug in gradle with –refresh-dependencies. 2.14.1 fixes that.
See https://discuss.gradle.org/t/refresh-dependencies-should-use-cachechangingmodulesfor-0s/556
For the majority of cases, just simply re-building the project should do the trick. Sometimes you have to run ./gradlew build --refresh-dependencies as several answers have already mentioned (takes a long time, depending on how much dependencies you have). How ever, sometimes none of those will work: the dependency just won't get updated. Then, you can do this:
Remove dependency from your gradle file
Run / debug your project and wait for it to fail (with NonExistingClass reason)
Hit "build project" and wait for it to finish successfully
Run / debug once again
This is ridiculous and seems like madness, but I actually do use this procedure daily, simply because the dependency I need can be updated dozens of times and none of adequate solutions would have any effect.
If you are using eclipse and if you want force eclipse to re load dependencies you could try below command
gradlew clean cleaneclipse build eclipse --refresh-dependencies
Only a manual deletion of the specific dependency in the cache folder works... an artifactory built by a colleague in enterprise repo.
You can do it like this
https://marschall.github.io/2017/04/17/disabling-gradle-cache.html
To quote from Disabling the Gradle Build Cache
The Gradle build cache may be a great thing when you’re regularly building >large projects with Gradle. However when only occasionally building open source >projects it can quickly become large.
To disable the Gradle build cache add the following line to ~/.gradle/gradle.properties
org.gradle.caching=false
You can clean the existing cache with
rm -rf $HOME/.gradle/caches/
rm -rf $HOME/.gradle/wrapper/
delete this directory:
C:\Users\[username]\.gradle
You need to redownload it, so you can either manually download and replace the corrupted file and again sync your project . Go to this location
C:\users[username].gradle\wrapper\dist\gradle3.3-all\55gk2rcmfc6p2dg9u9ohc3hw9\gradle-3.3-all.zip
Here delete gradle3.3allzip and replace it by downloading again from this site
https://services.gradle.org/distributions/
Find the same file and download and paste it to that location
Then sync your project.
Hope it works for you too.