可以在Android Studio的drawable文件夹中创建子文件夹吗?

时间:2014-09-12 09:28:05

标签: android android-studio android-gradle android-drawable

是否可以在主res文件夹中创建子文件夹结构,尤其是在使用Gradle的可绘制文件夹中?

我到目前为止尝试过这个

sourceSets {

    main {
        res.srcDirs = [
                "/src/main/res/drawable-xhdpi/actionbar_items",
                "/src/main/res/drawable-xhdpi/intro",
                "/src/main/res/drawable-xhdpi/loading_screen",
                "/src/main/res/drawable-xhdpi",
                "/src/main/res",
        ]
    }
}

当我重建项目时,我得到这样的Gradle构建错误消息:

Error:(39, 23) No resource found that matches the given name (at 'icon' with value     '@drawable/app_icon').
Error:(40, 24) No resource found that matches the given name (at 'label' with value '@string/app_name').
Error:(42, 24) No resource found that matches the given name (at 'theme' with value '@style/AppTheme').
Error:(45, 28) No resource found that matches the given name (at 'label' with value '@string/app_name').
Error:(50, 28) No resource found that matches the given name (at 'label' with value '@string/app_name').
Error:(55, 28) No resource found that matches the given name (at 'label' with value '@string/app_name').
Error:(73, 28) No resource found that matches the given name (at 'label' with value '@string/app_name'). 

Error:Execution failed for task ':app:processDebugResources'.
  

com.android.ide.common.internal.LoggedErrorException:无法运行命令:       /Users/adrian/adt-bundle-mac-x86_64-20140702/sdk/build-tools/android-4.4W/aapt package -f --no-crunch -I / Users / adrian / adt-bundle-mac-x86_64- 20140702 / sdk / platforms / android-19 / android.jar -M /Users/adrian/Development/alstom_framework/app/build/intermediates/manifests/debug/AndroidManifest.xml -S / Users / adrian / Development / alstom_framework / app / build / intermediates / res / debug -A / Users / adrian / Development / alstom_framework / app / build / intermediates / assets / debug -m -J / Users / adrian / Development / alstom_framework / app / build / generated / source / r / debug -F /Users/adrian/Development/alstom_framework/app/build/intermediates/libs/app-debug.ap_ --debug-mode --custom-package com.hiddenltd.framework -0 apk --output-text-symbols /用户/阿德里安/开发/ alstom_framework /应用程序/生成/中间体/符号/调试     错误代码:       1     输出:       /Users/adrian/Development/alstom_framework/app/build/intermediates/manifests/debug/AndroidManifest.xml:35:错误:错误:找不到与给定名称匹配的资源(在'icon'处,值为'@ drawable / app_icon' )。       /Users/adrian/Development/alstom_framework/app/build/intermediates/manifests/debug/AndroidManifest.xml:35:错误:错误:找不到与给定名称匹配的资源(在'label'处,值为'@ string / app_name' )。       /Users/adrian/Development/alstom_framework/app/build/intermediates/manifests/debug/AndroidManifest.xml:35:错误:错误:找不到与给定名称匹配的资源(在'theme'处,值为'@ style / AppTheme' )。       /Users/adrian/Development/alstom_framework/app/build/intermediates/manifests/debug/AndroidManifest.xml:43:错误:错误:找不到与给定名称匹配的资源(在'label'处,值为'@ string / app_name' )。       /Users/adrian/Development/alstom_framework/app/build/intermediates/manifests/debug/AndroidManifest.xml:48:错误:错误:找不到与给定名称匹配的资源(在'label'处,值为'@ string / app_name' )。       /Users/adrian/Development/alstom_framework/app/build/intermediates/manifests/debug/AndroidManifest.xml:52:错误:错误:找不到与给定名称匹配的资源(在'label'处,值为'@ string / app_name' )。       /Users/adrian/Development/alstom_framework/app/build/intermediates/manifests/debug/AndroidManifest.xml:70:错误:错误:找不到与给定名称匹配的资源(在'label'处,值为'@ string / app_name' )。

这对我来说意味着gradle只能在app.gradle文件中看到我指定的res文件夹?因此,我将其余部分添加到app.gradle并发生相同的错误... 任何人都可以帮忙....

1 个答案:

答案 0 :(得分:3)

不,Android希望所有文件都在一个目录中,并且不允许使用子文件夹。

大多数应用使用命名约定代替子文件夹,因此在您的示例中,您最终可能会得到一个文件列表:

  • intro_welcome.png
  • intro_background.png
  • loading_splashscreen.png
  • actionbar_delete.png