android-studio - 如何在gradle文件中设置资源目录?

标签 android-studio android-gradle-plugin

我将一个项目从一台电脑导入到另一台电脑,我的 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/

相关文章:

java - Android Studio 3.5.1 中出现什么类型的问题?

Android - ellipsize ="end"不显示三个点

android - 如何将项目从android studio迁移到android studio

android - 如何将 Gson 附加功能添加到 Android 项目中?

android - 在 Android Studio 项目中找不到参数的方法 android()

android - 何时在 Gradle 插件中应用自定义 Android 扩展?

android - 如何仅折射一个类中的变量名称

android - 如何使用全局本地 gradle 安装而不是每次都下载压缩包装?

android - React Native Android 中未指定 compileSdkVersion 错误

maven - 搜索Gradle插件的方法