我如何告诉gradle从存储库中重新下载依赖项?
当前回答
有两种方法:
使用命令行选项刷新依赖项现金。 您可以删除本地缓存,其中artefast是由Gradle和触发构建缓存
使用——refresh-dependencies选项:
./gradlew build --refresh-dependencies
简单解释——refresh-dependencies选项告诉Gradle忽略已解析模块和工件的所有缓存条目。
长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: [{}, {}]”.
使用删除: 当你删除缓存
rm -rf $HOME/.gradle/caches/
你只需要清理所有缓存的jar和sha1和,Gradle在你的机器上没有工件的情况下,必须下载所有东西。是的,第一次它将100%工作,但是当另一个快照被释放并且它是依赖树的一部分时,您将再次面临刷新或清除缓存的选择。
其他回答
这对我很管用。 通过取消文件>设置>Gradle>离线工作按钮,确保Gradle没有被设置为离线。
将其添加到构建的顶层。Gradle,很高兴有上面的依赖
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
我确保我的依赖是这样写的:
implementation('com.github.juanmendez:ThatDependency:ThatBranch-SNAPSHOT') {
changing = true
}
之后,我打开Android Studio中的Gradle面板,点击蓝色圆圈箭头按钮。我总是能看到我的更新得到一个新的新鲜副本。
以上的解决方案对我都不起作用。
如果你使用IntelliJ,解决这个问题的方法就是简单地刷新所有Gradle项目:
对于Windows……为了让gradle重新下载特定的依赖项:
从下面的目录中删除要重新下载的依赖项: C:\Users\ %用户名% \模块2 \ \ .gradle \缓存文件- 2.1 删除该路径下的所有元数据目录: C:\Users\ %用户名% \模块2 \ \ .gradle \缓存元数据- * 在项目的根目录下运行gradle build(如果使用gradle wrapper,则运行gradlew build)。
注意:上述文件路径中的数字可能与您不同。
我太迟了,但是我的解决方案是单一的存储库。我认为删除~/。Gradle /*是多余的。 我遇到的问题是,我正在删除目录的源代码和gradle正在获得另一个版本,而不是从nexus。 为了避免这种情况,我运行下一个:
~/.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
之后,gradle从nexus拖拽文件。
有两种方法:
使用命令行选项刷新依赖项现金。 您可以删除本地缓存,其中artefast是由Gradle和触发构建缓存
使用——refresh-dependencies选项:
./gradlew build --refresh-dependencies
简单解释——refresh-dependencies选项告诉Gradle忽略已解析模块和工件的所有缓存条目。
长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: [{}, {}]”.
使用删除: 当你删除缓存
rm -rf $HOME/.gradle/caches/
你只需要清理所有缓存的jar和sha1和,Gradle在你的机器上没有工件的情况下,必须下载所有东西。是的,第一次它将100%工作,但是当另一个快照被释放并且它是依赖树的一部分时,您将再次面临刷新或清除缓存的选择。
推荐文章
- Android Studio突然无法解析符号
- 没有找到Gradlew命令?
- 无法找到com.google.android.gms:play-services:3.1.59 3.2.25 4.0.30 4.1.32 4.2.40 4.2.42 4.3.23 4.4.52 5.0.77 5.0.89 5.2.08 6.1.11 6.1.71 6.5.87
- .dex文件中方法引用的数量不能超过64k API 17
- 我如何解决错误“minCompileSdk(31)指定在一个依赖的AAR元数据”在本机Java或Kotlin?
- Android工作室如何运行gradle同步手动?
- Android Studio在创建新项目时卡住了Gradle下载
- 无法解析符号“AppCompatActivity”
- 在Mac OS X上安装/升级gradle
- 错误:执行失败的任务':app:compileDebugKotlin'。>编译错误。详细信息请参见日志
- Android Studio 3.0口味维度问题
- 如何设置gradle家同时导入现有的项目在Android工作室
- 执行com.android.build.gradle.internal.tasks时失败
- 错误:与依赖项“com.google.code.findbugs:jsr305”冲突
- 如何/何时生成Gradle包装文件?