I have been doing a single project for a long time and in the development process I added lines to the grad and now I looked through the grad and noticed a piece of code

android { ... sourceSets { main { dirs.each { dir -> java.srcDirs "src/${dir}/java" res.srcDirs "src/${dir}/res" } } androidTest.setRoot('tests') androidTest.java.srcDirs = ['tests/src'] } } 

In it, .srcDirs stands out in gray and says that it cannot recognize what it is ...

And I can't remember what this piece of code does.

Can you tell who understands the hail files?

Closed due to the fact that the question is too common for participants Streletz , aleksandr barakin , Kromster , user194374, sercxjo Jun 30 '16 at 21:00 .

Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • ru.stackoverflow.com/questions/520403/android-instrumentation-tests-in-folder-androidtest-java- not- can- createclass- user186301
  • @ user186301 still hard for me to understand what this piece of code ultimately makes ... - Aleksey Timoshchenko
  • one
    They don't ask such questions here. Here they solve specific problems. What is your problem? - Vladyslav Matviienko
  • @metalurgus well, i'm not sure what the problem is. This piece of code just hangs out in hail and I don’t understand what it does) - Aleksey Timoshchenko

1 answer 1

The sourceSets block defines sets of source files that are grouped into groups, for example main . Inside these groups you create source directories for different types of files (they are expected to find plugins). In this case, you have 2 directories - java files will go to src/main/java , resources will go to src/main/res .

These blocks are usually added by the plugins themselves, and you don’t need to write them, unless you want to change the default values, as in this case, by changing src/main/resources to src/main/res .

  • why does the idea show that it doesn't recognize .srcDirs ? And if I understand correctly, can I delete it? - Aleksey Timoshchenko
  • one
    Idea does not know what java in this context, it is a dynamically resolvable field in runtime. Accordingly, Idea has no idea what properties this field has. It is impossible to delete, because surely something somewhere is tied to the fact that resources are called res , and not standardly - resources . PS If the answer is correct, then accept will not be superfluous. - JBaruch
  • In general, it is standard for androyd just res and not and not resources - xkor
  • one
    @AlekseyTimoshchenko what is there with an acceptance? :) - JBaruch
  • one
    accept the answer if it's correct. Tick ​​green :) - JBaruch