5

I'm trying to add one more resource folder in my Android project. I created a new folder extra-res so my project structure looks like this:

  + src
    + main
      + res
        + layout
        + ...etc...
      + extra-res
        + layout

So I added this to build.gradle:

android {
   .........

   sourceSets {
        main {
            res.srcDirs = ['res', 'extra-res']
        }
    }

}

But after editing the build.gradle file the build fails.

:app:processDebugResources C:\Users\vovasoft\AndroidStudioProjects\sdbm\app\build\intermediates\manifests\full\debug\AndroidManifest.xml
Error:(13, 23) No resource found that matches the given name (at 'icon' with value '@drawable/ic_launcher').
Error:(14, 24) 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:
aapt.exe package -f --no-crunch -I android.jar -M \AndroidStudioProjects\sdbm\app\build\intermediates\manifests\full\debug\AndroidManifest.xml -S \AndroidStudioProjects\sdbm\app\build\intermediates\res\debug -A \AndroidStudioProjects\sdbm\app\build\intermediates\assets\debug -m -J C:\Users\vovasoft\AndroidStudioProjects\sdbm\app\build\generated\source\r\debug -F (at 'label' with value '@string/activity_edit_field').

Before editing build.gradle the build was successful.

Community
  • 1
  • 1
vovahost
  • 34,185
  • 17
  • 113
  • 116
  • 1
    Have a look at: http://stackoverflow.com/questions/4930398/can-the-android-layout-folder-contain-subfolders#answer-22426467 – Joel Jan 28 '15 at 14:53

2 Answers2

10

I gave you some wrong information when I answered your original question in https://stackoverflow.com/a/28176489/2985303. That'll teach me about not testing an answer before posting it. You need to more fully qualify the resource directory paths, like so:

android {
    sourceSets {
        main {
            res.srcDirs = ['src/main/res', 'src/main/extra-res']
        }
    }
}
Community
  • 1
  • 1
Scott Barta
  • 79,344
  • 24
  • 180
  • 163
  • Thank you for your time. Your answer was a good solution but as @Joel mentioned I used this http://stackoverflow.com/questions/4930398/can-the-android-layout-folder-contain-subfolders#answer-22426467 approach. It is easier to organize my layout resources that way. – vovahost Jan 28 '15 at 19:41
  • You can also use the += operator. Example: `res.srcDirs += '../../Config/res/'` – Gustaf Rosenblad Aug 30 '16 at 18:19
0

I was getting that error beacause I forgot to include my new resource folder in build.gradle file.

vovahost
  • 34,185
  • 17
  • 113
  • 116