LinkFive - Successful Subscriptions

Android Kotlin Error troubleshooting

Android Kotlin Error troubleshooting

Android Kotlin Error

Kotlin version error. An example would be:

e: /Users/.../linkfive_purchases-1.1.1/android/src/main/kotlin/io/linkfive/linkfive_purchases/LinkFivePurchasesPlugin.kt: (25, 9): Cannot access built-in declaration 'kotlin.Unit'. Ensure that you have a dependency on the Kotlin standard library
e: /Users/.../linkfive_purchases-1.1.1/android/src/main/kotlin/io/linkfive/linkfive_purchases/LinkFivePurchasesPlugin.kt: (29, 9): Cannot access built-in declaration 'kotlin.Unit'. Ensure that you have a dependency on the Kotlin standard library
e: /Users/.../linkfive_purchases-1.1.1/android/src/main/kotlin/io/linkfive/linkfive_purchases/LinkFivePurchasesPlugin.kt: (29, 20): Cannot access built-in declaration 'kotlin.String'. Ensure that you have a dependency on the Kotlin standard library
e: /Users/.../linkfive_purchases-1.1.1/android/src/main/kotlin/io/linkfive/linkfive_purchases/LinkFivePurchasesPlugin.kt: (31, 24): Cannot access built-in declaration 'kotlin.Unit'. Ensure that you have a dependency on the Kotlin standard library
e: /Users/.../linkfive_purchases-1.1.1/android/src/main/kotlin/io/linkfive/linkfive_purchases/LinkFivePurchasesPlugin.kt: (33, 28): Cannot access built-in declaration 'kotlin.Unit'. Ensure that you have a dependency on the Kotlin standard library
e: /Users/.../linkfive_purchases-1.1.1/android/src/main/kotlin/io/linkfive/linkfive_purchases/LinkFivePurchasesPlugin.kt: (41, 9): Cannot access built-in declaration 'kotlin.Unit'. Ensure that you have a dependency on the Kotlin standard library
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':linkfive_purchases:compileDebugKotlin'.
> Compilation error. See log for more details
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 8s
Exception: Gradle task assembleDebug failed with exit code 1

Fix by increase the kotlin version

To solve this, go to: android project folder > build.gradle. And increase the kotlin version to at least 1.5.0

buildscript {
ext.kotlin_version = '1.5.0'
dependencies {
...
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}