# 插件解析异常：插件 [id: 'com.github.johnrengelman.shadow', version: '8.1.1'] 在以下来源中未找到：Gradle 核心插件、插件仓库（无法解析插件工件 'com.github.johnrengelman.shadow:com.github.johnrengelman.shadow.gradle.plugin:8.1.1'）

- **ID:** `java/gradle-plugin-not-found`
- **领域:** java
- **类别:** build_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

Gradle 插件未在 pluginManagement 块中声明，或者缺少插件仓库。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 8+ | active | — | — |

## 解决方案

1. **Add the Gradle Plugin Portal to pluginManagement repositories** (95% 成功率)
   ```
   pluginManagement { repositories { gradlePluginPortal() mavenCentral() } }
   ```
2. **Declare the plugin directly in build.gradle with correct version** (90% 成功率)
   ```
   plugins { id 'com.github.johnrengelman.shadow' version '8.1.1' }
   ```

## 无效尝试

- **Adding the plugin to buildscript dependencies without using pluginManagement** — Gradle 8+ requires plugins to be resolved via pluginManagement or direct plugin block with repository. (80% 失败率)
- **Using an older version of the plugin that is not compatible with Gradle 8** — Version incompatibility leads to resolution failure. (75% 失败率)
