Expo Publish failing

Since last few hours I am noticing this odd error when trying to run expo publish in my circle ci environment…

#!/bin/bash -eo pipefail
npx expo-cli publish --non-interactive --max-workers 1 --release-channel $EXPO_RELEASE_CHANNEL --target bare

[04:42:40] › Expo SDK: 40.0.0
[04:42:40] › Release channel: develop-1.2.0
[04:42:40] › Workflow: Bare

[04:42:40] Building optimized bundles and generating sourcemaps...
[04:42:42] Starting Metro Bundler
Building JavaScript bundle [] 20%Building JavaScript bundle [] 21%Building JavaScript bundle [] 22%Building JavaScript bundle [] 23%Building JavaScript bundle [] 24%Building JavaScript bundle [] 25%Building JavaScript bundle [] 26%Building JavaScript bundle [] 27%Building JavaScript bundle [] 28%Building JavaScript bundle [] 30%Building JavaScript bundle [] 31%Building JavaScript bundle [] 32%Building JavaScript bundle [] 33%Building JavaScript bundle [] 34%Building JavaScript bundle [] 35%Building JavaScript bundle [] 36%Building JavaScript bundle [] 37%Building JavaScript bundle [] 38%Building JavaScript bundle [] 39%Building JavaScript bundle [] 40%Building JavaScript bundle [] 41%Building JavaScript bundle [] 42%Building JavaScript bundle [] 43%Building JavaScript bundle [] 44%Building JavaScript bundle [] 45%Building JavaScript bundle [] 46%Building JavaScript bundle [] 47%Building JavaScript bundle [] 48%Building JavaScript bundle [] 49%Building JavaScript bundle [] 50%Building JavaScript bundle [] 51%Building JavaScript bundle [] 52%Building JavaScript bundle [] 53%Building JavaScript bundle [] 54%Building JavaScript bundle [] 55%Building JavaScript bundle [] 56%Building JavaScript bundle [] 57%Building JavaScript bundle [] 59%Building JavaScript bundle [] 60%Building JavaScript bundle [] 61%Building JavaScript bundle [] 62%Building JavaScript bundle [] 63%Building JavaScript bundle [] 64%Building JavaScript bundle [] 65%Building JavaScript bundle [] 66%Building JavaScript bundle [] 67%Building JavaScript bundle [] 68%Building JavaScript bundle [] 69%Building JavaScript bundle [] 70%Building JavaScript bundle [] 71%Building JavaScript bundle [] 72%Building JavaScript bundle [] 73%Building JavaScript bundle [] 74%Building JavaScript bundle [] 75%Building JavaScript bundle [] 76%Building JavaScript bundle [] 77%Building JavaScript bundle [] 78%Building JavaScript bundle [] 79%Building JavaScript bundle [] 80%Building JavaScript bundle [] 81%Building JavaScript bundle [] 82%Building JavaScript bundle [] 83%Building JavaScript bundle [] 84%Building JavaScript bundle [] 85%Building JavaScript bundle [] 86%Building JavaScript bundle [] 87%Building JavaScript bundle [] 88%Building JavaScript bundle [] 89%Building JavaScript bundle [] 90%Building JavaScript bundle [] 91%Building JavaScript bundle [] 92%Building JavaScript bundle [] 93%Building JavaScript bundle [] 94%Building JavaScript bundle [] 95%Building JavaScript bundle [] 96%Building JavaScript bundle [] 97%Building JavaScript bundle [] 98%Building JavaScript bundle [] 99%Building JavaScript bundle [] 100%[04:44:50] Finished building JavaScript bundle in 127253ms.
[04:44:50] JavaScript engine configuration is inconsistent between app.json and Android native project.
In app.json: Hermes is not enabled
In Android native project: Hermes is enabled
Please check the following files for inconsistencies:
  - /home/circleci/repo/app.json
  - /home/circleci/repo/android/gradle.properties
  - /home/circleci/repo/android/app/build.gradle

[04:44:50] Error: JavaScript engine configuration is inconsistent between app.json and Android native project.
In app.json: Hermes is not enabled
In Android native project: Hermes is enabled
Please check the following files for inconsistencies:
  - /home/circleci/repo/app.json
  - /home/circleci/repo/android/gradle.properties
  - /home/circleci/repo/android/app/build.gradle

    at /home/circleci/.npm/_npx/116/lib/node_modules/expo-cli/node_modules/@expo/dev-server/src/MetroDevServer.ts:184:17
    at async Promise.all (index 0)
    at Object.bundleAsync (/home/circleci/.npm/_npx/116/lib/node_modules/expo-cli/node_modules/@expo/dev-server/src/MetroDevServer.ts:169:12)
    at Object.createBundlesAsync (/home/circleci/.npm/_npx/116/lib/node_modules/expo-cli/node_modules/xdl/src/project/createBundlesAsync.ts:90:26)
    at Object.publishAsync (/home/circleci/.npm/_npx/116/lib/node_modules/expo-cli/node_modules/xdl/src/project/publishAsync.ts:92:19)
    at action (/home/circleci/.npm/_npx/116/lib/node_modules/expo-cli/src/commands/publish.ts:86:18)
    at Command.<anonymous> (/home/circleci/.npm/_npx/116/lib/node_modules/expo-cli/src/exp.ts:351:7)

Exited with code exit status 1
CircleCI received exit code 1

Any ideas why this might be happening?

Regards

hi there!

this may have been caused by the latest release (4.6.0) of expo-cli. i rolled back expo-cli to 4.5.2 for now and we will investigate this tomorrow. can you share the contents of your android/gradle.properties and android/app/build.gradle please?

Hi @notbrent

Sure, yes we locked into 4.5.2 and things are ok now.

apply plugin: "com.android.application"

import com.android.build.OutputFile

/**
 * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
 * and bundleReleaseJsAndAssets).
 * These basically call `react-native bundle` with the correct arguments during the Android build
 * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
 * bundle directly from the development server. Below you can see all the possible configurations
 * and their defaults. If you decide to add a configuration block, make sure to add it before the
 * `apply from: "../../node_modules/react-native/react.gradle"` line.
 *
 * project.ext.react = [
 *   // the name of the generated asset file containing your JS bundle
 *   bundleAssetName: "index.android.bundle",
 *
 *   // the entry file for bundle generation. If none specified and
 *   // "index.android.js" exists, it will be used. Otherwise "index.js" is
 *   // default. Can be overridden with ENTRY_FILE environment variable.
 *   entryFile: "index.android.js",
 *
 *   // https://reactnative.dev/docs/performance#enable-the-ram-format
 *   bundleCommand: "ram-bundle",
 *
 *   // whether to bundle JS and assets in debug mode
 *   bundleInDebug: false,
 *
 *   // whether to bundle JS and assets in release mode
 *   bundleInRelease: true,
 *
 *   // whether to bundle JS and assets in another build variant (if configured).
 *   // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
 *   // The configuration property can be in the following formats
 *   //         'bundleIn${productFlavor}${buildType}'
 *   //         'bundleIn${buildType}'
 *   // bundleInFreeDebug: true,
 *   // bundleInPaidRelease: true,
 *   // bundleInBeta: true,
 *
 *   // whether to disable dev mode in custom build variants (by default only disabled in release)
 *   // for example: to disable dev mode in the staging build type (if configured)
 *   devDisabledInStaging: true,
 *   // The configuration property can be in the following formats
 *   //         'devDisabledIn${productFlavor}${buildType}'
 *   //         'devDisabledIn${buildType}'
 *
 *   // the root of your project, i.e. where "package.json" lives
 *   root: "../../",
 *
 *   // where to put the JS bundle asset in debug mode
 *   jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
 *
 *   // where to put the JS bundle asset in release mode
 *   jsBundleDirRelease: "$buildDir/intermediates/assets/release",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in debug mode
 *   resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in release mode
 *   resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
 *
 *   // by default the gradle tasks are skipped if none of the JS files or assets change; this means
 *   // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
 *   // date; if you have any other folders that you want to ignore for performance reasons (gradle
 *   // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
 *   // for example, you might want to remove it from here.
 *   inputExcludes: ["android/**", "ios/**"],
 *
 *   // override which node gets called and with what additional arguments
 *   nodeExecutableAndArgs: ["node"],
 *
 *   // supply additional arguments to the packager
 *   extraPackagerArgs: []
 * ]
 */

project.ext.react = [
    enableHermes: true
]

apply from: '../../node_modules/react-native-unimodules/gradle.groovy'
apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/expo-constants/scripts/get-app-config-android.gradle"
apply from: "../../node_modules/expo-updates/scripts/create-manifest-android.gradle"

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = false

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

/**
 * The preferred build flavor of JavaScriptCore.
 *
 * For example, to use the international variant, you can use:
 * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
 *
 * The international variant includes ICU i18n library and necessary data
 * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
 * give correct results when using with locales other than en-US.  Note that
 * this variant is about 6MiB larger per architecture than default.
 */
def jscFlavor = 'org.webkit:android-jsc:+'

/**
 * Whether to enable the Hermes VM.
 *
 * This should be set on project.ext.react and mirrored here.  If it is not set
 * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
 * and the benefits of using Hermes will therefore be sharply reduced.
 */
def enableHermes = project.ext.react.get("enableHermes", false);

android {
    compileSdkVersion rootProject.ext.compileSdkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    flavorDimensions "default"

    defaultConfig {
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode findProperty("android.versionCode") as Integer
        versionName findProperty("android.versionName")
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://reactnative.dev/docs/signed-apk-android.
            signingConfig signingConfigs.debug
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
    productFlavors {
        dev {
            applicationId "com.payright.customer.dev"
            minSdkVersion rootProject.ext.minSdkVersion
            targetSdkVersion rootProject.ext.targetSdkVersion
            resValue "string", "build_config_package", "com.payright.customer.dev"
            buildConfigField "String", "INSTABUG_TOKEN", '"447d930caba52f7badf78a8a86bc0a9f"'
        }
        uat {
            applicationId "com.payright.customer.uat"
            minSdkVersion rootProject.ext.minSdkVersion
            targetSdkVersion rootProject.ext.targetSdkVersion
            resValue "string", "build_config_package", "com.payright.customer.uat"
            buildConfigField "String", "INSTABUG_TOKEN", '"447d930caba52f7badf78a8a86bc0a9f"'
        }
        prod {
            applicationId "com.payright.customer"
            minSdkVersion rootProject.ext.minSdkVersion
            targetSdkVersion rootProject.ext.targetSdkVersion
            resValue "string", "build_config_package", "com.payright.customer"
            buildConfigField "String", "INSTABUG_TOKEN", '"7cd661572e8a5b08feeac9c5c8d0710e"'
        }
    }

    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // https://developer.android.com/studio/build/configure-apk-splits.html
            def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }

        }
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    //noinspection GradleDynamicVersion
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
    debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
      exclude group:'com.facebook.fbjni'
    }
    debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.flipper'
        exclude group:'com.squareup.okhttp3', module:'okhttp'
    }
    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.flipper'
    }
    addUnimodulesDependencies()

    if (enableHermes) {
        def hermesPath = "../../node_modules/hermes-engine/android/";
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

apply plugin: 'com.google.gms.google-services'
apply from: "./eas-build.gradle"

# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true

# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

# Android versioning
android.versionCode=23
android.versionName=1.2.0

# Version of flipper SDK to use with React Native
FLIPPER_VERSION=0.54.0

Regards,

Praveen.

hi there!

from the shared gradle file, it looks like you have enabled Hermes engine.
traditionally, expo publish will just publish a plaintext javascript bundle.
just curious how you use Hermes to load a plaintext javascript bundle, even in release build.
we are asking this because we are trying to add Hermes support to expo publish.
the error message you posted is to prevent inconsistent error between javascript engine and bundle format.

would like to know more insight of Hermes + plaintext javascript bundle use cases.
thank you for providing these information.

1 Like

@kudochien I’m not quite sure honestly. But we are using react-native-reanimated and the installation instructions say to enable Hermes. Installation | React Native Reanimated

Also to mention I was having issues with the upgrade to Expo SDK 41 that may be associated, Upgrade to SDK 41 error - #2 by notbrent

Regards

@praveen_payright just to let you know that expo-cli@4.7.2 fixed the inconsistent error for SDK 41.

BTW, if you are going to use Hermes in managed workflow, you take a look for SDK 42 beta:

let us know if there are any issues. thanks!

Thanks @kudochien , we have upgraded to expo-cli 4.7.2 and latest eas-cli and things are working ok, and have updated the hermes configuration as per the latest docs, so seems all good for now, on the bare workflow.

2 Likes