我需要针对特定设备的原生 Android SDK 和自定义 Android SDK 构建我的应用程序并修改 AOSP。
我的想法是在我的 build.gradle
中使用产品风格来有条件地指向正确的 SDK 目录。基本上,我正在寻找具有以下效果的东西:
productFlavors {
stock {
sdk.dir "/path/to/stocksdk"
}
mydevice {
sdk.dir "/path/to/customsdk"
}
}
查看 ProductFlavor DSL 文档,没有设置 SDK 目录的属性。
还有哪些其他方法可以达到类似的结果?
最佳答案
有趣的问题,但遗憾的是,您不能为 productFlavors
或 buildTypes
使用不同的 SDK。您只能在项目级别拥有它。
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.
和
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?
您可以将此项目设为库项目,然后使用不同的 SDK 创建包装器项目,只需使用库中的功能即可。所以现在你有一个单独的包装器项目而不是 productFlavors
,你可以在 local.properties
中为每个包装器项目更改 sdk.dir
文件。
关于android - 为每种产品风格使用不同的 Android SDK(库存和定制),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34949613/