title: Android studio src/res/layout subfolder error
body: <p><a href="https://stackoverflow.com/a/36931232/7105963">StackOverflow Answers</a></p>
  
  <p>I read that article and tried to <strong>make subfolders</strong> in app/src/main/res/layout/</p>
  
  <p>I think I did the whole things which are mentioned in that answer.</p>
  
  <h2>In my gradle:</h2>
  
  <pre><code>apply plugin: 
  apply plugin: 
  apply plugin:
  apply plugin: 
  
  android {
      // something
      sourceSets {
      main {
          res.srcDirs = getLayoutList("app/src/main/res/layout/")
      }
  }
  def getLayoutList(path) {
  File file = new File(path)
  def throwAway = file.path.split("/")[0]
  def newPath = file.path.substring(throwAway.length() + 1)
  def array = file.list().collect {
      "${newPath}/${it}"
  }
  def res="src/main/res";
  array.push(res);
  return array
  }
  
  dependencies { ... }
  </code></pre>
  
  <h2>My directory hierarchy model (Project)</h2>
  
  <pre>
  Test
  -- .gradle
  -- .idea
  -- app
    -- build
    -- libs
    -- src
      -- androidTest
      -- main
        -- assets
        -- java
        -- res
          -- layout
            -- about_login
            -- timetable
            -- activity_main.xml
        -- AndroidManifest.xml
      -- test
  -- build
  -- gradle
  -- .gitignore
  -- ... // Lot more setting files
  </pre>
  
  <p>But when I sync my gradle, the error came up and said, <strong>index error</strong></p>
  
  <blockquote>
    <p>def newPath = file.path.substring(throwAway.length() + 1)</p>
  </blockquote>
  
  <p>at that line. Please help me.</p>
  
  <h2>Why this is different question?</h2>
  
  <p>1st. Many people works in their own PC but, I can't<br>
  2nd. I think that there has relationship between String.substring()<br>
  3rd. I cannot solve this problem.</p>