Trying to upgrade to support android 12 but getting - Unable to load script, make sure your bundle "index.android.bundle" is packaged correctly for release.
See original GitHub issueNew Version
0.66.5+
Old Version
0.63.4
Build Target(s)
Android Emulator and release build as well
Output of react-native info
System: OS: macOS 12.6.1 CPU: (12) x64 Intel® Core™ i7-9750H CPU @ 2.60GHz Memory: 170.70 MB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.14.0 - /usr/local/bin/node Yarn: Not Found npm: 8.3.1 - /usr/local/bin/npm Watchman: 2022.10.03.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.3 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.1, iOS 16.1, macOS 13.0, tvOS 16.1, watchOS 9.1 Android SDK: Not Found IDEs: Android Studio: 2021.3 AI-213.7172.25.2113.9014738 Xcode: 14.1/14B47b - /usr/bin/xcodebuild Languages: Java: 11.0.2 - /Users/kapil.raghuwanshi/.sdkman/candidates/java/current/bin/javac npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 17.0.2 react-native: 0.63.4 => 0.66.5 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Issue and Reproduction Steps
We are trying to migrate our react native project in order to support android 12.
https://reactnative.dev/blog/2021/09/01/preparing-your-app-for-iOS-15-and-android-12
We are struggling to resolve this issue past few days.
We searched on the internet https://stackoverflow.com/questions/55441230/unable-to-load-script-make-sure-you-are-either-running-a-metro-server-or-that-yo/58570426#58570426
and found a few solutions below:
-
adb reverse tcp:8081 tcp:8081
-
setting port and host configs
-
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
Out of which all are working fine in our local system and emulators but once we create a release build for the production environment, no luck with any of such hacks.
Since my final package was built using below react native bundle command but gets installed on the separate native android project. There it is still the same issue.
“react-native bundle --platform android --dev true --entry-file index.js --bundle-output ./android/app/src/main/assets/index.android.bundle --assets-dest ./server/dir/”
Could you please help us out in resolving this issue?
Issue Analytics
- State:
- Created 10 months ago
- Comments:16 (1 by maintainers)
@kapilraghuwanshi Based on the RN version (0.66~) that you provide, you should be using
com.android.tools.build:gradle:4.2.2
instead. https://github.com/react-native-community/rn-diff-purge/blob/version/0.66.5/RnDiffApp/android/build.gradleI strongly advise you to use the Gradle version that comes with your current RN version, or else you might face some build issues as I mentioned earlier. Or I highly recommend you spend some time upgrading the RN version which supports a much higher Gradle version, you also get better support for the latest Android/iOS.
Trust me, I literally face the exact same issue few days ago, where I accidentally change the Gradle version via Android studio.
let me give this a try.