バージョン関連エラー解決 - Ki-Kobayashi/Android-Wiki GitHub Wiki

🟩Javaバージョン系のエラー

に、'compileDebugJavaWithJavac' タスクのJavaのバージョンが17に設定されており、一方で 'compileDebugKotlin' タスクのKotlinのバージョンが1.8に設定されているため、JVMターゲットの互換性に問題が生じている系のエラー ''' Execution failed for task ':app:compileDebugKotlin'.

'compileDebugJavaWithJavac' task (current target is 17) and 'compileDebugKotlin' task (current target is 1.8) jvm target compatibility should be set to the same Java version. Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain

  • Try:

Run with --info or --debug option to get more log output. Run with --scan to get full insights. '''

✨解決方法(app/ build.gradle)

「🌟」の4箇所のバージョンを合わせる

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17 🌟1
        targetCompatibility = JavaVersion.VERSION_17 🌟2
//        sourceCompatibility = JavaVersion.VERSION_1_8
//        targetCompatibility = JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "17" 🌟3
    }

🌟4:setting > Build, Exevution, Deployment > Build Tools > Gradle を開く
 右ペインのGradleから、バージョンを合わせる