【发布时间】:2020-10-22 22:00:17
【问题描述】:
我在 Android Studio (4.0.1) 中签出了一个 Android 项目。 build.gradle 包含以下 sourceSets 块(如下所示的 sn-p)。这是为了防止某些值资源文件包含在打包的 aar 中(我只想在 aar 中包含 values-en-rUS 和 values-es-rUS)。
aar 被正确打包,并且只包含 values-en-rUS 和 values-es-rUS,正如预期的那样。
sourceSets {
main {
def resSrc = fileTree(dir: 'src/main/res').matching { exclude { details ->
(!details.file.canonicalPath.matches('.*values-(en|es)-rUS.*')
&& details.file.canonicalPath.matches('.*values-.*'))
} }
...
res.srcDirs = [ resSrc ]
...
}
}
However, Android Studio does not show me the res directory (the entire directory!) anymore in the "Project" sidebar when "Android" is selected, and the Java code files can no longer resolve the ids or layouts (例如findViewById(R.id.bottom_sheet_layout) -- 它们显示为红色波浪线)。
在这种情况下,我怎样才能让 Android Studio 继续显示 res 目录?
谢谢。
【问题讨论】:
标签: android android-studio build.gradle