[React Native] EAS Buildで.apkファイルを生成する方法

スポンサーリンク

概要

React Nativeアプリをeas buildコマンドでビルドすると、デフォルトでは.aabファイルが生成される。
.apkファイルを生成したい場合はeas.jsonに設定を追加する必要がある。

追加する設定

"production": {
    "android": {
       "buildType": "apk"
    }
}

サンプル

{
  "cli": {
    "version": ">= 5.9.1"
  },
  "build": {
    "development": {
      "developmentClient": true,
      "distribution": "internal",
      "android": {
        "gradleCommand": ":app:assembleDebug"
      },
      "ios": {
        "buildConfiguration": "Debug"
      }
    },
    "preview": {
      "distribution": "internal"
    },
    "production": {
      "android": {
        "buildType": "apk"
      }
    }
  },
  "submit": {
    "production": {}
  }
}

参考サイト

Build APKs for Android Emulators and devices
Learn how to configure and install an .apk for Android Emulators and devices when using EAS Build.

Development buildを使う場合

development buildを実行して.apkファイルを生成することもできる。
https://docs.expo.dev/develop/development-builds/create-a-build/

  1. npx expo install expo-dev-client
  2. eas login
  3. touch ees.json
  4. eas build --profile development --platform android
  5. ビルド後に表示されるURLにアクセスし、Build artifactから.apkファイルをダウンロード可能
{
  "build": {
    "development": {
      "developmentClient": true,
      "distribution": "internal"
    },
    "preview": {
      "distribution": "internal"
    },
    "production": {}
  }
}

おすすめ書籍

コメント