I'm storing my xml files in a hierarchical manner, subfolders were created based on the modules, to reduce cluttering of xml layout file in the folder. However, after refactoring, the R.id of each view is not detected from the Activity.java and tags in the layout xml is not detected by Android Studio.
I have added the src directory to my build.gradle and it still give me errors.
sourceSets {
main {
res {
srcDirs 'src/main/res/layout/login_registration',
'src/main/res/layout/store_registration',
'src/main/res/layout',
'src/main/res'
}
}
}
Sample snapshot of the errors:
Can't determine type for tag '<FrameLayout android:id="@+id/login_registration_fragment_container" android:layout_height="match_parent" android:layout_width="match_parent" tools:layout_editor_absoluteX="171dp" tools:layout_editor_absoluteY="225dp"/>'
Can't determine type for tag '<include android:layout_height="match_parent" android:layout_width="match_parent" layout="@layout/app_bar_main"/>'
I have followed the guidance from Can the Android layout folder contain subfolders?. But it does not work. Am I doing something wrong or is there any alternative for managing layout xml files for large application.
EDIT: Thanks to the answer from https://stackoverflow.com/a/64905044/12311798. I have fixed the build issue. But the Android Studio still shows errors in both java and xml files. How can I get rid of the warning? Since the layout resources are detected by gradle.
Screenshot of errors in Android Studio:
Updated src directory in build.gradle:
sourceSets {
main {
res {
srcDirs = ['src/main/res/layout/login_registration',
'src/main/res/layout/store_registration',
'src/main/res/layout',
'src/main/res']
}
}
}