wix / react-native-navigation

A complete native navigation solution for React Native
https://wix.github.io/react-native-navigation/
MIT License
13.04k stars 2.67k forks source link

Build error: Could not get BatchedBridge, make sure your bundle is packaged correctly #2562

Closed alexcbz closed 6 years ago

alexcbz commented 6 years ago

Issue Description

I am getting the following error when trying to build the app in Android Emulator.

Error calling RCTDeviceEventEmitter.emit
Could not get BatchedBridge, make sure your bundle is packaged correctly
run
    NativeRunnable.java
handleCallback
    Handler.java:739
dispatchMessage
    Handler.java:95
dispatchMessage
    MessageQueueThreadHandler.java:31
loop
    Looper.java:148
run
    MessageQueueThreadImpl.java:194
run
    Thread.java:818

Steps to Reproduce / Code Snippets / Screenshots

This is my Android configuration for React Native Navigation V2.

android/settings.gradle


rootProject.name = 'myapplication'

include ':app' include ':react-native-navigation' project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/lib/android/app/')


> android/app/build.gradle

apply plugin: "com.android.application"

import com.android.build.OutputFile

project.ext.react = [ root : "../../", entryFile: "index.android.js" ]

apply from: "../../node_modules/react-native/react.gradle"

def enableSeparateBuildPerCPUArchitecture = false

/**

android { compileSdkVersion 25 // buildToolsVersion "23.0.1"

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
    applicationId "com.myapplication"
    minSdkVersion 19
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    ndk {
        abiFilters "armeabi-v7a", "x86"
    }
}
splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate a universal APK
        include "armeabi-v7a", "x86"
    }
}
buildTypes {
    release {
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
    variant.outputs.each { output ->
        // For each separate APK per architecture, set a unique version code as described here:
        // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
        def versionCodes = ["armeabi-v7a":1, "x86":2]
        def abi = output.getFilter(OutputFile.ABI)
        if (abi != null) {  // null for the universal-debug, universal-release variants
            output.versionCodeOverride =
                    versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
        }
    }
}

}

dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) implementation 'com.android.support:design:25.4.0' implementation "com.android.support:appcompat-v7:25.4.0" implementation "com.facebook.react:react-native:+" // From node_modules implementation project(':react-native-navigation') }

// Run this once to be able to run the application with BUCK // puts all compile dependencies into folder libs for BUCK to use task copyDownloadableDepsToLibs(type: Copy) { from configurations.compile into 'libs' }


> MainActivity.java

package com.myapplication;

import com.reactnativenavigation.*;

public class MainActivity extends NavigationActivity { }


> MainApplication.java

package com.myapplication;

import android.support.annotation.*;

import com.facebook.react.; import com.reactnativenavigation.;

import java.util.*;

public class MainApplication extends NavigationApplication {

@Override
public boolean isDebug() {
    return BuildConfig.DEBUG;
}

@Nullable
@Override
public List<ReactPackage> createAdditionalReactPackages() {
    return null;
}

}


---
### Environment
* React Native Navigation version: 2.0.2093
* React Native version: 0.52
* Platform(s) (iOS, Android, or both?): Android
* Device info (Simulator/Device? OS version? Debug/Release?): Simulator (Nexus_5X_API_23), Debug
romeoonisim commented 6 years ago

+1 I'm also struggling with this issue ...

pqkluan commented 6 years ago

RNN doesn't support RN 0.52 yet, try downgrading to RN 0.51 Link

b9words commented 5 years ago

I resolved this issue by changing index.js file react-native-cli created to index.ios.js and index.android.js.

https://stackoverflow.com/questions/48014303/batchedbridge-error-in-react-native-on-ios

waqaramjad commented 4 years ago

same issue when using woo commerce API

Justin9606 commented 2 years ago

I had a same issue, then I did: rm -rf node_modules npm install and restarted the metro (npm start). It worked.

RimApp commented 1 year ago

In Settings, go to Privacy > Local Network to see a list of every app that requested access. I solved by allowing my app to access to the local network. (Trying to run on physical iPhone device from my mac m1 on the same wifi).

Source