Open jakubkrolewski opened 9 years ago
That's a known issue already. (https://github.com/JakeWharton/sdk-manager-plugin/issues/10, https://github.com/JakeWharton/sdk-manager-plugin/issues/47)
This is due to the way gradle resolves dependency scope before any task is ever run and don't update it later.
Use next workaround:
./gradlew clean --continue
./gradlew clean assemble
Any idea how I could do this on Jenkins? @jakubkrolewski like you said, looks like it is downloading the dependencies but failing for some reason. Everytime i build it tries to download the dependencies and then fails with the error - failed to find target android-22 : /usr/local/android-sdk
Same error here with circleci
@plastiv That workaround doesn't seem to work, and it still fails a Jenkins build.
+1
I witnessed this today. There are 3 identical tickets so this appears to be an oft-reported, high priority issue. @plastiv: you seem to understand this from the Gradle perspective. Can you give as much detail about the cause as you can? I will reach out to the Gradle team and see if we can build a work-around.
@ncalexan My best guess is that due to code
def findDependenciesWithGroup(String group) {
def deps = []
for (Configuration configuration : project.configurations) {
for (Dependency dependency : configuration.dependencies) {
if (group.equals(dependency.group)) {
deps.add dependency
}
}
}
return deps
}
from here https://github.com/JakeWharton/sdk-manager-plugin/blob/master/src/main/groovy/com/jakewharton/sdkmanager/internal/PackageResolver.groovy#L271-L274 where sdk-manager-plugin scans project dependencies to find support libraries it also triggers gradle to resolve configuration. Because of support lib isn't downloaded yet at that point and because of gradle caches resolved configuration then project sees unresolved dependencies (even though they are downloaded).
Unfortunately, I don't see an api to skip cache and force to resolve dependencies again after downloading. https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.Configuration.html#org.gradle.api.artifacts.Configuration:resolvedConfiguration If you know how to trigger it, maybe a fix for this issue.
I was having the same issue. The workaround I did was to add
./gradlew -refresh-dependencies
before
./gradlew clean assembleDebug -PdisablePreDex
Depending on your set up, doing "-refresh-dependencies" every time takes long time and might not be an acceptable workaround.
"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." quoted from Gradle manual.
I suspect that ./gradlew --refresh-dependencies
works in the same way that adding any extra ./gradlew
invocation works. In other words, I doubt it works any better than:
./gradlew clean || true
./gradlew assembleDebug
or
./gradlew dependencies || true
./gradlew clean assembleDebug
What's interesting, the SDK was actually downloaded correctly, so after running the build again nothing was missing any more and the build succeed.