android-Flatter flavor sourceSet资源未引用flavor文件夹
发布时间:2022-08-19 23:56:04 287
相关标签: # java
在我的 Flutter 移动应用程序中,有两种风格,res每种风格都有单独的文件夹。我已经sourceSet在build.gradle文件中添加了,但是在运行时运行的风味不会显示风味文件夹中的相关资源,而是main文件夹资源。
文件夹结构如下。
src
|
flavor1
------res(with sub folders)
|
flavor2
------res(with sub folders)
|
main
------res(with sub folders)
build.gradle
文件更改。
android {
sourceSets {
main {
java.srcDirs += 'src/main/kotlin'
res.srcDirs = ['src/main/res']
manifest.srcFile 'src/main/AndroidManifest.xml'
}
flavor1 {
res.srcDirs = [
'src/flavor1/res/drawable-hdpi',
'src/flavor1/res/drawable-ldpi',
'src/flavor1/res/drawable-mdpi',
'src/flavor1/res/drawable-v21',
'src/flavor1/res/drawable-xhdpi',
'src/flavor1/res/drawable-xxhdpi',
'src/flavor1/res/drawable-xxxhdpi',
'src/flavor1/res/drawable',
'src/flavor1/res/mipmap-hdpi',
'src/flavor1/res/mipmap-mdpi',
'src/flavor1/res/mipmap-xhdpi',
'src/flavor1/res/mipmap-xxhdpi',
'src/flavor1/res/mipmap-xxxhdpi',
'src/flavor1/res/raw',
'src/flavor1/res/values',
'src/flavor1/res'
]
manifest.srcFile 'src/flavor1/AndroidManifest.xml'
}
flavor2 {
res.srcDirs = [
'src/flavor2/res/drawable-hdpi',
'src/flavor2/res/drawable-ldpi',
'src/flavor2/res/drawable-mdpi',
'src/flavor2/res/drawable-v21',
'src/flavor2/res/drawable-xhdpi',
'src/flavor2/res/drawable-xxhdpi',
'src/flavor2/res/drawable-xxxhdpi',
'src/flavor2/res/drawable',
'src/flavor2/res/mipmap-hdpi',
'src/flavor2/res/mipmap-mdpi',
'src/flavor2/res/mipmap-xhdpi',
'src/flavor2/res/mipmap-xxhdpi',
'src/flavor2/res/mipmap-xxxhdpi',
'src/flavor2/res/raw',
'src/flavor2/res/values',
'src/flavor2/res'
]
manifest.srcFile 'src/flavor2/AndroidManifest.xml'
}
}
// Because of flavors and multiple res folders.
afterEvaluate {
android.applicationVariants.all { variant ->
tasks.named("generate${variant.name.capitalize()}ResValues")
.configure { task ->
task.outputs.upToDateWhen {false}
}
}
}
flavorDimensions "app"
productFlavors {
flavor1 {
dimension "app"
applicationIdSuffix ""
}
flavor2 {
dimension "app"
applicationIdSuffix ".flavor2"
}
}
}
运行flavor2
应用程序仍然指main
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报