4

I'm using Android Studio 0.2.5 with gradle 1.6. I'm collaborating with a developer of a library I'm using, so when he pushes updates to some-library:2.1.5-SNAPSHOT I'd like to get it immediately. I can disable caching for changing modules in gradle by setting the resolution strategy as follows:

configurations.all {
  resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}

This works fine for command line builds, but it looks like Android Studio is still using the old version of some-library-2.1.5-SNAPSHOT. The only workaround I've been able to get to work is to delete myproject.iml and the .idea directory and re-import into Android Studio, which is very time consuming and seems unnecessary.

4

1 回答 1

2

另一种解决方法是删除~/.gradle/caches目录,然后在 Android Studio 中同步项目。这并不理想,因为您的所有依赖项都需要重新下载,但正如@Joe 所指出的那样,将项目重新导入 AS 的侵入性要小一些。

  • 终端:rm -rf ~/.gradle/caches
  • AS:Tools > Android > Sync Project with Gradle Files(或点击“Sync Project with Gradle Files”菜单按钮)

    编辑
    做了一些更多的研究,发现了这个小宝石
    只需像这样配置您的依赖项...

    compile ('groupId:artifactId:X.X.X-SNAPSHOT'){
        changing=true
    }
    

    然后只需gradle clean assemble在具有 SNAPSHOT 依赖项的项目上运行。

    我确实测试了一个新添加的常量是否可用,果然它起作用了。

  • 于 2014-03-19T18:27:29.420 回答