error Could not get BatchedBridge, make sure your bundle is packaged properly on start of app
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
error Could not get BatchedBridge, make sure your bundle is packaged properly on start of app
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
React Native run-android error in emulator Could not get BatchedBridge, make sure your bundle is packaged correctly
I have the fix but the reason behind it, posting this answer for increasing the visibility of the solution which is equivalent to this commit.
So I removed .babelrc
file and moved the module resolver settings to the webpack config, updated babel.config.js
so now the web related settings will not disturb the App-related babel settings.
I have updated the mentioned article as well.
.babelrc
:
<Deleted>
babel.config.js
:
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
};
web/webpack.config.js
:
...
...
...
// The 'metro-react-native-babel-preset' preset is recommended to match React Native's packager
presets: ['module:metro-react-native-babel-preset'],
// Re-write paths to import only the modules needed by the app
plugins: [
'react-native-web',
[
'module-resolver',
{
alias: {
'^react-native$': 'react-native-web',
},
},
],
],
...
...
...
ios Could not get BatchedBridge, make sure your bundle is packaged properly
create index.js, index.android.js and index.ios.js whith the same content. I do have all of them and it solved my issue
Related Topics
Android Webview App Won't Let Video Player Go Full Screen
How to Scale a Website for Mobile Devices
Getting "Socketexception:Connection Reset by Peer" in Android
Animating Markers on Google Maps V2
Is There a Better Way to Refresh Webview
How to Securely Store Credentials (Password) in Android Application
Listing All Extras of an Intent
Android/Webkit Text-Overflow: Ellipsis Not Working
Android Webview Rem Units Scale Way to Large for Boxes
Keyboard Showed Messed Up Elements' Position
Trusting All Certificates with Okhttp
How to Get the List of Mounted External Storage of Android Device
Error:'Keytool' Is Not Recognized as an Internal or External Command, Operable Program or Batch File
When Should I Use the Assets as Opposed to Raw Resources in Android
Android How to Use Environment.Getexternalstoragedirectory()
Update Ui from Thread in Android