Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to move my Kotlin files into separate package (source type) in Android Studio?

default folder structure look like this:

app:
-manifests
-java
-res

Is there a way that I can create another folder here just for kotlin? So it gonna look like this:

app:
-manifest
-java
-kotlin
-res
like image 406
Zeezl Avatar asked Jan 28 '26 05:01

Zeezl


2 Answers

Yes, it's possible. Add the folder called kotlin and after that add the following lines to the android section of your app/build.gradle file:

sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
}

If you want to read more about Kotlin-Android projects in Android Studio, you can read this.

like image 102
aga Avatar answered Jan 30 '26 22:01

aga


Of course, just mark the folder as source. Actually, default Gradle Kotlin plugin automatically recognizes src/main/kotlin and src/main/java as source folders.

like image 44
Czyzby Avatar answered Jan 30 '26 21:01

Czyzby