1

I have created sub directory 'caching' within the res-layout directory and when I placed an XML file within caching it complains 'URI is not registered'.

I looked up online and some say it is not recommended to create sub directories withing layout and some suggest to add the following code in the build.gradle.

app: build.gradle

sourceSets {
        main {
            res.srcDirs =
                    [
                            'src/main/res/layouts/caching',
                            'src/main/res/layouts',
                            'src/main/res'
                    ]
        }
    }

My Structure

--res
   --layout
      --caching
          cache_save_layout.xml

Where the error occurs -- "http://schemas.android.com/apk/res/android" - URI is not registered

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

</LinearLayout>

Could you suggest what is the right way to fix this.

Thanks in advance R

BRDroid
  • 3,920
  • 8
  • 65
  • 143
  • https://stackoverflow.com/questions/44581013/android-organizing-layout-resourse/44582145#44582145 – Goku Nov 29 '17 at 12:17
  • The simplest solution is to get rid of the `caching` directory and put `cache_save_layout` in `res/layout/`. – CommonsWare Nov 29 '17 at 12:21
  • 1
    Possible duplicate of [Android organizing layout resourse?](https://stackoverflow.com/questions/44581013/android-organizing-layout-resourse) – Sanket Bhat Nov 29 '17 at 12:23
  • @CommonsWare thank you for your response but that was not what I wanted to do. – BRDroid Nov 29 '17 at 12:23

1 Answers1

0

try follow

sourceSets {
    main {
        res.srcDirs =
                [
                        'src/main/res/layouts/activity',
                        'src/main/res/layouts/fragment',                          
                        'src/main/res'
                ]
    }
}

Your structure should like this:

--res 
    --layouts
        --activity
           --layout
              --main_activity.xml
        --fragment
           --layout
              --main_fragment.xml
Shweta Chauhan
  • 6,739
  • 6
  • 37
  • 57
  • 2
    Please don't use quote-formatting for any and all text you write. It is meant for quotes thus the name.... – piet.t Aug 22 '18 at 06:59