Skip to content

Instantly share code, notes, and snippets.

@biomazi
Last active May 30, 2025 16:43
Show Gist options
  • Save biomazi/4a0cd21a31db78f6d45bfabc52838772 to your computer and use it in GitHub Desktop.
Save biomazi/4a0cd21a31db78f6d45bfabc52838772 to your computer and use it in GitHub Desktop.
Expo build setup

This article will guide you through building Expo application for deployment to GPC and Test Flight

If you dont have expo-dev-client you need to install it for development builds: npx expo install expo-dev-client

Build with EAS

  1. Create eas account on https://expo.dev/eas

  2. install eas globally on your machine npm install -g eas-cli

  3. login into eas account eas login

  4. configure project for Eas build eas build:configure

  5. modify your eas.json to include env variables and types of packages you want built

  "cli": {
    "version": ">= 12.5.2",
    "appVersionSource": "remote"
  },
  "build": {
    "development": {
      "developmentClient": true,
      "distribution": "internal",
      "env": {
          "EXPO_PUBLIC_API": "https://your-api-address.com"
      }
    },
    "preview": {
      "distribution": "internal",
      "buildType": "apk",
      "env": {
          "EXPO_PUBLIC_API": "https://your-api-address.com"
      }
    },
    "preview-apk": {
      "android": {
          "buildType": "apk"
      }
      "distribution": "internal",
      "env": {
          "EXPO_PUBLIC_API": "https://your-api-address.com"
      }
    },
    "production": {
      "autoIncrement": true,
      "env": {
          "EXPO_PUBLIC_API": "https://your-api-address.com"
      }
    }
  },
  "submit": {
    "production": {}
  }
}
  1. run build with --local flag, this will create needed credentials for android and ios and store on eas server, provide --profile(-e) and --platform(-p) or select platform in terminal, you can only build one platform at time locally eas build -e production -p android —local
  2. add eas.json, credentials.json and credentials folder to .gitignore
  3. check docs for more details https://docs.expo.dev/build/setup/

In case of "error Distribution certificate with fingerprint xxxxxxxxxxx hasn't been imported successfully" follow steps presented here

This process uses remote credentials from EAS, you can read more details at managed credentials.

Using local credentials

To use local credentials you need to follow steps outlined at using local credentials for CI. My preferred workflow is to let EAS automaticly generate signature keys for android and apple apps, and then we can download them directly through eas credentials into app and set CI tools to use local credentials if we dont want to use EAS hosted credentials.

Summarized setup steps

  1. put keystore (android) and Distribution Certificate and Provisioning Profile (for ios) to .gitignore. android/keystores/release.keystore ios/certs/*

  2. update eas.json to use local credentials, e.g:

  "build": {
    "amazon-production": {
      "android": {
        "credentialsSource": "local"
      }
    },
    "google-production": {
      "android": {
        "credentialsSource": "remote"
      }
    }
  }
}
  1. convert credentials.json to a base64-encoded string, set an environment variable to that value, and later decode it and restore the file on the CI. base64 credentials.json
  2. set CI env variable CREDENTIALS_JSON_BASE64 to output from above command
  3. on CI restore base64 string to credentials.json echo $CREDENTIALS_JSON_BASE64 | base64 -d > credentials.json
  4. repeat steps 3-5 for keystore, provisioning profile and distribution certificate so you can provide them to CI.

Build android with android studio or gradlew

In case you need to build android app directly, you need to do following steps:

  1. prebuild code with expo so you create android folder npx expo prebuild --clean

  2. create upload key and keystore, follow instructions here or use keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000

  3. cd android && ./gradlew bundleRelease (builds .aap for play store or use assembleReleaase to build .apk)

  4. in android/gradle.properties add

MY_UPLOAD_KEYSTORE_FILE=keystore.jks # or name of your keystore file
MY_UPLOAD_KEYSTORE_PASSWORD=YOUR_KEYSTORE_PASSWORD
MY_UPLOAD_KEY_ALIAS=YOUR_KEY_ALIAS
MY_UPLOAD_KEY_PASSWORD=YOUR_KEY_PASSWORD
  1. in android/app/build.gradle add inside signingConfigs
        release {
            if(project.hasProperty('MY_UPLOAD_KEYSTORE_FILE')) {
                storeFile file(MY_UPLOAD_KEYSTORE_FILE)
                storePassword MY_UPLOAD_KEYSTORE_PASSWORD
                keyAlias MY_UPLOAD_KEY_ALIAS
                keyPassword MY_UPLOAD_KEY_PASSWORD
            }
        }
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
    }

under buildTypes.release.signingConfis.debug => signingConfigs.release

  1. instead of step 5, you can follow this guide for keeping build keys secure

  2. you can use android studio instead of step 3.

Read more about configuring eas.json on https://docs.expo.dev/build/eas-json/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment