Android - Invalid Resource Directory Name

Asked

Viewed 939 times

1

I tried everything searching the internet, saw various responses about giving Clean Project, rename, update IDE and nothing worked. Still giving the following problem:

inserir a descrição da imagem aqui

I just want to better organize the layout files by adding a folder to separate them. However it is giving this error and I did not find solution

2 answers

3

The folders of an Android application follow a well-defined folder structure and names.

By default the Resources of the kind layout should be placed in the folder

path_do_projeto app src main res layout

In your case what’s wrong is besides having ..\app src main res layouts(layouts instead of layout), has yet another folder layout-Tuto.

To solve

  • rename the folder layouts for layout*.
  • pass the contents of the folder layout-Tuto to the layout.
  • delete the folder layout-Tuto.

However it is possible to have other folders from Resources. They must be configured in the file build.Gradle through sourceSets using the property res.srcDirs.

android{

    ....
    ....
    sourceSets {
        main {
            res.srcDirs += ['src/main/res2']
        }
    }
}
  • Yes, but if I do this, how will I get the layouts organized by folder? Everything in a folder will only be very difficult to locate when the project gets larger

  • But the architecture is the same. If the app is that big, you can modulate it and configure the dependencies between them in the grid. So you would have one folder per module with the classes, activities, layouts, etc in each of them.

0

The error says:

Invalid resource directory name

You have created a directory, layout-tuto, inside of another directory, layouts, which is not recognized by the Android SDK, finally, soon the error is launched in your IDE. To resolve the problem, you should change the directory name layouts for layout as recommended in the documentation. You can improve and organize your structure, through the name of your layouts.

See in Resource provision valid recommendations for directory names.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.