在gradle中将变量中的依赖项存储在变量中

时间:2014-07-01 23:05:25

标签: gradle android-studio android-gradle

如何在gradle构建脚本中将依赖项版本存储在变量中而不会出现Android Studio的错误?

当我这样做时:

def guavaVersion = '17.0'
compile "com.google.guava:guava:$guavaVersion"

我有:
A newer version of com.google.guava:guava than $guavaVersion is available: 17

1 个答案:

答案 0 :(得分:43)

试试这个:

ext.guavaVersion = '17.0'
compile "com.google.guava:guava:$guavaVersion"