I'm using Kotlin for the first time to develop an Android app. Currently I'm working on a library module ("data") inside my project, separate from the main app module:
> [Root directory]
> app
> [...]
> data
> src
> debug
> kotlin
> com.domain.app
> [...]
> main
> kotlin
> com.domain.app
> [...]
> release
> kotlin
> com.domain.app
> [...]
I've come across a snag: whenever a file inside data.src.main references a file inside data.src.debug, the build process fails with the message "Unresolved reference: [class name]". However, it doesn't fail when I reference files inside data.src.release. In both cases I've triple checked the syntax, directories, and build variants.
I haven't modified the debug or release build types inside my build.gradle files - I'm using whatever their default settings are. My source sets are:
android {
...
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
debug.java.srcDirs += 'src/debug/kotlin'
release.java.srcDirs += 'src/release/
}
}
The module is using the 'com.android.library' and 'kotlin-android' plugins. All the files I've tested with so far have been Kotlin files, though I don't know if this is a Kotlin issue or something else. Kotlin has otherwise been behaving.
I figured this might be caused by the default debug settings, but I also testing app.src.main referencing app.src.debug, and that works correctly despite using the same default settings.