Compared to previous updates, the transition from Capacitor 4 to Capacitor 5 involves minimal breaking changes. This guide provides step-by-step instructions for updating your project to Capacitor 5, as well as a list of breaking changes for official plugins.
注記Capacitor 5 は、NodeJS 16 以上が必要です。Node 12 はすでにサポート終了しており、Node 14 は 2023 年 4 月 30 日にサポート終了予定です。最新の LTS バージョンの NodeJS を使用することをお勧めします。
-
Capacitor 5をインストールします。
latestCapacitor 5 の Capacitor CLI をプロジェクト内で更新するnpm i -D @capacitor/cli@latest -
Capacitor 5 にアップグレードするには、以下のコマンドを実行して、CLI がマイグレーションを管理するようにします。
npx cap migrateアップグレードの際に、migrationステップのいくつかが実行できない場合、ターミナル出力に追加情報が提供されます。 以下に手動でのmigrationステップが記載されています。
-
Capacitor 4からCapacitor 5にアップデートする場合、Visual Studio の Code 拡張機能がインストールされている場合は、拡張機能の推奨事項セクションでプロジェクトを Capacitor 5に移行するオプションを確認してください。
Upgrading Capacitor 4 iOS Project to Capacitor 5
-
アップグレード Xcode: Capacitor 5 requires Xcode 14.1+.
-
Capacitor 5 へのアップデート: __CAPGO_KEEP_0__ から __CAPGO_KEEP_1__ へのアップグレードを行ってください。
.gitignore: ファイルを更新してください。- App/Podfile.lock + App/output -
Update Assets を使用して、単一のアプリアイコンを使用するように変更してください。コンテキスト: 解決策 ページのアプリ例のセクション。役割: 画像の代替テキスト。見られる場所: コンポーネント解決策/ SolutionAppExample.astro。メッセージキー `solution_app_examples_icon_alt` (Solution App Examples Icon Alt)。
Upgrading Capacitor 4 Android Project to Capacitor 5
-
__CAPGO_KEEP_0__ 4 Android Project を __CAPGO_KEEP_1__ 5 にアップグレードする: Capacitor 5 requires Android Studio Flamingo | 2022.2.1 or newer due to the usage of Gradle 8, which requires Java JDK 17. Java 17 ships with Android Studio Flamingo, so no additional downloads are needed.
-
: __CAPGO_KEEP_0__ 5 では、Gradle 8 の使用により、Java JDK 17 が必要です。Java 17 は Android Studio Flamingo に含まれているため、追加のダウンロードは必要ありません。AGP Upgrade Assistant を実行してください。
Tools -> AGP Upgrade Assistant. -
: Android Studio は、Gradle とパッケージをビルドファイルに移動する関連する更新を助けることができます。始めるには、Android Project Variables を更新してください。
variables.gradle: ご自身のファイルを更新してください。値を、以下の新しい最小値に更新してください。minSdkVersion = 22 compileSdkVersion = 33 targetSdkVersion = 33 androidxActivityVersion = '1.7.0' androidxAppCompatVersion = '1.6.1' androidxCoordinatorLayoutVersion = '1.2.0' androidxCoreVersion = '1.10.0' androidxFragmentVersion = '1.5.6' coreSplashScreenVersion = '1.0.0' androidxWebkitVersion = '1.6.1' junitVersion = '4.13.2' androidxJunitVersion = '1.1.5' androidxEspressoCoreVersion = '3.5.1' cordovaAndroidVersion = '10.1.1' -
アップデート Google Services:
# build.gradle dependencies { - classpath 'com.google.gms:google-services:4.3.13' + classpath 'com.google.gms:google-services:4.3.15' } -
Gradle プラグインを 8.0.0 にアップデート:
# build.gradle dependencies { - classpath 'com.android.tools.build:gradle:7.2.1' + classpath 'com.android.tools.build:gradle:8.0.0' } -
Gradle ラッパーを 8.0.2 にアップデート:
# gradle-wrapper.properties distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists - distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip + distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -
Jetifier を無効化:
# gradle.properties android.useAndroidX=true - android.enableJetifier=true -
パッケージを移動
build.gradle:# AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> - <manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="[YOUR_PACKAGE_ID]"> + <manifest xmlns:android="http://schemas.android.com/apk/res/android"># build.gradle android { + namespace "[YOUR_PACKAGE_ID]" compileSdkVersion rootProject.ext.compileSdkVersion -
androidScheme をアップデート: Capacitor 6 については、
httpsのデフォルト設定になります。既存のアプリケーションでは、__CAPGO_KEEP_0__ アプリケーションがシステムの Autofill 機能を使用できるようにするために、androidSchemefor existing apps to better enable Capacitor applications to use the system Autofill feature. To avoid data loss as a result of this change, set the scheme tohttpを設定してください。{ server: { androidScheme: "http" } } -
Kotlin バージョンをアップデート: Kotlin を使用するプロジェクトでは、
kotlin_version変数を'1.8.20'.
プラグイン機能の変更
以下のプラグイン機能が変更または削除されました。codeを更新してください。
- アクションシート
- ブラウザ
- カメラ
- デバイス
- 位置情報
- Google マップ
- ローカル通知
- プッシュ通知
- ステータスバー
アクション シート
- アップデート
androidxMaterialVersion変数を1.8.0.
ブラウザ
- アップデート
androidxBrowserVersion変数を1.5.0.
カメラ
- Android 13 の場合、読み取り用メディア イメージの権限を追加してください (
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>の内側にAndroidManifest.xml. - アップデート
androidxMaterialVersion変数を1.8.0. - アップデート
androidxExifInterfaceVersion変数を1.3.6.
デバイス
- 変更
DeviceId.uuidにDeviceId.identifier. - iOS 16+ では、
DeviceInfo.name適切な特権を追加しない限り、一般的なデバイス名が返されます。 位置情報.
更新
- に
playServicesLocationVersionGoogle マップ21.0.1.
以下の変数を更新してください:
- __CAPGO_KEEP_0__
googleMapsPlayServicesVersionに18.1.0.googleMapsUtilsVersionに3.4.0.googleMapsKtxVersionに3.4.0.googleMapsUtilsKtxVersionに3.4.0.kotlinxCoroutinesVersionに1.6.4.androidxCoreKTXVersionに1.10.0.kotlin_versionローカル通知1.8.20.
Android 13では、ローカル通知をスケジュールするために必要な新しいランタイムパーミッションチェックが実行されます。__CAPGO_KEEP_0__ 33をターゲットにすると、
- For Android 13, a new runtime permission check is required to schedule local notifications when targeting SDK 33. Call
checkPermissions()したがって。requestPermissions()プッシュ通知
Android 13では、プッシュ通知の機能が削除されました。代わりに、ローカル通知を使用してユーザーに通知を送信する必要があります。
- Android 13では、SDK 33. Callに対してプッシュ通知を受け取るために必要な新しい実行時許可チェックが必要です。
checkPermissions()とrequestPermissions()したがって。 - を更新する
firebaseMessagingVersionに23.1.2.
ステータスバー
- iOSでは、デフォルトのステータスバーのアニメーションが変更されました。
FADE.
これらのステップに従い、code を更新すると、Capacitor 4からCapacitor 5にプロジェクトを更新することができました。すべての機能とプラグインが期待どおりに動作することを確認するために、必ずアプリケーションを徹底的にテストしてください。
Updating from Capacitor 4 to Capacitor 5: A Step-by-Step Guide
Capacitor 4を使用している場合 Updating from Capacitor 4 to Capacitor 5: A Step-by-Step Guide nativeプラグインの作業を計画するには、__CAPGO_KEEP_0__ を接続する必要があります Capgo プラグイン ディレクトリ for the product workflow in Capgo Plugin Directory, Capacitor Plugins by Capgo for the implementation detail in Capacitor Plugins by Capgo, プラグインの追加または更新 プラグインの追加または更新 イオニック エンタープライズ プラグインの代替 Capacitor 4 から Capacitor 5 へのアップデート Capgo Native Builds for the product workflow in Capgo Native Builds.