【发布时间】:2017-06-28 08:28:12
【问题描述】:
我阅读了那篇文章并尝试在 app/src/main/res/layout/ 中制作子文件夹
我想我做了那个答案中提到的所有事情。
在我的毕业典礼中:
apply plugin:
apply plugin:
apply plugin:
apply plugin:
android {
// something
sourceSets {
main {
res.srcDirs = getLayoutList("app/src/main/res/layout/")
}
}
def getLayoutList(path) {
File file = new File(path)
def throwAway = file.path.split("/")[0]
def newPath = file.path.substring(throwAway.length() + 1)
def array = file.list().collect {
"${newPath}/${it}"
}
def res="src/main/res";
array.push(res);
return array
}
dependencies { ... }
我的目录层次模型(项目)
测试 -- .gradle - 。主意 - 应用程序 - 建造 -- 库 -- 源代码 -- 安卓测试 - 主要的 -- 资产 -- 爪哇 -- 水库 - 布局 -- about_login - 时间表 --activity_main.xml -- AndroidManifest.xml - 测试 - 建造 -- 毕业 -- .gitignore -- ... // 更多设置文件但是当我同步我的 gradle 时,错误出现并说,index error
def newPath = file.path.substring(throwAway.length() + 1)
在那条线上。请帮帮我。
为什么这是一个不同的问题?
第一。很多人在自己的电脑上工作,但我不能
第二。我认为 String.substring()
之间有关系
第三。我无法解决这个问题。
【问题讨论】:
-
所以,我试图将
throwAway.length() + 1更改为throwAway.length(),但随后出现错误。找不到R.id.~~(但是,在java中,没有编译错误)
标签: android android-studio gradle subdirectory