I'm trying to add a Kotlin library to Android studio, that does not have any dependencies on Android. I followed Create a Kotlin library in Android Studio. The following code in that library compiled fine,
import java.util.*
class DateTimeProvider {
inner class Helper: TimerTask() {
override fun run() {
}
}
fun start(period: Long) {
val timer = Timer()
}
}
but the code completion doesn't see java.util.Date, etc. For example, if I remove the import statement and type Date(0), Android Studio won't add an action to import java.util.Date.
The build.grade file looks like this:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.4"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
When I create an Android library instead, it works, but the whole point is to not depend on Android.
Thank you,
Update
Here is the library's build.grade
file content:
buildscript {
repositories {
google()
mavenCentral()
}
}
plugins {
id 'java-library'
id 'kotlin'
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10"
}