[英]How to build flavor?
I have a gradle.build which works fine for main goal. 我有一个gradle.build,可以很好地完成主要目标。 I would like to add flavor for skinning version.
我想为皮肤版添加味道。 I have add them into gradle build but I don't understand where I should put another version of files, in which folder and what name it should be?
我已将它们添加到gradle构建中,但我不明白我应该在哪里放置另一个版本的文件,在哪个文件夹中它应该是什么名称? Lets consider an example: main package is com.example.app with project structure common to android app (I do it in sourceSets).
让我们考虑一个例子:主包是com.example.app,具有android app常见的项目结构(我在sourceSets中做)。 As I understand I should create folder (not a set of sub folders) com.example.app.flavor and put in \\res which already contains files for main project but it doesn;t work when I build assembleFlavorDebug -- apk is built but it contains the main app but doesnt have a changes in flavor
据我所知,我应该创建文件夹(不是一组子文件夹)com.example.app.flavor并放入\\ res已经包含主项目的文件,但它没有;当我构建assembleFlavorDebug时工作 - 建立了apk但是它包含主应用程序,但没有风味的变化
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile 'commons-io:commons-io:2.4'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
compile 'com.android.support:support-v4:18.0.+'
compile 'com.google.android.gms:play-services:3.2.+@aar'
compile project(':ViewPagerIndicator')
compile project(':AndroidHorizontalListView')
}
android {
compileSdkVersion 18
buildToolsVersion "18.1.0"
productFlavors {
app {
packageName="com.example.app"
}
flavor {
packageName="com.example.app.flavor"
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
signingConfigs {
debug {
storeFile file('../debug.keystore')
}
}
You should create a subfolder named flavor
under src
. 您应该在
src
下创建一个名为flavor
的子文件夹。 The structure of the flavor
subfolder is identical to the structure of main
: flavor
子文件夹的结构与main
的结构相同:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.