Android Studio 项目风格的 Java 源目录未呈现为蓝色 [英] Java source directories for Android Studio project flavors not rendered in blue

查看:40
本文介绍了Android Studio 项目风格的 Java 源目录未呈现为蓝色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 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

main/java"、flavor1/java"在IDE中被渲染/注释为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.

当使用运行选项时,您可以更改并激活任何目录/风格,以便您的内容根目录编译和构建您的应用程序.可以从 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.

如下图所示:

生产活动在此进行:

uat 在此处处于活动状态:

这篇关于Android Studio 项目风格的 Java 源目录未呈现为蓝色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆