3

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",
        ]
    }
}

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: 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').

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 ....

Adrian L
  • 443
  • 1
  • 8
  • 19
  • I have looked at this question http://stackoverflow.com/questions/4930398/can-the-android-layout-folder-contain-subfolders and I followed the solution proposed in the second answer for that question, where someone manager to create subfolders for layout res folder – Adrian L Sep 12 '14 at 09:36

1 Answers1

4

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
zmarties
  • 4,809
  • 22
  • 39