expo: [SDK 49][expo-updates][android] gradle plugin error on build when running on Windows

Minimal reproducible example

https://github.com/yerevin/expo-updates-node-issue

Summary

Hi,

After upgrade from Expo 48 to Expo 49 I ran into issue with expo-updates gradle plugin, it throws below error related to attached line.

It is related to project with flavors as when I tried to reproduce it on simple bare-template it wasn’t an error, but after I added extra flavors it started to fail. (without multiple flavors gradle plugin doesn’t reach line with error).

I think it can be worth mention I’m on Windows 11.

Line causing error:

https://github.com/expo/expo/blob/sdk-49/packages/expo-updates/expo-updates-gradle-plugin/src/main/kotlin/expo/modules/updates/ExpoUpdatesPlugin.kt#L78

Error:

> Task :app:createDevelopmentDebugExpoManifest FAILED
'[node' is not recognized as an internal or external command,
operable program or batch file.

Off topic side note:

I think it can be worth to add multi flavor (Android) / bundle id (iOS) template to templates projects for beta testing as I think in last update from Expo 47 to Expo 48 also there was issue caught after SDK release related to projects with flavors and having multi flavor is quiet common thing. (I’m not adding it to be offensive in any way, just a tip)

Environment

expo-env-info 1.0.5 environment info: System: OS: Windows 10 10.0.22621 Binaries: Node: 16.20.0 - C:\Program Files\nodejs\node.EXE npm: 9.6.5 - C:\Program Files\nodejs\npm.CMD IDEs: Android Studio: AI-222.4459.24.2221.9862592 npmPackages: expo: 49.0.0 => 49.0.0 react: 18.2.0 => 18.2.0 react-dom: 18.2.0 => 18.2.0 react-native: 0.72.1 => 0.72.1 Expo Workflow: bare

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 19 (4 by maintainers)

Most upvoted comments

Patch fix for this issue (for expo-update@0.18.8)

diff --git a/node_modules/expo-updates/expo-updates-gradle-plugin/src/main/kotlin/expo/modules/updates/ExpoUpdatesPlugin.kt b/node_modules/expo-updates/expo-updates-gradle-plugin/src/main/kotlin/expo/modules/updates/ExpoUpdatesPlugin.kt
index 2d81db9..fa5454b 100644
--- a/node_modules/expo-updates/expo-updates-gradle-plugin/src/main/kotlin/expo/modules/updates/ExpoUpdatesPlugin.kt
+++ b/node_modules/expo-updates/expo-updates-gradle-plugin/src/main/kotlin/expo/modules/updates/ExpoUpdatesPlugin.kt
@@ -75,7 +75,7 @@ abstract class ExpoUpdatesPlugin : Plugin<Project> {
         }
 
         if (Os.isFamily(Os.FAMILY_WINDOWS)) {
-          it.commandLine("cmd", "/c", args)
+          it.commandLine("cmd", "/c", *args.toTypedArray())
         } else {
           it.commandLine(args)
         }

I am running into a similar issue on Mac after upgrading to Expo SDK 49 and react-native 0.72.4:

 ℹ️  Applying gradle plugin 'expo-updates-gradle-plugin' (expo-updates@0.18.12)

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Cannot query the value of extension 'react' property 'entryFile' because it has no value available.

This issue doesn’t occur if I use expo-updates: “~0.16.4”, however then all my expo packages don’t seem to be linking correctly and they can’t compile.

I am using gradle-7.5.1 in gradle-wrapper.properties, because I was having similar compilation issues with expo 49 and gradle, and this was the only way I could get gradle to run.

distributionUrl=https://services.gradle.org/distributions/gradle-7.5.1-all.zip

What worked for me was explicitly defining entryFile by uncommenting it in android/app/build.gradle file and then replacing it with the path of the index file which has the registerRootComponent expo method.

    //   The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
    entryFile = file("../../index.js")

NOTE: make sure that the android/app/build.gradle is updated for react-native 0.72.4 as it should be wrapped by react configuration block. https://react-native-community.github.io/upgrade-helper/?from=0.71.13&to=0.72.4

It looks like for me PR https://github.com/expo/expo/pull/23983 brought regression and I have to patch fix also line 92 Current patch fix for expo-updates@0.18.12 which I used to successfully build local development build

diff --git a/node_modules/expo-updates/expo-updates-gradle-plugin/src/main/kotlin/expo/modules/updates/ExpoUpdatesPlugin.kt b/node_modules/expo-updates/expo-updates-gradle-plugin/src/main/kotlin/expo/modules/updates/ExpoUpdatesPlugin.kt
index 6cd4226..b010ebb 100644
--- a/node_modules/expo-updates/expo-updates-gradle-plugin/src/main/kotlin/expo/modules/updates/ExpoUpdatesPlugin.kt
+++ b/node_modules/expo-updates/expo-updates-gradle-plugin/src/main/kotlin/expo/modules/updates/ExpoUpdatesPlugin.kt
@@ -75,7 +75,7 @@ abstract class ExpoUpdatesPlugin : Plugin<Project> {
         }
 
         if (Os.isFamily(Os.FAMILY_WINDOWS)) {
-          it.commandLine("cmd", "/c", args)
+          it.commandLine("cmd", "/c", *args.toTypedArray())
         } else {
           it.commandLine(args)
         }
@@ -89,7 +89,7 @@ abstract class ExpoUpdatesPlugin : Plugin<Project> {
       project.exec {
         val args = listOf(*nodeExecutableAndArgs.get().toTypedArray(), "-e", "console.log(require('path').dirname(require.resolve('expo-updates/package.json')));")
         if (Os.isFamily(Os.FAMILY_WINDOWS)) {
-          it.commandLine("cmd", "/c", args)
+          it.commandLine("cmd", "/c", *args.toTypedArray())
         } else {
           it.commandLine(args)
         }

@weykon were you able to build successfully without patch fix on line 92 after upgrade to expo-update@0.18.12?

Patch fix for this issue

diff --git a/node_modules/expo-updates/expo-updates-gradle-plugin/src/main/kotlin/expo/modules/updates/ExpoUpdatesPlugin.kt b/node_modules/expo-updates/expo-updates-gradle-plugin/src/main/kotlin/expo/modules/updates/ExpoUpdatesPlugin.kt
index 2d81db9..fa5454b 100644
--- a/node_modules/expo-updates/expo-updates-gradle-plugin/src/main/kotlin/expo/modules/updates/ExpoUpdatesPlugin.kt
+++ b/node_modules/expo-updates/expo-updates-gradle-plugin/src/main/kotlin/expo/modules/updates/ExpoUpdatesPlugin.kt
@@ -75,7 +75,7 @@ abstract class ExpoUpdatesPlugin : Plugin<Project> {
         }
 
         if (Os.isFamily(Os.FAMILY_WINDOWS)) {
-          it.commandLine("cmd", "/c", args)
+          it.commandLine("cmd", "/c", *args.toTypedArray())
         } else {
           it.commandLine(args)
         }

it worked with #23983 code !

even after installing expo-updates still getting same error. Tried this solution as well. Can anyone update on this?

It appears that this is fixed in https://github.com/expo/expo/pull/23983 .

@Kudo

@RicardoBrito1938 Can you paste the command you are running? It looks like issue is in command you are running than some build level error

Yes , sure, here it it

npx expo prebuild --clean

cd android

./gradlew clean

./gradlew assembleRelease --stacktrace --debug

These are the local commands I run to get the same error eas is triggering

@RicardoBrito1938 Can you paste the command you are running? It looks like issue is in command you are running than some build level error

Hey guys, i got build failed but it happened with this message

“> Task :app:createBundleReleaseJsAndAssets FAILED Unknown or unexpected option: --platform”