メインコンテンツにジャンプします
Capacitor

Capacitor 4からCapacitor 5へのアップデート: ステップバイステップのガイド

Capacitor 4からCapacitor 5へのアップデート: ステップバイステップのガイド

マーチン・ドナディュー

マーチン・ドナディュー

コンテンツマーケター

Capacitor 4からCapacitor 5へのアップデート: ステップバイステップのガイド

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.

  1. __CAPGO_KEEP_3__ latest Capacitor 5 の Capacitor CLI をプロジェクト内で使用している場合:

    npm i -D @capacitor/cli@latest
  2. 以下のコマンドを実行して、CLI がマイグレーションを管理するようにします:

    npx cap migrate

    マイグレーションステップが実行できなかった場合は、ターミナル出力に追加情報が表示されます。手動で実行するマイグレーションステップは以下のとおりです。

  3. 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

  1. Xcode をアップグレードする: Capacitor 5 requires Xcode 14.1+.

  2. .gitignore をアップデートする: 以下の変更を実行してください。 .gitignore ファイルをアップデートする

    - App/Podfile.lock
    + App/output
  3. アプリのアイコンを 1 つのアイコンにアップデートするコンテキスト: ソリューション ページのアプリの例のセクション。ロール: 画像の代替テキスト。見られる場所: コンポーネント ソリューション / SolutionAppExample.astro。メッセージ キー `solution_app_examples_icon_alt` (ソリューション アプリの例のアイコンの代替テキスト)。

Upgrading Capacitor 4 Android Project to Capacitor 5

  1. 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.

  2. AGP アップグレード アシスタントを実行する: Android Studio は、Gradle とパッケージをビルド ファイルに移動する関連する更新を助けることができます。実行するには Tools -> AGP Upgrade Assistant.

  3. Android Project 変数を更新する: 以下の新しい最小値に更新する必要があります。 variables.gradle Google 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'
  4. 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'
    }
  5. 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'
    }
  6. 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
  7. __CAPGO_KEEP_0__:

    # gradle.properties
    android.useAndroidX=true
    - android.enableJetifier=true
  8. パッケージを移動する 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
  9. androidSchemeを更新する: Capacitor 6 から https 既存のアプリケーションには、__CAPGO_KEEP_0__ アプリケーションがシステムのオートフィル機能を使用できるようにするために、 androidScheme for 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 to http に設定する必要があります。 これは、現在のデフォルト値でもかまいません。

    {
      server: {
        androidScheme: "http"
      }
    }
  10. 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 適切な特権を追加しない限り 特権.

位置情報

  • 更新 playServicesLocationVersion to 21.0.1.

Google Maps

  • 更新する変数
    • googleMapsPlayServicesVersion to 18.1.0.
    • googleMapsUtilsVersion to 3.4.0.
    • googleMapsKtxVersion to 3.4.0.
    • googleMapsUtilsKtxVersion to 3.4.0.
    • kotlinxCoroutinesVersion to 1.6.4.
    • androidxCoreKTXVersion to 1.10.0.
    • kotlin_version to 1.8.20.

Local Notifications

  • For Android 13, a new runtime permission check is required to schedule local notifications when targeting SDK 33. Call checkPermissions() and requestPermissions() accordingly.

Push Notifications

  • For Android 13, a new runtime permission check is required to receive push notifications when targeting SDK 33. Call checkPermissions() and requestPermissions() 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 ネイティブ ビルドのワークフローについて

リアルタイムの更新が Capacitor アプリにあります。

ウェブ層のバグが生じた場合、Capgo を通じて修正を配信し、数日間待つ必要のないアプリストアの承認を待つ必要がなくなる。

マーティンから人間のサポートを受けます。

今すぐ始めましょう。

最新のブログ記事

Capgo は、プロフェッショナルなモバイルアプリを作成するために必要な最良の洞察を提供します。