Issue
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
Solution
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
Answered By - Shweta Chauhan
Answer Checked By - Senaida (JavaFixing Volunteer)