# 任务':app:compileDebugKotlin'执行失败。'compileDebugJavaWithJavac'任务（当前目标1.8）和'compileDebugKotlin'任务（当前目标11）的JVM目标兼容性应设置为相同的Java版本。

- **ID:** `android/compile-sdk-version-mismatch`
- **领域:** android
- **类别:** build_error
- **验证级别:** ai_generated
- **修复率:** 95%

## 根因

build.gradle中Java和Kotlin的JVM目标版本不匹配，导致编译不兼容。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Kotlin 1.8.0 | active | — | — |
| Android Gradle Plugin 8.0.0 | active | — | — |
| Java 11 | active | — | — |

## 解决方案

1. ```
   In build.gradle (app level), set both targets: android { compileOptions { sourceCompatibility JavaVersion.VERSION_11; targetCompatibility JavaVersion.VERSION_11 } kotlinOptions { jvmTarget = '11' } }
   ```
2. ```
   If using Java 8, align both to 8: kotlinOptions { jvmTarget = '1.8' } and compileOptions { sourceCompatibility JavaVersion.VERSION_1_8; targetCompatibility JavaVersion.VERSION_1_8 }
   ```

## 无效尝试

- **Only changing compileSdk version in build.gradle without adjusting Java/Kotlin targets** — compileSdk is separate from JVM target; does not resolve version mismatch error. (95% 失败率)
- **Setting both Java and Kotlin targets to 1.6 (deprecated) in hope of backward compatibility** — AGP 8.0+ requires minimum Java 8; 1.6 is unsupported and causes other errors. (85% 失败率)
