gradle:Android Studio继承buildtype [英] gradle: Android Studio inherit buildtype
问题描述
我有gradle(Android Studio)4种构建类型
I have in gradle (Android Studio) 4 build types
android {
buildTypes {
release { ... }
debug { ... }
kindle { ... }
kindle_debug { ... }
}
}
我知道,对于每个构建类型,我的src
文件夹可以具有一个文件夹.因此它最终变成了
And I know, that my src
folder can have for each build type one folder. So it ends up into
src/
-- debug
-- kindle
-- kindle_debug
-- main // used for every project
-- release
目前,kindle
与release
相同,并且kindle_debug
与debug
相同.
At the moment kindle
is the same as release
and kindle_debug
is the same as debug
.
如何避免重复src文件夹?有没有办法从release
和debug
继承,或者我可以自己在build.gradle
文件中设置src文件夹?
How can I avoid to duplicate the src-folders? Is there a way to inherit from release
and debug
or have I to set the src-folders by myself in the build.gradle
file?
一种似乎可行的解决方案是设置符号链接,但是我想使用Mac OS和Windows OS,并不是每个新用户都希望自己设置符号链接.
One solution, that seems to work, is to set symlinks, but I want to use Mac OS and Windows OS and not every new user wants to set symlinks by them self.
我现在使用的是产品口味,因此,我可以进行调试/发布,并且可以使用Google,亚马逊和三星.这是达到我目的的最佳解决方案.
Edit 2: I use now product flavors, because of that, I can have debug/release and with that google, amazon and samsung. That's the best solution for my purpose.
推荐答案
您可以从以下构建类型继承:
You can inherit from build types like the following:
buildTypes {
release { ... }
debug { ... }
kindle {
initWith buildTypes.release
...
}
kindle_debug {
initWith buildTypes.debug
...
}
}
这篇关于gradle:Android Studio继承buildtype的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!