问题描述
我使用的是标准的Android Studio目录结构,并且创建了不同的构建类型:
I'm using a standard Android Studio directory structure and I created different build types:
buildTypes {
debug {
runProguard false
packageNameSuffix ".debug"
signingConfig signingConfigs.debug
}
preview.initWith(buildTypes.debug)
preview {
packageNameSuffix ".preview"
}
release {
runProguard false
signingConfig signingConfigs.release
}
}
一切正常,但是AS无法识别所有源文件夹.仅将main
和debug
下的文件夹标记为源,将preview
和release
下的文件夹显示为普通文件夹实际上,这些文件夹中没有错误检查
everything compiles fine, but AS doesnt recognize all of the source folders.Only folders under main
and debug
are marked as source, folders under preview
and release
are displayed as normal foldersIn effect there is no error checking in those folders
我检查了.iml文件,并且未添加sourceFolder标记.
I checked the .iml file and sourceFolder tags were not added.
如果我手动编辑项目iml文件,请添加以下行:
If I edit the project iml file manually adding the lines:
<sourceFolder url="file://$MODULE_DIR$/src/preview/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/preview/res" type="java-resource" />
似乎工作正常.
...直到我与gradle文件同步-删除了上面的行.
...until I sync with my gradle file - which removes the above lines.
这是gradle插件中的错误,还是我做错了什么?
Is this a bug in gradle plugin, or am I doing something wrong?
推荐答案
您必须在构建变体列表中进行切换,然后AS会选择适当的源集.
You have to switch it in the build variants list, then AS will pick up the appropriate source sets.
这篇关于Android Studio无法识别源文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!