我将一个项目从一台电脑导入到另一台电脑,我的 gradle 文件都搞砸了。它提示我的 res 文件夹不在正确的路径。我已经在 list 文件中使用了以下行:
sourceSets {
main {
manifest.srcFile 'app\\src\\main\\AndroidManifest.xml'
}
}
我可以以某种方式设置整个源目录(用于java文件和res文件)吗?或者单独设置它们?
注意:gradle 尝试使用的路径似乎缺少“app”
作为引用,这里是错误:
C:\MyProject\build\intermediates\manifests\debug\AndroidManifest.xml
Error:(24, 23) No resource found that matches the given name (at 'icon' with value '@drawable/ic_launcher').
Error:(25, 24) No resource found that matches the given name (at 'label' with value '@string/app_name').
Error:(26, 24) No resource found that matches the given name (at 'theme' with value '@style/AppTheme').
Error:(29, 28) No resource found that matches the given name (at 'label' with value '@string/app_name').
最佳答案
2分钟后我找到了解决方案。我想我不应该在深夜编码。
sourceSets {
main {
java.srcDirs 'app\\src\\main\\java'
res.srcDirs 'app\\src\\main\\res'
manifest.srcFile 'app\\src\\main\\AndroidManifest.xml'
}
}
关于android-studio - 如何在gradle文件中设置资源目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25376084/