Android 工作室获取旧工件

Android Studio fetching an old artifact

我正在使用 Android Studio 下载内部 Maven 存储库中可用的工件。有时 Android Studio 无法获取导致编译错误的最新快照。这个问题有解决办法吗?

来自 http://forums.gradle.org/gradle/topics/how_to_get_gradle_to_download_newer_snapshots_to_gradle_cache_when_using_an_ivy_repository 的 Gradle 论坛:

Since SNAPSHOTs are a Maven concept, they aren't treated as anything special in an 'ivy' repository. Unfortunately, there's not (yet) any way to specify a custom pattern for a 'maven' repository, so you're a bit stuck.

The best way to tell Gradle to check for updated versions of a dependency is to flag the dependency as 'changing'. Gradle will then check for updates every 24 hours, but this can be configured using the resolutionStrategy DSL.

configurations.all {
    // check for updates every build
    resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
dependencies {
    compile group: "group", name: "projectA", version: "1.1-SNAPSHOT", changing: true
}

您可以使用 Invalidate Caches / Restart 命令使 Android Studio 刷新其工件,该命令位于 File 菜单。我第一次在 Android Studio 3.2.1 上使用这个命令。它也可能存在于旧版本中。

我在加载新版本的外部库(AAR 文件)作为模块后使用它,如果 类 或方法已添加或更改。