【发布时间】:2014-10-24 20:44:08
【问题描述】:
我已阅读官方文档以及此处的其他几个问题,无论我尝试什么,我的备用资源都不会加载。请ELI5!如果我有以下产品风味
productFlavor {
flavor1 {
applicationId "com.packagename.flavor1"
}
}
我究竟应该在我的项目层次结构中的哪里创建替代资源文件夹,以及我究竟需要如何更改我的 build.gradle 文件以便它知道在构建特定风格时查看所述位置?文档让这听起来很容易,但我整个下午都在尝试不同的变化,但没有任何运气。我误会了什么?
编辑:build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
defaultConfig {
applicationId "com.example.android"
minSdkVersion 14
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
default_flavor {
resValue "string", "build_variant", "default"
resValue "string", "app_title", "Android"
}
bengals {
applicationId "com.example.Bengals"
resValue "string", "build_variant", "bengals"
resValue "string", "app_title", "Cincinnati Bengals"
}
bills {
applicationId "com.example.Bills"
resValue "string", "build_variant", "bills"
resValue "string", "app_title", "Buffalo Bills"
}
boilermakers {
applicationId "com.example.Boilermakers"
resValue "string", "build_variant", "boilermakers"
resValue "string", "app_title", "Purdue Boilermakers"
}
cardinals {
applicationId "com.example.Cardinals"
resValue "string", "build_variant", "cardinals"
resValue "string", "app_title", "Cardinals"
}
colts {
applicationId "com.example.Colts"
resValue "string", "build_variant", "colts"
resValue "string", "app_title", "Indianapolis Colts"
}
cyclones {
applicationId "com.example.Cyclones"
resValue "string", "build_variant", "cyclones"
resValue "string", "app_title", "Cincinnati Cyclones"
}
eagles {
applicationId "com.example.Eagles"
resValue "string", "build_variant", "eagles"
resValue "string", "app_title", "Philadelphia Eagles"
}
hawkeyes {
applicationId "com.example.Hawkeyes"
resValue "string", "build_variant", "hawkeyes"
resValue "string", "app_title", "Hawkeyes"
}
hoosiers {
applicationId "com.example.Hoosiers"
resValue "string", "build_variant", "hoosiers"
resValue "string", "app_title", "Indiana Hoosiers"
}
packers {
applicationId "com.example.Packers"
resValue "string", "build_variant", "packers"
resValue "string", "app_title", "Green Bay Packers"
}
test_flavor {
applicationId "com.example.test"
resValue "string", "build_variant", "test"
resValue "string", "app_title", "Dolly Test"
}
titans {
applicationId "com.example.Titans"
resValue "string", "build_variant", "titans"
resValue "string", "app_title", "Tennessee Titans"
}
}
}
dependencies {
compile 'com.android.support:support-v4:20.0.0'
compile project(':admsAppLibrary')
compile 'com.google.android.gms:play-services:5.0.89'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':volley')
compile 'com.google.code.gson:gson:2.2.4'
compile project(':Minimogrify')
compile project(':urbanairship-lib-5.0.1')
}
AndroidManifest.xml 的相关部分:
<application android:name=".Application"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
【问题讨论】:
标签: android gradle android-gradle-plugin build.gradle