Android Studio项目版本的Java源目录未以蓝色呈现 [英] Java source directories for Android Studio project flavors not rendered in blue
问题描述
我有一个Android Gradle项目,我想创建两个风味分支.我使用具有以下结构的默认sourceSets:
I have an Android Gradle project and I want to create two flavor branches. I'm use the default sourceSets with this structure:
src
- main
- java
- package
- res
- manifest.xml
- flavor1
- java
- package
- flavor2
- java
- package
在IDE中,"main/java","flavor1/java"被渲染/注释为Java源(即,"java"为蓝色,并且目录显示为包),但是未渲染"flavor2"同样的方式.
"main/java", "flavor1/java" is rendered/annotated as Java source in the IDE (i.e., "java" is in blue, and the directories are shown as packages), but "flavor2" is not rendered the same way.
我试图清除缓存并重新启动Android Studio,但这无济于事.我该如何解决?
I tried to clear the caches and restart Android Studio but this did not help. How can I fix this?
推荐答案
默认情况下,您的主目录(内容根)源始终为蓝色,而其他源则取决于活动性.
Your main directory (content root) sources will always be blue colored by default, but others depend on the activeness.
蓝色目录显示构建变体或内容根处于活动状态,如果您将使用IDE的Run
按钮,它将使用这些源来编译和构建您的应用程序.一次只能有一个内容根可以处于活动状态以构建应用.
The blue color directory shows that the build variant or content root is active and if you will use the Run
button of IDE, it will take these sources to compile and build you app. Only one content root can be active at a time for building the app.
使用run选项时,您可以更改内容根目录并使其处于活动状态,以编译和构建应用程序.可以通过Android Studio左侧面板中的 Build Variants
标签来完成此操作.
You can change and make any directory/flavor active for your content root to compile and build your app when run option is used. It can be done from Build Variants
tab available in left panel of your Android Studio.
就像下面的图片所示:
此处的生产处于活动状态:
燕麦在这里处于活动状态:
这篇关于Android Studio项目版本的Java源目录未以蓝色呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!