К основному содержанию
скилл CX Codex

capacitor-app-upgrade-v4-to-v5 — скилл для Claude Code: миграция

Скилл ведёт приложение на Capacitor 4 к версии 5: запускает npx cap migrate, добивает пропущенное вручную и проверяет сборку.

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add Cap-go/capgo-skills --skill capacitor-app-upgrade-v4-to-v5 -a claude-code
Открыть на GitHub

Что делает capacitor-app-upgrade-v4-to-v5

Скилл включается, когда в package.json стоит @capacitor/core версии 4.x, а нужна 5.x. Он прогоняет автоматическую миграцию через @capacitor/cli@latest-5 и npx cap migrate: обновляет пакеты @capacitor/*, variables.gradle, AGP, Gradle wrapper, переносит package в namespace и делает cap sync. Всё, что CLI не осилил, печатается в выводе — эти шаги скилл доводит по чек-листу.

Перед правками идёт предполётная проверка инструментов: Node.js 16+, Xcode 14.1+, Android Studio Flamingo с JDK 17, AGP 8.0.0, Gradle 8.0.2, compileSdk и targetSdk 33. Если Gradle JDK остался на 11, сборка упадёт с Android Gradle plugin requires Java 17 to run — это повод переключить JDK в Android Studio до начала миграции, а не после. Отдельно скилл советует зафиксировать androidScheme: "http" в capacitor.config.*: в Capacitor 6 значение по умолчанию станет https, сменится origin WebView, и localStorage с IndexedDB и cookies пропадут.

Внутри два справочника, которые подгружаются по ситуации: references/android.md для ручной правки build.gradle, манифеста и Kotlin, references/plugins.md для ломающих изменений официальных плагинов — Device.getId() теперь отдаёт { identifier } вместо uuid, а на Android 13 Push и Local Notifications требуют checkPermissions() и requestPermissions() в рантайме. Скилл не для перехода между другими мажорными версиями, не для обновления библиотек-плагинов и не для приложений вне Capacitor.

Какие задачи решает

  • перевести приложение с Capacitor 4 на Capacitor 5 без пропущенных шагов
  • починить сборку Android после ошибки Namespace not specified
  • переключить Gradle JDK на 17 и убрать конфликт с Java 11
  • перенести package из AndroidManifest.xml в namespace в build.gradle
  • проверить, что localStorage и cookies пережили смену androidScheme

Примеры запросов агенту

  • Проверь версии @capacitor/* в package.json и проведи миграцию с 4 на 5
  • Сборка Android падает с Android Gradle plugin requires Java 17 to run — что делать?
  • Прогони чек-лист для iOS и Android после npx cap migrate

Как установить capacitor-app-upgrade-v4-to-v5

1Через Skills CLI (Vercel)

npx skills add Cap-go/capgo-skills --skill capacitor-app-upgrade-v4-to-v5 -a claude-code

2Вручную: положить файлы

~/.claude/skills/capacitor-app-upgrade-v4-to-v5/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/capacitor-app-upgrade-v4-to-v5/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Вопросы о capacitor-app-upgrade-v4-to-v5

Как установить capacitor-app-upgrade-v4-to-v5 в Claude?

Выполните npx skills add Cap-go/capgo-skills --skill capacitor-app-upgrade-v4-to-v5 -a claude-code. Скилл появится в ~/.claude/skills/capacitor-app-upgrade-v4-to-v5/SKILL.md.

Что делает этот скилл?

Проводит приложение с Capacitor 4 на Capacitor 5: запускает npx cap migrate, доводит шаги, которые CLI пропустил, и проверяет сборку на обеих платформах.

Подойдёт ли он для обновления плагина или перехода с 5 на 6?

Нет. Для библиотеки-плагина есть отдельный скилл capacitor-plugin-upgrade-v4-to-v5, а для 5 → 6 — capacitor-app-upgrade-v5-to-v6.

Исходный текст

SKILL.md · MIT
---
name: capacitor-app-upgrade-v4-to-v5
description: Upgrades a Capacitor app from v4 to v5 using `npx cap migrate` from `@capacitor/cli@latest-5`, then the manual checklist - Node 16+, Xcode 14.1+, Android Studio Flamingo with JDK 17, AGP 8.0.0, Gradle 8.0.2, compile/target SDK 33, `package` moved from AndroidManifest.xml to `namespace` in build.gradle, Jetifier removal, pinning `androidScheme` to `http`, and official plugin breaking changes (Device `uuid` to `identifier`, Android 13 notification permissions, READ_MEDIA_IMAGES). Use when `@capacitor/core` is 4.x and the target is 5.x, or on errors like "Namespace not specified" or "Android Gradle plugin requires Java 17". Do not use for other major versions, plugin library upgrades, or non-Capacitor apps.
allowed-tools:
  - Bash(node -e *)
---

# Capacitor App Upgrade v4 to v5

Move a Capacitor 4 app to Capacitor 5. Source of truth: https://capacitorjs.com/docs/updating/5-0

## When to Use

- `@capacitor/core` in the snapshot below is `4.x` and the user wants `5.x`.
- Android build fails after bumping to Capacitor 5 with `Namespace not specified`, a Java 11 vs 17 mismatch, or AGP 8 errors.
- The user asks for the exact 4 -> 5 checklist for iOS, Android, or official plugins.

Do not use:

- App on 5.x or later -> `capacitor-app-upgrade-v5-to-v6` (then v6-to-v7, v7-to-v8). Multi-hop planning -> `capacitor-app-upgrades`.
- Upgrading a plugin library -> `capacitor-plugin-upgrade-v4-to-v5`.
- App on 3.x -> upgrade to 4 first (`npx cap migrate` in 5.x refuses projects below 4).

## Live Project Snapshot

Current Capacitor packages from `package.json`:
!`node -e "const fs=require('fs');if(!fs.existsSync('package.json'))process.exit(0);const pkg=JSON.parse(fs.readFileSync('package.json','utf8'));const out=[];for(const section of ['dependencies','devDependencies']){for(const [name,version] of Object.entries(pkg[section]||{})){if(name.startsWith('@capacitor/'))out.push(section+'.'+name+'='+version)}}console.log(out.sort().join('\n'))"`

## References

Only load a reference when its topic is in play.

| File | Load when |
| --- | --- |
| `references/android.md` | Editing `variables.gradle`, `build.gradle`, wrapper, manifest, or Kotlin by hand |
| `references/plugins.md` | The app uses official `@capacitor/*` plugins (Camera, Device, Push, Local Notifications, Google Maps, ...) |

## Preflight

Check and report before touching files. Ask the user to upgrade tooling if any minimum is missing.

| Tool | Minimum for Capacitor 5 |
| --- | --- |
| Node.js | 16+ (latest LTS recommended) |
| Xcode | 14.1+ |
| Android Studio | Flamingo 2022.2.1+ (bundles JDK 17) |
| Java (Gradle JDK) | 17 |
| AGP / Gradle | 8.0.0 / 8.0.2 |
| Android SDK | minSdk 22, compileSdk 33, targetSdk 33 |
| iOS deployment target | 13.0 (unchanged from v4) |

```bash
node -v
xcodebuild -version
java -version
git status --short   # start from a clean tree so the migration diff is reviewable
```

## Procedure

1. Confirm `@capacitor/core` is 4.x from the snapshot. If below 4, stop and route to a 3 -> 4 upgrade first.
2. Run the automated migration:

   ```bash
   npm i -D @capacitor/cli@latest-5
   npx cap migrate
   ```

   It bumps `@capacitor/*` packages, updates `variables.gradle`, AGP, the Gradle wrapper, moves `package` to `namespace`, trims the iOS app icon set, and runs `cap sync`. Read the output: every step it could not complete is printed and must be done by hand.
3. Review `git diff`. Then finish anything the CLI skipped:
   - **iOS**: in `ios/.gitignore` replace `App/Podfile.lock` with `App/output` (commit `Podfile.lock` from now on). Optionally reduce `AppIcon.appiconset` to a single 1024x1024 icon.
   - **Android**: apply the variable table and diffs in `references/android.md` (AGP 8.0.0, Gradle 8.0.2, google-services 4.3.15, `namespace`, Jetifier, Kotlin 1.8.20).
   - **Config**: if `server.androidScheme` is not set, add `androidScheme: "http"` to `capacitor.config.*`. Capacitor 6 flips the default to `https`, which changes the WebView origin and wipes localStorage, IndexedDB and cookies. Pinning now prevents data loss later. Ask the user before choosing `https` instead.
4. Update every official plugin to `^5.0.0` and community plugins to their Capacitor 5 release. Apply code changes from `references/plugins.md`.
5. In Android Studio, run `Tools -> AGP Upgrade Assistant` if the Gradle files still show AGP 7 leftovers.
6. Run verification below.

## Traps

- Removing `android.enableJetifier=true` breaks builds if any dependency still uses the old `android.support.*` libraries. Grep `node_modules` and native deps first; keep Jetifier if unsure.
- `namespace` must equal the old manifest `package` value, not the `applicationId` if they differ.
- Device plugin: `getId()` now returns `{ identifier }`; `uuid` is gone. On iOS 16+, `DeviceInfo.name` returns a generic name without the user-assigned-device-name entitlement.
- Android 13 (targetSdk 33): Push and Local Notifications need `checkPermissions()` / `requestPermissions()` at runtime or nothing is shown.

## Verification

```bash
grep -rn "package=" android/app/src/main/AndroidManifest.xml          # expect no package attribute
grep -n "namespace" android/app/build.gradle                          # expect namespace "<id>"
grep -n "gradle:8.0.0\|google-services" android/build.gradle
grep -n "distributionUrl" android/gradle/wrapper/gradle-wrapper.properties  # gradle-8.0.2
grep -n "SdkVersion" android/variables.gradle                         # 22 / 33 / 33
grep -rn "androidScheme" capacitor.config.*                           # explicit value present
grep -rn "\.uuid\b" src/                                              # no Device uuid leftovers
npx cap sync
cd android && ./gradlew assembleDebug
```

Then build iOS in Xcode 14.1+ (or `npx cap run ios`) and launch both platforms. Confirm stored data (login, localStorage) survived the upgrade.

## Error Handling

| Error | Fix |
| --- | --- |
| `Migrate can only be used on capacitor 4 and above, please use the CLI in Capacitor 4 to upgrade to 4 first` | Project is on 3.x. Upgrade to 4 first. |
| `Capacitor 5 requires JDK 17 or higher. Some steps may fail.` | Set Gradle JDK to 17 (Android Studio Settings -> Build Tools -> Gradle) and rerun. |
| `Unable to find <file>. Try updating it manually` | Apply the matching diff from `references/android.md`. |
| `Found namespace in build.gradle already, skipping migration` | Informational. Just confirm the manifest no longer has `package=`. |
| `Namespace not specified` (Gradle) | Add `namespace "<package id>"` to the `android {}` block of the failing module. For a third-party plugin, update it to its Capacitor 5 release. |
| `Android Gradle plugin requires Java 17 to run. You are currently using Java 11.` | Switch Gradle JDK to 17. |
| Data loss / logged out after upgrade on Android | `androidScheme` changed. Set it back to the scheme the installed app used (`http` for v4 defaults). |

© Cap-go · MIT · Cap-go/capgo-skills

Похожие скиллы

Всё по теме «Мобильная разработка» →
capacitor-plugin-upgrades capawesome-team Проведёт плагин Capacitor через мажорные версии 4–8, включая прыжки через несколько версий сразу. Пригодится, когда плагин отстал от текущего Capacitor. CX Codex +1 811установок capacitor-app-upgrades capawesome-team Ведёт агента через обновление Capacitor-проекта до новой мажорной версии, включая прыжки через несколько версий. Пригодится, когда пора перейти с 4 на 8 и не хочется разбираться в миграции вручную. CX Codex +1 902установок agp-9-upgrade Google LLC Ведёт Android-проект с AGP 8 на Android Gradle Plugin 9: поднимает зависимости, переводит сборку на встроенный Kotlin и новый DSL. CX Codex +1 1 200установок play-billing-library-version-upgrade Google LLC Скилл ведёт Android-проект с устаревшей Google Play Billing Library до актуальной стабильной версии. Он сам находит зависимость в Gradle и проверяет сборку после каждого шага. CX Codex +1 1 900установок upgrade-react-native react-native-community Обновляет проекты React Native Community CLI на заданную версию через diff-файлы React Native Upgrade Helper. CX Codex +1 1 300установок kotlin-multiplatform vitorpamplona Скилл подсказывает агенту, в какой модуль и source set положить код в Amethyst, и не даёт сломать сборку на гейте чистоты KMP. CX Codex +1 1 600установок

Из того же набора29

capgo-release-management Скилл ведёт релизы Capgo из CLI: загрузка бандлов, каналы, постепенный выкат, откат и шифрование. Пригодится, когда релиз ломается на загрузке или нужно откатить бандл. CX Codex +1 705установок capacitor-app-upgrade-v7-to-v8 Ведёт приложение на Capacitor 7 к восьмой версии: сначала npx cap migrate, потом ручной чек-лист по iOS и Android. CX Codex +1 704установок webapp-to-capacitor Планирует и выполняет превращение веб-приложения, PWA или SPA в приложение под iOS и Android на Capacitor, которое проходит ревью магазинов. CX Codex +1 665установок ionic-appflow-migration Переводит Ionic или Capacitor проект с Ionic Appflow на Capgo: живые обновления, сборки и публикация в стор. CX Codex +1 653установок capacitor-app-upgrade-v6-to-v7 Ведёт приложение на Capacitor с версии 6 на 7: сначала автоматическая миграция, потом ручной чек-лист по iOS, Android и плагинам. CX Codex +1 643установок capacitor-app-upgrade-v5-to-v6 Ведёт приложение на Capacitor с версии 5 на 6: запускает npx cap migrate, потом добивает ручной чеклист по Android и iOS. CX Codex +1 639установок capacitor-plugin-upgrade-v4-to-v5 Ведёт плагин Capacitor с версии 4 на 5: запускает официальный мигратор, потом добивает Gradle, Java 17 и правки в коде. CX Codex +1 634установок capacitor-plugin-upgrade-v5-to-v6 Ведёт плагин Capacitor с версии 5 на 6: запускает официальный мигратор, потом добивает ручной чек-лист по Gradle, Kotlin и TypeScript. CX Codex +1 633установок

Спонсоры проекта

Компании, которые помогают держать аналитику открытой