Closed zaffy88 closed 1 year ago
The same question for me.
The current temporary solution is to manually generate the bundle file. Hope there is a better solution!
step 1:
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
step 2:
./gradlew clean app:assembleRelease --stacktrace -x bundleReleaseJsAndAssets
Hello, On my project we have development, staging and production debug and release variants. I'm also getting this error when trying to make a development release build. My project uses RN 0.67.3 and I haven't made any upgrade from a different version.
Other details:
classpath('com.android.tools.build:gradle:7.2.1')
Android gradle: 7.5.1
Mac OS: Monterey 12.4
MacBook Pro (13-inch, M1, 2020)
Java version: openjdk 11.0.16.1 2022-07-19 LTS
OpenJDK Runtime Environment Zulu11.58+23-CA (build 11.0.16.1+1-LTS)
OpenJDK 64-Bit Server VM Zulu11.58+23-CA (build 11.0.16.1+1-LTS, mixed mode)
With lower gradle versions, I get an error on development release build. When googling it, the solution suggested was to upgrade gradle to 7.0.+. With the above gradle config, the build is created but as @zaffy88 mentioned, when the application is opened it immediately crashes with the same error displayed on Logcat.
I found this Github PR https://github.com/facebook/react-native/pull/30177 from October 2020, but I can still reproduce it.
It is very frustrating and it blocks us from testing the Android build. Can anyone advice on how to have this issue resolved? Thank you!
./gradlew
thanks, but it doesn't work for me
Eventually, yesterday I upgraded from 0.67.3 to 0.70.0 and the Android release builds work now. I left Hermes enabled on Android only; on iOS I had some issues with Hermes enabled on my M1 Mac so I disabled it for iOS.
The issue here is caused by using different flavors.
Can you try on 0.70 and report back if the issue persists? If so, we can look into it and potentially fix it.
I don't think it's a bug but most likely a misconfig of your:
project.ext.react = [
entryFile : "index.js",
enableHermes: true,
extraPackagerArgs: [
]
]
Can you try on 0.70 and report back if the issue persists? If so, we can look into it and potentially fix it.
I have the same issue (and I'm also using flavors). It still does not work on 0.70.0 or 0.70.1.
The issue here is caused by using different flavors.
Can you try on 0.70 and report back if the issue persists? If so, we can look into it and potentially fix it.
I don't think it's a bug but most likely a misconfig of your:
project.ext.react = [ entryFile : "index.js", enableHermes: true, extraPackagerArgs: [ ] ]
Thank you for your reply, but this config can work on 0.67.3
I have the same issue (and I'm also using flavors). It still does not work on 0.70.0 or 0.70.1.
Is this happening on a blank project?
The issue here is caused by using different flavors.
Can you try on 0.70 and report back if the issue persists? If so, we can look into it and potentially fix it.
I don't think it's a bug but most likely a misconfig of your:
project.ext.react = [ entryFile : "index.js", enableHermes: true, extraPackagerArgs: [ ] ]
It still does not work on 0.70.4
Just a heads up that I fixed this and it's going to be released in RN 0.71
Just a heads up that I fixed this and it's going to be released in RN 0.71
Hey! Could you please tell us when this version is going to be released?
I can't find pull request related to this issue.
Thank you
Could you please tell us when this version is going to be released?
As soon as we're ready :)
I've found a PR related to this bug: https://github.com/facebook/react-native/pull/35063
@zaffy88 Actually, if you don't want to wait for the fix in 0.71, you can try this temporary workaround in package.json instead of generating bundle manually, it helped me:
"resolutions": {
"react-native-gradle-plugin": "0.71.5",
},
@zaffy88 Actually, if you don't want to wait for the fix in 0.71, you can try this temporary workaround in package.json instead of generating bundle manually, it helped me:
I would highly advice against doing this kind of fixes as 1. It will most likely won't work 2. If you forget you added this script in your package.json, your upgrade in the future will be really painful.
Same issue with 0.70.6 =/
We were using classpath("com.android.tools.build:gradle:7.3.1")
because it's tested with compileSdk 33, however, it resulted in the bundle in the release APK being nested within a mergeReleaseAssets
directory. Changing to classpath("com.android.tools.build:gradle:7.2.1")
fixes this issue.
Maybe not the issue here, but this thread helped lead me to the problem.
Just a heads up that we fixed this in 0.71.
I've also wrote a short guide on how to properly configure flavors so that the issue you're having is going away: https://reactnative.dev/docs/react-native-gradle-plugin#using-flavors--build-variants
I'm closing this as the root cause was fixed. If the issue persists on 0.71, please open a new issue
The same question for me.
The current temporary solution is to manually generate the bundle file. Hope there is a better solution!
step 1:
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
step 2:
./gradlew clean app:assembleRelease --stacktrace -x bundleReleaseJsAndAssets
I can confirm this works for me
"expo": "^46.0.0", "react": "18.0.0", "react-native": "0.69.7"
'com.android.tools.build:gradle:7.2.2'
New Version
0.70.4
Old Version
0.67.3
Build Target(s)
android real machine in release flavor
Output of
react-native info
System: OS: macOS 10.15.4 CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz Memory: 527.52 MB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 16.14.0 - /usr/local/bin/node Yarn: 1.22.4 - /usr/local/bin/yarn npm: 8.3.1 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.2 - /Users/zaffy/.rbenv/shims/pod SDKs: iOS SDK: Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2 Android SDK: Android NDK: 21.0.6113669 IDEs: Android Studio: 4.2 AI-202.7660.26.42.7486908 Xcode: 12.4/12D4e - /usr/bin/xcodebuild Languages: Java: 11.0.15.1 - /Library/Java/JavaVirtualMachines/jdk-11.0.15.1.jdk/Contents/Home//bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.0.0 => 18.1.0 react-native: 0.70.4 => 0.70.4 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Issue and Reproduction Steps
I follow the steps on this page https://react-native-community.github.io/upgrade-helper/?from=0.67.3&to=0.70.4, assemble flavor release apk success, but crash when start app, logcat print
Unable to load script. Make sure you're either running Metro (run 'npx react-native start') or that your bundle 'index.android.bundle
but log tell me copy bundle success:
The following are important file contents:
app/build.gradle
android/build.gradle
gradle.properties
gradle-wrapper.properties
package.json