RevenueCat / purchases-capacitor

Capacitor in-app purchases and subscriptions made easy.
MIT License
155 stars 15 forks source link

[Android] Error Unknown Kotlin JVM target: 21 when compiling #344

Open basvdijk opened 1 month ago

basvdijk commented 1 month ago

When building my Capacitor app with revenuecat/purchases-capacitor 9.0.4 I get:

Execution failed for task ':revenuecat-purchases-capacitor:compileDebugKotlin'.
> Error while evaluating property 'compilerOptions.jvmTarget' of task ':revenuecat-purchases-capacitor:compileDebugKotlin'.
   > Failed to calculate the value of property 'jvmTarget'.
      > Unknown Kotlin JVM target: 21
RCGitBot commented 1 month ago

👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!

basvdijk commented 1 month ago

Checked: https://github.com/RevenueCat/purchases-capacitor/issues/333

I've tried:

android-studio-2024.1.2.13-mac_arm
android-studio-2024.1.2.12-mac_arm
android-studio-2024.1.1.12-mac_arm
android-studio-2023.3.1.20-mac_arm

with

Still got the same error on MacOS 14.6.1 (23G93) Sonoma

rglanz-rc commented 3 weeks ago

Hi @basvdijk, as Toni mentioned, can you confirm which JVM version you're using? And if it's above 17, you may need to use 17 or below instead

basvdijk commented 3 weeks ago

@rglanz-rc These are my settings

image

sebastian-glow commented 3 weeks ago

I encountered a similar issue while using Capacitor 6 and the Android Studio Koala Feature Drop to build the Android project. I was able to resolve it by adding:

android {
  // other configurations

  kotlinOptions {
      jvmTarget = "17"
  }
}

to the android block in the node_modules/@revenuecat/purchases-capacitor/android/build.gradle file. However, directly modifying files within the node_modules directory is not a recommended practice, as changes may be overwritten on updates. Nonetheless, this solution might serve as a quick workaround or provide a hint for a more permanent fix.