Include .java files as java source files in Android Studio to remove red circle with "J" on them
I found some magical solution while playing with this
There are two possible solution you can try to make it correct (tricky one)
1.Replace this in your build.gradle file
java.srcDirs = ['src'] to java.srcDirs = ['src/com']
2.Create a subdirectory inside src
name it whatever you want, I prefer name it java
like
src > java
move all your java package in to it and change the
java.srcDirs = ['src'] to java.srcDirs = ['src/java']
These are the tricky solutions. It can be considered as a bug in Android Studio that it is not considering the java source set if it is the root of src
directory but compiles fine.
After doing all the necessary changes sync your project with gradle and your yellow directory will be magically turned into blue.
Note : Even you have them in root there will be no effect on compilation as per my experience. Only Studio will not mark them as java sourcesets in IDE.
- Open Project Structure in Android Studio(
Cmd+;
) - Under modules Header over the left of the window, look onto right side of it , You will get to see three tabs one of which is Sources ,Select it.
- There, you will find the structure of your project which you have imported or might have created by self.
- Go for the src folder of it and wait for the sources link above that dialog with many others to get avail to apply onto it,grab it.
- Apply and OK
- Problem Solved.
I solved it just closing the project from android studio and remove the project from recent project. Re-import the project, it worked. If any one facing for android project he/she can try this. Thanks