Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Using relative paths for ENTRY_FILE now end up in build failure #36186

Closed
DomiR opened this issue Feb 16, 2023 · 10 comments
Closed

[Android] Using relative paths for ENTRY_FILE now end up in build failure #36186

DomiR opened this issue Feb 16, 2023 · 10 comments
Labels
Impact: Bug The issue represents a bug somewhere Tool: Gradle

Comments

@DomiR
Copy link

DomiR commented Feb 16, 2023

Description

Before bb02ccf we were able to run ENTRY_FILE="./index.custom.js" npx react-native android --variant="release" but now I get:

* What went wrong:
A problem was found with the configuration of task ':app:createBundleConnectdevReleaseJsAndAssets' (type 'BundleHermesCTask').
  - In plugin 'com.facebook.react' type 'com.facebook.react.tasks.BundleHermesCTask' property 'entryFile' specifies file '$HOME/rn-project/android/app/index.custom.js' which doesn't exist.

It seems that the entry file is now resolved relative to the android root project. Not sure if this was intended.

Version

0.71.3

Output of npx react-native info

System:
    OS: macOS 13.2.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 799.56 MB / 64.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.14.0 - ~/.cache/fnm_multishells/16825_1676559821539/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 9.3.1 - ~/.cache/fnm_multishells/16825_1676559821539/bin/npm
    Watchman: 2023.01.23.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /opt/homebrew/lib/ruby/gems/3.1.0/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
    Android SDK:
      System Images: android-30 | ARM 64 v8a
      Android NDK: 24.0.8215888
  IDEs:
    Android Studio: 2022.1 AI-221.6008.13.2211.9477386
    Xcode: 14.2/14C18 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.17 - /Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0
    react-native: 0.71.3 => 0.71.3
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

Build release variant while passing in relative path for ENTRY_FILE.

Snack, code example, screenshot, or link to a repository

* What went wrong:
A problem was found with the configuration of task ':app:createBundleConnectdevReleaseJsAndAssets' (type 'BundleHermesCTask').
  - In plugin 'com.facebook.react' type 'com.facebook.react.tasks.BundleHermesCTask' property 'entryFile' specifies file '$HOME/rn-project/android/app/index.custom.js' which doesn't exist.
@cortinico
Copy link
Contributor

property 'entryFile' specifies file '$HOME/rn-project/android/app/index.custom.js' which doesn't exist.

Does the file '$HOME/rn-project/android/app/index.custom.js' exists?

@DomiR
Copy link
Author

DomiR commented Feb 17, 2023

It is exists in the root folder, which is were react-native init puts index.js: '$HOME/rn-project/index.custom.js'

Now it expects the path of the entry file to be relative to the android root: '$HOME/rn-project/android/app' which was not the case before. I guess ENTRY_FILE="../../index.custom.js" npx react-native android --variant="release" would work but it's not consistent with iOS.

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Feb 17, 2023
@cortinico cortinico changed the title Using relative paths now end up in build failure [Android] Using relative paths for ENTRY_FILE now end up in build failure Feb 17, 2023
@cortinico cortinico added Tool: Gradle Impact: Bug The issue represents a bug somewhere and removed Needs: Attention Issues where the author has responded to feedback. labels Feb 17, 2023
cortinico added a commit to cortinico/react-native that referenced this issue Feb 17, 2023
Summary:
Fixes facebook#36186

Changelog:
[Android] [Fixed] - ENTRY_FILE should resolve relative paths from root

Differential Revision: D43392121

fbshipit-source-id: 0b3a704e764ac620ab3c935270041e7db8f17ee2
@DomiR
Copy link
Author

DomiR commented Feb 17, 2023

@cortinico Thank you very much for looking into this! Cheers 🍻

cortinico added a commit that referenced this issue Mar 6, 2023
Summary:
Pull Request resolved: #36193

Fixes #36186

Changelog:
[Android] [Fixed] - ENTRY_FILE should resolve relative paths from root

Reviewed By: cipolleschi

Differential Revision: D43392121

fbshipit-source-id: ddf302d333c5fc5f822e0635a73e5b52470140ee
kelset pushed a commit that referenced this issue Mar 6, 2023
Summary:
Pull Request resolved: #36193

Fixes #36186

Changelog:
[Android] [Fixed] - ENTRY_FILE should resolve relative paths from root

Reviewed By: cipolleschi

Differential Revision: D43392121

fbshipit-source-id: ddf302d333c5fc5f822e0635a73e5b52470140ee
OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this issue May 22, 2023
…6193)

Summary:
Pull Request resolved: facebook#36193

Fixes facebook#36186

Changelog:
[Android] [Fixed] - ENTRY_FILE should resolve relative paths from root

Reviewed By: cipolleschi

Differential Revision: D43392121

fbshipit-source-id: ddf302d333c5fc5f822e0635a73e5b52470140ee
@Gijuno
Copy link

Gijuno commented Jul 3, 2023

A similar error shows in react-native 0.71.11 ("specifies file '$HOME/PROJECT/android/app/index.js' which doesn't exist."),
while > Task :app:createBundleDevelopmentJsAndAssets,
when run ./gradlew clean assembleDevelopmentin android/.
I set entryFile paths already ("src/index.tsx").
Is there any new way? @cortinico

@marouane-edghoughi
Copy link

A similar error shows in react-native 0.71.11 ("specifies file '$HOME/PROJECT/android/app/index.js' which doesn't exist."), while > Task :app:createBundleDevelopmentJsAndAssets, when run ./gradlew clean assembleDevelopmentin android/. I set entryFile paths already ("src/index.tsx"). Is there any new way? @cortinico

I was able to solve this error by setting the entryFile path inside android/app/build.gradle
Navigating from the actual file: entryFile = file("../../index.tsx"), knowing that my index.tsx is located in the root of my project. So make sure you're going back to the root from your current location then to your src folder.

@github-actions github-actions bot added the Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. label Jul 21, 2023
@cortinico cortinico removed the Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. label Jul 25, 2023
@charlee-dev
Copy link

charlee-dev commented Oct 11, 2023

in my case i had to add entry in the android/app/build.gradle.kts react block:

react {
  entryFile = file("../../index.tsx")
}

but I've got more android modules in my project so for others path may be entryFile = file("../index.tsx")

@eman747
Copy link

eman747 commented Mar 28, 2024

change index.ts or index.tsx to index.js

@KingAmo
Copy link

KingAmo commented Apr 9, 2024

how to skip bundle generation step? i have a brown field android app,and my React-Native code is in another project,when integration with react native, i have this error.

@PaulHryn
Copy link

PaulHryn commented Jun 8, 2024

how to skip bundle generation step? i have a brown field android app,and my React-Native code is in another project,when integration with react native, i have this error.

did you found any solution?

@KingAmo
Copy link

KingAmo commented Jun 9, 2024

how to skip bundle generation step? i have a brown field android app,and my React-Native code is in another project,when integration with react native, i have this error.

did you found any solution?

see #44035

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Impact: Bug The issue represents a bug somewhere Tool: Gradle
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants