可以在Android Studio中的drawable文件夹中创建子文件夹吗? [英] Possible to create subfolders in drawable folder in Android Studio?

查看:1044
本文介绍了可以在Android Studio中的drawable文件夹中创建子文件夹吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Is it possible to create subfolder structures inside main res folders, especially in drawable folder using Gradle?

到目前为止,我已经尝试过

I have attempted this so far

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构建错误消息:

When I rebuild the project however I get this Gradle build error message something like this:

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软件包-f --no-crunch -I/Users/adrian/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/generation/source/r/调试-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/Users/adrian/Development/alstom_framework/app/build/intermediates/symbols/debug 错误代码: 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' ).

com.android.ide.common.internal.LoggedErrorException: Failed to run command: /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 /Users/adrian/Development/alstom_framework/app/build/intermediates/symbols/debug Error Code: 1 Output: /Users/adrian/Development/alstom_framework/app/build/intermediates/manifests/debug/AndroidManifest.xml:35: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/app_icon'). /Users/adrian/Development/alstom_framework/app/build/intermediates/manifests/debug/AndroidManifest.xml:35: error: Error: No resource found that matches the given name (at 'label' with value '@string/app_name'). /Users/adrian/Development/alstom_framework/app/build/intermediates/manifests/debug/AndroidManifest.xml:35: error: Error: No resource found that matches the given name (at 'theme' with value '@style/AppTheme'). /Users/adrian/Development/alstom_framework/app/build/intermediates/manifests/debug/AndroidManifest.xml:43: error: Error: No resource found that matches the given name (at 'label' with value '@string/app_name'). /Users/adrian/Development/alstom_framework/app/build/intermediates/manifests/debug/AndroidManifest.xml:48: error: Error: No resource found that matches the given name (at 'label' with value '@string/app_name'). /Users/adrian/Development/alstom_framework/app/build/intermediates/manifests/debug/AndroidManifest.xml:52: error: Error: No resource found that matches the given name (at 'label' with value '@string/app_name'). /Users/adrian/Development/alstom_framework/app/build/intermediates/manifests/debug/AndroidManifest.xml:70: error: Error: No resource found that matches the given name (at 'label' with value '@string/app_name').

这对我来说意味着gradle仅能看到我在app.gradle文件中指定的res文件夹?因此,我将其余部分添加到了app.gradle中,并且发生了相同的错误... 谁能帮忙....

This means to me that the gradle sees only the res folders specified by me in app.gradle file ? Therefore I added the rest of it to the app.gradle and same error occurs... Can anyone help please ....

推荐答案

否,Android希望所有文件都位于单个目录中,并且不允许使用子文件夹.

No, Android expects all the files to be in a single directory, and does not allow subfolders to be used.

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

Most apps use a naming convention in place of subfolders, so in your example you might end up with a list of files:

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

这篇关于可以在Android Studio中的drawable文件夹中创建子文件夹吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆