Renaming “java” directory to “kotlin” in Android Studio

后端 未结 7 913
挽巷
挽巷 2021-01-31 01:40

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 +=         


        
7条回答
  •  野的像风
    2021-01-31 02:42

    This works fine in Android Studio 3.6.2 and should be the most versatile solution until AndroidSourceSet starts supporting Kotlin directly. Just add the following snippet at the end of your app/build.gradle[.kts]:

    android.sourceSets.all {
        java.srcDir("src/$name/kotlin")
    }
    

提交回复
热议问题