My android project is written 100% in Kotlin and I wanted to rename the java directory to kotlin to be consistent. I added
sourceSets{
main.java.srcDirs += 'src/main/kotlin'
}
to gradle and renamed the directory. All compiles and works fine.
The only issue is that when I am in the project tab, in "Android" view the directory is still named "java" (if I switch to the project view in the dropdown, I do see "kotlin" tho).
What am I missing?
Update:
After refactor renaming
java
tokotlin
, syntax highlighting got broken, cannot CTRL + B to resources in source files.So I opened an issue in the issue tracker even mentioned the android view issue after renaming.
So for now I will keep the source directory name as it is.
Actually you just have to rename the
java
directory tokotlin
, by right clicking on thejava
directory inProject view
and selectand type the new directory name as
kotlin
No need to add any code to gradle file.
(Works on android studio 3.5, Linux Mint)
After refactoring on
Android view
, If it is aAndroid app module
orandroid library module
your source directories (java/kotlin) would not show up, but in regularlibrary module
s it will show up asjava
. InProject view
all things look as expected.