Reputation: 2071
I'm using Android Studio to handle compiling/building my EvolveSMS themes. However, I've recently started making minor changes to a theme, and I want a way to keep it under the same project, but still have access to build the standard theme.
If that's not clear, let me give an example.
I have Theme A. I change the color of something in Theme A. It's a minor change, but I want to keep versions of both A and newly created B so I can build both of them. However, I don't want to create an entirely new project for B, because it's such a minor change.
Is there anyway to do this?
Upvotes: 0
Views: 69
Reputation:
You need the Gradle feature named "flavours". They allow you to overlay code and properties on a "base".
android {
...
defaultConfig {
minSdkVersion 8
versionCode 10
}
productFlavors {
flavor1 {
packageName "com.example.flavor1"
versionCode 20
}
flavor2 {
packageName "com.example.flavor2"
minSdkVersion 14
}
}
}
The above code sample (build.gradle
) would create two flavours.
flavor1
minSdkVersion 8
packageName "com.example.flavor1"
versionCode 20
and
android.sourceSets.flavor1
android.sourceSets.flavor1Release
android.sourceSets.flavor1Debug
android.sourceSets.androidTestFlavor1
and
flavor1Compile
flavor1Test
flavor2
versionCode 10
packageName "com.example.flavor2"
minSdkVersion 14
and etc…
android.sourceSets
defines source sets (who'da thunk it?)
android.sourceSets.main → src/main android.sourceSets.flavor1 → src/flavor1
Let us say that one theme has dependencies on a library…
dependencies {
flavor1Compile "..."
}
See the official Android Studio guide here:
http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Product-flavors.
See the official Gradle guide here: http://www.gradle.org/docs/current/userguide/nativeBinaries.html#flavors
Upvotes: 1