Reputation: 101
I need to build my app against both a stock Android SDK and a custom Android SDK for a specific device with AOSP modifications.
My thought was to use product flavors in my build.gradle
to conditionally point to the correct SDK directory. Basically, I'm looking for something to the effect of:
productFlavors {
stock {
sdk.dir "/path/to/stocksdk"
}
mydevice {
sdk.dir "/path/to/customsdk"
}
}
Looking at the ProductFlavor DSL documentation, there isn't a property to set SDK directory.
What other ways could I achieve a similar result?
Upvotes: 3
Views: 972
Reputation: 33438
Interesting question but, unfortunately you cannot have different SDKs for productFlavors
or buildTypes
. You can have it only at the project level.
Product flavors can customize the following properties:
minSdkVersion targetSdkVersion versionCode versionName package name (overrides value from manifest) release signing info (keystore, key alias, passwords,...). BuildConfig: Ability to provide custom Java code. NDK ABI filter (Not implemented yet) test info package name for test app (optional, default is <base>.test) InstrumentationTestRunner class (optional) Additionally, Product Flavor can provide their own source code, resources and manifest.
And
A Build Type provides configuration for the following build properties:
manifest debuggable flag native compilation debug flag proguard enabled + specific rules (Not implemented yet) debug signing flag (ie whether to use debug key or release key) package name suffix (2) version name suffix (new in milestone 0.3) Buildconfig DEBUG flag. Set automatically based on the manifest debuggable flag. Ability to provide custom Java code.
Source (Build System Concepts on http://tools.android.com/tech-docs/)
What other ways could I achieve a similar result?
You could make this project a library project and then create wrapper projects with different SDKs, just using the functionality in the library. So now you have a separate wrapper project instead of the productFlavors
and you can change the sdk.dir
for each wrapper project in the local.properties
file.
Upvotes: 3