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

后端 未结 7 910
挽巷
挽巷 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")
    }
    
    0 讨论(0)
提交回复
热议问题