I maintain a public repository A, and apply the dependency in this repository in another project B.
In Project A:
Just released the latest version 1.0.7
.
In project B:
module level build.gradle
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation 'com.xxx.jk:public-permission-handler:1.+'
}
Checked log in project B, the applied version is 1.0.7
.
Then there is an update in project A, a new version 1.0.8
is released.
Scenarios:
-
In project B, still apply
'com.xxx.jk:public-permission-handler:1.+'
,
checked log, the applied version is1.0.7
. -
In project B, apply
'com.xxx.jk:public-permission-handler:1.0.8'
, checked log, the applied version is1.0.8
.
So the issue is, although there is a newer release 1.0.8
, gradle won't dynamically fetch the latest version.
Solution:
Solution 1: Force re-fetch the dependencies within code:
resolutionStrategy.cacheDynamicVersionsFor 1, 'minutes'
android {
}
configurations.all {
resolutionStrategy.cacheDynamicVersionsFor 1, 'minutes'
}
dependencies {
}
Solution 2: Force re-fetch the dependencies within gradle command line:
./gradlew cDAT --refresh-dependencies
Refer to gradle dependency dynamic version:
Controlling dependency caching programmatically
You can fine-tune certain aspects of caching programmatically using the ResolutionStrategy for a configuration. The programmatic approach is useful if you would like to change the settings permanently.
By default, Gradle caches dynamic versions for 24 hours. To change how long Gradle will cache the resolved version for a dynamic version, use:
网友评论