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

后端 未结 7 912
挽巷
挽巷 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:25

    Android Studio 3.6 has the same behavior. This is how I fixed it, in app/build.gradle:

    // Register kotlin files
    android.sourceSets {
         androidTest.java.srcDirs += "src/androidTest/kotlin"
         debug.java.srcDirs += "src/debug/kotlin"
         main.java.srcDirs += "src/main/kotlin"
         test.java.srcDirs += "src/test/kotlin"
    }
    

提交回复
热议问题