question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 issue

New 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.

screenshot screenshot

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:

  1. adb reverse tcp:8081 tcp:8081

  2. setting port and host configs

  3. 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?

@sammy-SC

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:16 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
chungweileong94commented, Nov 29, 2022

@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.gradle

I 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.

1reaction
kapilraghuwanshicommented, Dec 2, 2022

RN v 0.70.6 + gradle 7.2.1 leads to this error message,

Am I reading right that this issue is happening on a empty 0.70.6 project?

From what I have tested on the fresh RN 0.70.6 project, both the dev & release build work fine, at least for me. @kapilraghuwanshi Is it possible for you to create a small example project that can reproduce this problem?

let me give this a try.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to load script.Make sure you are either running a ...
The message is as follows: Unable to load script.Make sure you are either running a Metro server or that your bundle 'index.android.bundle' is ......
Read more >
Unable to load script from assets 'index.android.bundle'. Make ...
This can be caused by a misconfigured app/build.gradle, such as pointing to the wrong bundle name or not packaging during the release process...
Read more >
React Native: Unable to load script: index. android.bundle
Step 1: I am using React Native version 0.63.2 like below, and I want to build an android app by using Fastlane for...
Read more >
Addressing common errors in React Native - LogRocket Blog
All of your app's JavaScript is bundled into the index.android.bundle file. If the bundle file is unavailable or not correctly packaged, you'll ...
Read more >
Fixing React-Native android release build - wesionaryTEAM
adb logcat '*:E' · project.ext.react = [ enableHermes: true, // clean and rebuild if changing · rm android/app/src/main/assets/index.android.bundle · npx react- ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found