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.
: __CAPGO_KEEP_0__ 5では、NodeJS 16以上が必要です。Node 12はすでにサポート終了しており、Node 14は2023年4月30日にサポート終了予定です。最新のLTSバージョンのNodeJSを使用することをお勧めします。: Capacitor 5 requires NodeJS 16 or higher, as Node 12 has reached end-of-life and Node 14 will reach end-of-life on April 30th, 2023. It is recommended to use the latest LTS version of NodeJS.
-
__CAPGO_KEEP_3__
latestCapacitor 5 の Capacitor CLI をプロジェクト内で使用している場合:npm i -D @capacitor/cli@latest -
以下のコマンドを実行して、CLI がマイグレーションを管理するようにします:
npx cap migrateマイグレーションステップが実行できなかった場合は、ターミナル出力に追加情報が表示されます。手動で実行するマイグレーションステップは以下のとおりです。
-
If you have the VS Code extension installed, check the recommendations section of the extension to find the option to migrate your project to Capacitor 5.
Upgrading Capacitor 4 iOS Project to Capacitor 5
-
Xcode をアップグレードする: Capacitor 5 requires Xcode 14.1+.
-
.gitignore をアップデートする: 以下の変更を実行してください。
.gitignoreファイルをアップデートする- App/Podfile.lock + App/output -
アプリのアイコンを 1 つのアイコンにアップデートするコンテキスト: ソリューション ページのアプリの例のセクション。ロール: 画像の代替テキスト。見られる場所: コンポーネント ソリューション / SolutionAppExample.astro。メッセージ キー `solution_app_examples_icon_alt` (ソリューション アプリの例のアイコンの代替テキスト)。
Upgrading Capacitor 4 Android Project to Capacitor 5
-
Android Studio をアップグレードする: 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.
-
AGP アップグレード アシスタントを実行する: Android Studio は、Gradle とパッケージをビルド ファイルに移動する関連する更新を助けることができます。実行するには
Tools -> AGP Upgrade Assistant. -
Android Project 変数を更新する: 以下の新しい最小値に更新する必要があります。
variables.gradleGoogle Services を更新する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' -
Gradle プラグインを 8.0.0 に更新する:
# build.gradle dependencies { - classpath 'com.google.gms:google-services:4.3.13' + classpath 'com.google.gms:google-services:4.3.15' } -
Gradle ラッパーを 8.0.2 に更新する:
# build.gradle dependencies { - classpath 'com.android.tools.build:gradle:7.2.1' + classpath 'com.android.tools.build:gradle:8.0.0' } -
Jetifier を無効にする:
# 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 -
__CAPGO_KEEP_0__:
# 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__ アプリケーションがシステムのオートフィル機能を使用できるようにするために、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 マップ
- ローカル通知
- Push通知
- ステータスバー
アクションシート
- 更新する
androidxMaterialVersion変数を1.8.0.
ブラウザ
- Capacitor 5 にアップグレードする
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.
に
- Live Update
DeviceId.uuid__CAPGO_KEEP_0__DeviceId.identifier. - iOS 16以降では
DeviceInfo.name適切な特権を追加しない限り 特権.
位置情報
- 更新
playServicesLocationVersionto21.0.1.
Google Maps
- 更新する変数
googleMapsPlayServicesVersionto18.1.0.googleMapsUtilsVersionto3.4.0.googleMapsKtxVersionto3.4.0.googleMapsUtilsKtxVersionto3.4.0.kotlinxCoroutinesVersionto1.6.4.androidxCoreKTXVersionto1.10.0.kotlin_versionto1.8.20.
Local Notifications
- For Android 13, a new runtime permission check is required to schedule local notifications when targeting SDK 33. Call
checkPermissions()andrequestPermissions()accordingly.
Push Notifications
- For Android 13, a new runtime permission check is required to receive push notifications when targeting SDK 33. Call
checkPermissions()andrequestPermissions()accordingly. - Update the
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 ネイティブ プラグインの作業を計画するには、__CAPGO_KEEP_0__ Plugin Directory に接続します。 Capgo Plugin Directory for the product workflow in Capgo Plugin Directory, Capacitor Plugins by Capgo for the implementation detail in Capacitor Plugins by Capgo, プラグインの追加または更新 プラグインの追加または更新の実装詳細について イオニック エンタープライズ プラグインの代替 イオニック エンタープライズ プラグインのワークフローについて Capgo ネイティブ ビルド Capgo ネイティブ ビルドのワークフローについて