Reputation: 1535
Specifically an Android project?
Upvotes: 0
Views: 5792
Reputation: 2326
If you want to define variable in project level dependancy build.gradle(Project:NameOfYourProject) then you can define variables in ext
.
like :
ext {
vCode = 340
vName = "v3.4.0"
}
and if you want to define variable in app level dependancy build.gradle(Module:app) then you can use def
for variable declaration.
Like :
def CHAT_BUCKET_NAME = '"' + CHAT_BUCKET_NAME + '"' ?: '"'
Example :
Use it like : Use variable
Upvotes: 3
Reputation: 1535
In the top most build.gradle
define any variables you want inside of ext{}
ext{
my_version = "16.0.0"
}
And then use it in sub folder .gradle files automatically (Android Studio) with
implementation "com.google.android.gms:play-services-analytics:$my_version"
Upvotes: 3