By Zygro


2016-08-10 10:24:32 8 Comments

Trying to create a react-native project on Android 4.4.2 I get this error screen

said error

and couldn't find any way to resolve it. I tried restarting packager, reconnecting device, even reinstalling react native and starting new project. On 6.0.0 and later versions it works just fine.

30 comments

@Vinayak Gupta 2018-09-25 08:01:19

Simply restart your system or your complete bundle and the issue may be fixed.

@Jason 2018-05-28 05:24:02

Easiest Way!

  • Stop server and end project build.
  • Open a 'Node.js' terminal.
    • Navigate to folder with 'react-native' project.
    • Type 'react-native start' --Starting the react native server manually.
  • Go to your Code Editor Terminal and type 'react-native run-android.

You're good to go!

@Serhey Dolgushev 2017-12-14 16:56:46

Please check if you have following error when you run react-native run-android: adb server version (XX) doesn't match this client (XX); killing...

In that case make sure /usr/local/opt/android-sdk/platform-tools/adb and /usr/local/bin/adb are pointed to the same adb

In my case one was pointed to /Users/sd/Library/Android/sdk/platform-tools/adb (Android SDK), but another was pointed to /usr/local/Caskroom/android-platform-tools/26.0.2/platform-tools/adb (Homebrew)

And issue have been fixed after both of them pointed to /Users/sd/Library/Android/sdk/platform-tools/adb (Android SDK)

@Martin Choraine 2017-11-07 19:20:07

I got the same issue but it was a stupid mistake from myself...

From Android studio, I was launching installDebug/installRelease gradle script from app projet instead of root projet.

@tbo 2016-08-10 13:33:09

A possible solution for this is that you most probably not bundling your application first, perform the following steps and then deploy your app-debug.apk to your device

$ cd myproject  
$ react-native start > /dev/null 2>&1 &  
$ curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"

(if the folder assets does not exists create it)

Then run from project root

$> (cd android/ && ./gradlew assembleDebug)

install the created apk to you device, from location: android/app/build/outputs/apk/app-debug.apk

let me know if that fixes your issue

EDIT:

You can simply put it to your package.json as a script to automate it, I believe it will be fixed in upcoming releases of react-native and will be executed prior assembling the final APK, hence this won't be needed (I hope as well)

put :

"scripts": {
    "build": "(cd android/ && ./gradlew assembleDebug)",
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "bundle-android": "react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --sourcemap-output android/app/src/main/assets/index.android.map --assets-dest android/app/src/main/res/"
  },

or as mentioned the curl equivalent, but for most cases the above is more robust

@Zygro 2016-08-10 13:51:34

Yes it works!!! What did I just do? why curl? also, can this be automated?

@Zygro 2016-08-10 14:09:43

I mean, could you please explain which command does what?

@tbo 2016-08-10 15:15:26

I have updated the answer a bit, pls check

@GeekHades 2016-08-18 08:13:24

Thank you very much, Because My app din't link the React native bundle.

@Jesse 2016-08-19 22:00:32

Only answer in the topic that worked for me, cheers!

@Liron Yahdav 2016-08-21 05:43:18

This seems like a hack. If you are packaging the JavaScript into a single file won't you not get the live reloading capability while running the app during development?

@tbo 2016-08-23 18:17:18

this is not for development but for actual APK packaging

@Dinesh Spartacus 2016-11-21 12:57:47

nothing happen with me still getting error:- com.facebook.react.devsupport.JSException: Could not get BatchedBridge, make sure your bundle is packaged correctly

@Dharam Mali 2016-12-29 12:54:59

Any suggestion for Windows user ?

@gbade_ 2017-01-18 12:02:41

@tbo Please if you're online, respond ASAP. I added the latter in the package.json file and it worked initially. But when I uninstalled to re-install the app, I am getting the same "Could not get BatcheBridge" error. Please how do I resolve this?

@tbo 2017-01-18 12:45:41

@gbade_ have you been using rnpm instead of npm anywhere in your react native code? I think you would have used it at some point so probable now you used npm install and the links have not been created. This is just a guess, hope it helps

@gbade_ 2017-01-18 14:35:24

@tbo I am using npm. I am also running tests on an Android 4.1.2 device. I can't use the development server as that shows red and throws errors of its own. I found a way of fixing the issue. I shook the device, went to Dev Settings, found the IP and port by using ifconfig in terminal and added it to the IP and Port part in the Dev Settings.

@Beelphegor 2017-02-10 21:52:00

@tbo my application boots now, but I'm not seeing any of the assets.

@Mochammad Taufiq 2017-02-13 17:27:34

this is working! thanks

@pixel 2017-11-28 20:09:06

did not work for me on Windows 10

@Hitesh Sahu 2017-07-11 13:45:19

Try to clean cache

react-native start --reset-cache

@niceman 2017-06-27 10:23:00

For me the problem was that 'adb' was not recognised - check this answer.

To fix this add C:\Users\USERNAME\AppData\Local\Android\sdk\platform-tools to Environment Variables

@Amit Joshi 2017-06-27 10:40:50

This is nothing more than comment. But if you paste last line of your linked answer here, this becomes valid answer. Otherwise there are chances this answer will be removed.

@Sebastian Voráč 2017-05-09 12:24:51

I had the same problem. When I did create a react native project via create-react-native-app AwesomeProject it worked well in Expo app on phone. After that I wanted to use that quickstart project for developing my project and got same error as you do.

After some research I find out it's better to start new project with react-native init AwesomeProject (with all setting in react native docs) Then run this command:

react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/

That should fix the thing with bundle (--dev false is not showing warnings)

All you need to do for app to run on your virtual / real device is:

react-native run-android

And it should be working just fine. At least it worked for me.

@DeepakPanwar 2017-05-01 10:03:26

Most of us face this problem for the first time, when we start react native project#1.

Few simple steps solved my problem:

I created a sample project using command: react-native init ReactProject1

Solution

The fix is to help local-cli\runAndroid\adb.js to find adb.exe, the same way as local-cli\runAndroid\runAndroid.js:

find replace statement under projectname(whatever you have given)\node_modules\react-native\local-cli\runAndroid

Replace:

const devicesResult = child_process.execSync('adb devices');

By:

const devicesResult = child_process.execSync( (process.env.ANDROID_HOME ? process.env.ANDROID_HOME + '/platform-tools/' : '') + 'adb devices');

after doing above replacement, just run react-native run-android in your cmd, it will bundle apk and at first try to install js bundle locally in your device. (Got Success)

@Shamsher 2017-04-30 16:38:01

It's little too late but this really works for me.

  1. react-native run-android.
  2. react-native start.

First command will build apk for android and deploy it on your device if its connected. When you open the App it will show red screen with error. Then run second command which will run packager and build app bundle for you.

@SpencerL 2017-04-16 08:17:11

My issue was that I went through my AndroidManifest.xml file and had removed the line

<uses-permission android:name="android.permission.INTERNET" />

because my app will not need internet. However, the react native debugging app does need internet access (to access the packager) Whoops. :)

@Christophe Cadilhac 2017-08-12 18:19:08

Man you saved my day. Was ripping my hair off :)

@M. Solle 2017-04-12 19:37:57

I found that I needed to also add in a

react-native upgrade

to get the application to run correctly.

@Cheng.Tang 2017-03-30 09:45:57

Solution: under "react-native" directory: after run command "./gradlew :Examples:UIExplorer:android:app:installDebug" successfully, run commnad "./packager/packager.sh" successfuly. then click "UIExplorer App“ in the emulator or the device

@alexfigtree 2017-03-11 23:55:20

I tried many of the suggestions above/below, but ultimately, the issue I faced was a permissions one with watchman, which was installed using homebrew earlier. If you look at your terminal messages while trying to use the emulator, and encounter 'Permission denied' errors with regards to watchman along with this 'Could not get BatchedBridge" message on your emulator, do the following:

Go to your /Users/<username>/Library/LaunchAgents directory and change the permissions settings so your user can Read and Write. This is regardless of whether or not you actually have a com.github.facebook.watchman.plist file in there.

@ThienSuBS 2017-03-10 10:17:26

My way are:

react-native start

After that in your device using:

click to Reload.

See in console react-native, it will be fetch js bundle data.

@Nicolas Leucci 2017-04-28 16:25:38

This was my issue, because the terminal wasn't starting. Thanks !

@Brijmohan Karadia 2017-01-26 10:58:59

In a separate terminal, connect your device to the computer and run the following commands:

react-native start 
cd user/Library/Android/sdk/platform-tools/
./adb reverse tcp:8081 tcp:8081

Application terminal:

react-native run-android 
install apk on your device from this location android/app/build/outputs/apk/app-debug.apk

@niels 2017-01-26 11:18:07

Perhaps you could expand your answer to include a bit more detail on what the individual steps in your answer mean, from what directories the commands should be run etc? I think that would make your answer much more helpful.

@Joshua Pinter 2017-03-03 01:58:59

This the proper answer. This allows you to iterate quickly by connecting to the react native server instead of having to repackage the bundle with each change.

@pixel 2017-11-28 20:14:45

does not work with android emulator on Windows 10

@Luiz Henrique Martins Lins Rol 2017-01-17 00:08:41

It had this issue "randomly" and took me sometime to realize what was wrong in my scenario.

After I have updated to React-native-cli 2.0.1, there was a message output to the log which helped me to dig and find the root cause:

JS server not recognized, continuing with build...

After researching some links I found this one:

Unable to recognize JS server

Since I´m on windows, I ran netstat and found out that my VLC player was also running on port 8081 causing the issue. So, in my case, if I started the vlc server prior to the react-native server it wouldn´t work.

This same log message wasn´t output on previous versions of the react-native-cli, making it fail silently.

TL, DR: check if there´s anything running on the same port as the package manager (8081 by default)

@Jesús Carrera 2016-12-07 09:00:47

Since you are using Android < 5.0 you can't use the default adb reverse method, but Facebook has added official documentation to connect to the development server via Wi-Fi, which would support your version. Quoting the instructions for MacOS, but they also have them for Linux and Windows:

Method 2: Connect via Wi-Fi

You can also connect to the development server over Wi-Fi. You'll first need to install the app on your device using a USB cable, but once that has been done you can debug wirelessly by following these instructions. You'll need your development machine's current IP address before proceeding.

You can find the IP address in System Preferences → Network.

Make sure your laptop and your phone are on the same Wi-Fi network. Open your React Native app on your device. You'll see a red screen with an error. This is OK. The following steps will fix that. Open the in-app Developer menu. Go to Dev Settings → Debug server host for device. Type in your machine's IP address and the port of the local dev server (e.g. 10.0.1.1:8081). Go back to the Developer menu and select Reload JS.

@Anthony Naddeo 2016-11-20 01:16:54

I ended up having to open up the port that I was using (8081 by default). On Linux, you can do the following

sudo iptables -A INPUT -p tcp --dport 8081 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
sudo iptables -A OUTPUT -p tcp --sport 8081 -m conntrack --ctstate ESTABLISHED -j ACCEPT

You can test to see whether you actually need to do this. Just navigate to your dev server in Chrome on your Android device. If it doesn't respond, then this might be what you need. If it does respond, then this won't help you.

@h--n 2016-11-16 13:22:19

For me, it's because adb was not in the PATH. It's located /Users/man/Library/Android/sdk/platform-tools for me, it may be somewhere else for you, but anyway, find it and add it to your path to see if that help.

@Yang 2016-11-08 04:40:33

  1. restart the genymotion
  2. run react-native run-android
  3. the problem was solved

@Michal 2017-04-25 13:27:08

For real? restart the genymotion? Ty vole.

@Michal 2017-04-25 13:27:52

That is like saying "oh your website does not work? Try restarting your server."

@lee_dabiker 2016-10-29 00:00:24

For me, I had side-sync enabled and active. Closing it imediately made the issue go away. It might be worth closing this or any other communication between PC and device

@XYz Amos 2016-10-21 03:29:09

see issue:

1.react-native start

2.click Reload(R,R) on your device.

@Felipe 2016-08-14 23:19:38

I came across this issue as well. What I did was force kill the app on my device, then I opened up another console and ran

react-native start

and then I opened the app again from my device and it started working again.

EDIT: If you are using an android device via USB and have unplugged it or your computer went to sleep, you may have to first run

adb reverse tcp:8081 tcp:8081

@Dylan Pierce 2016-09-13 18:51:46

This solved my problem when using react-native run-android. Using react-native start was never required for me when I was doing react-native run-ios

@Marko 2017-02-10 17:30:38

This worked, but why is this happening? Is this going to be fixed? Do I have to always open 2 terminals, and do the 'start' first before I can run it on a device?

@Achin 2017-06-07 03:48:58

this worked for me

@dtjmsy 2017-06-21 14:05:47

it works for me too ! spent hours to find a solution

@Darius 2017-08-15 11:21:43

adb reverse tcp:8081 tcp:8081 was sufficient in itself for me. Many thanks!

@pixel 2017-11-28 20:10:09

does not work, tried it few times (Windows 10)

@Faris Rayhan 2018-05-01 15:55:48

This is awesome after that you could do ./adb install

@Praneeth 2016-10-04 23:21:22

Try this command in terminal and then reload. It worked for me

adb reverse tcp:8081 tcp:8081

@silvdb 2016-10-19 12:01:43

That command is only supported for Android 5+

@Richh94 2016-09-18 20:32:31

I got this also when I started for the first time with React Native, using a physical device. If that's the case, you need to do some extra things before you can get started. You have to enter some information about your development machine in the 'Dev Settings' of React Native.

When you see the error, shake your device. A dialog will popup, the last option will be 'Dev Settings'. Select 'Debug server hot & port for device' and enter your local IP and the used port (usually 8081).

See the last paragraph of https://facebook.github.io/react-native/docs/running-on-device-android.html

@cube 2016-11-27 15:35:41

This is literally a repeat, verbatim of what I said above (in August)

@Richh94 2016-12-21 13:39:11

I didn't know that I need to shake the device. First, I would post it as a comment, but I don't have enough points to do that. I did upvote your post.

@Keith Gong 2016-12-28 09:51:53

It really works. But it's so strange

@callOfCode 2017-03-09 15:24:59

Simplest and cleanest solution. Thanks!

@Bruce Lee 2016-09-16 06:07:56

I got this error too, really confused. cuz all answers does not work. Just after add adb to path.

@Sumit Kushwaha 2016-09-15 12:57:39

If none of the solution work for you try this:

I found that my <root>/android/app/build/intermediates/assets/debug folder was empty and by running cd android && ./gradlew assembleDebug was not creating those files required, which are later used by javascript thread in our react native apps.

I ran manually the following command which the debug build command should have created ideally.

node node_modules/react-native/local-cli/cli.js bundle --platform android --dev true --reset-cache --entry-file index.android.js --bundle-output /<path to dir>/android/app/build/intermediates/assets/debug/index.android.bundle --assets-dest /<path to dir>/android/app/build/intermediates/res/merged/debug

After running these commands I found two bundle files in this directory <root>/android/app/build/intermediates/assets/debug

And then a I ran again cd android && ./gradlew installDebug my app started working again.

Will debug more and would update what is failing actually.

@metarob 2017-05-25 14:42:25

Just to clarify what's going on it seems that when integrating a react native into an existing project, the bundle output path is NOT set automatically, so you have to set it yourself. Hence the bundle output path=/path/to/assets ?

@metarob 2017-05-25 14:48:41

You are the best btw.

@Chaim Salzer 2016-09-14 17:09:50

This is what worked for me (After trying every other solution i found ...):

Run adb reverse tcp:8081 tcp:8081 inside \Android\sdk\platform-tools

@goldylucks 2016-09-22 10:44:15

can run this command anywhere, dont have to b in platform-tools

@straya 2016-09-30 05:49:46

I found that react-native run-android attempts to run that command and depends on the Windows environment variable path to contain the platform-tools path.

@chazefate 2017-03-05 00:24:58

Thank you, this worked. PATH is C:\Users\USERNAME\AppData\Local\Android\sdk\platform-tools

@pixel 2017-11-28 20:14:16

nope, not working on Windows 10 and Android emulator

@cube 2016-08-15 19:30:33

Just got this error. Here's what I did to fix: I selected Dismiss, Went into the Developer menu, then Dev Settings, Choose Debug server host & port for device, I added my computers IP address and the port: 192.168.0.xx:8xxx, use whatever your developer machines assigned IP address is on your wifi network. The port is usually :8081

Once I did this, all went well. Also, while you're in the dev menu remember to select Enable Live Reload and Debug JS Remotely, it makes your life much-much easier while debugging.

@henggana 2016-08-26 13:49:37

Works! For ubuntu user: run ifconfig, then find inet addr:xxx.xxx.xxx.xxx where xxx* is your developer machine ip

@Michael Ribbons 2016-10-10 02:51:48

This worked for me on an API level 19 / Kitkat 4.4, see stackoverflow.com/questions/31525431/…, facebook.github.io/react-native/docs/…

@Fidan Hakaj 2016-10-22 17:19:37

Thank you! I only have to do this config when I debug without USB cable (with tools like WiFi ADB).

@flyingace 2016-11-08 05:18:55

It's important to note that you can make the Developer menu that @cube references above by physically shaking your android device. That may seem odd, but that's what will bring it up. Then follow the rest of the instructions. This fixed it for me.

Related Questions

Sponsored Content

84 Answered Questions

[SOLVED] "cannot resolve symbol R" in Android Studio

39 Answered Questions

[SOLVED] Can't start Eclipse - Java was started but returned exit code=13

21 Answered Questions

[SOLVED] Android failed to load JS bundle

1 Answered Questions

54 Answered Questions

5 Answered Questions

1 Answered Questions

React-Native Could not get batchedBridge Error

4 Answered Questions

Could not get BatchedBridge, make sure your bundle is packaged correctly

0 Answered Questions

Sponsored Content