Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unhandled promise rejection #192

Closed
Ideasrefined opened this issue Aug 4, 2017 · 11 comments
Closed

unhandled promise rejection #192

Ideasrefined opened this issue Aug 4, 2017 · 11 comments

Comments

@Ideasrefined
Copy link

Ideasrefined commented Aug 4, 2017

Version

Tell us which versions you are using:

  • react-native-ble-manager v_latest as of 4thAug2017

  • react-native
    react-native-cli: 2.0.1
    react-native: 0.47.0

  • iOS/Android v.Android 7.1.1

I have linked ble-manager library using react-native link. I followed the instructions to change minSDK version to 18.

I am getting the following Warning when I use

"BleManager.start({showAlert: false, allowDuplicates: false});"

Possible Unhandled Promise Rejection (id: 0):
TypeError: Cannot read property 'start' of undefined
TypeError: Cannot read property 'start' of undefined

I have traced the problem to the
bleManager.start call in the following function in BleManager.js.

start(options) {
    return new Promise((fulfill, reject) => {
      if (options == null) {
        options = {};
      }
      console.log("Start BLE")
      bleManager.start(options, (error) => {
        if (error) {
          reject(error);
        } else {
          fulfill();
        }
      });
    });
  }

I am not sure what went wrong or how to fix it.

@marcosinigaglia
Copy link
Member

Hi, try to install manually.

@Ideasrefined
Copy link
Author

Update: Compiling and running included example results in the same error.

now moving to installing it manually But I am skeptical.

@Ideasrefined
Copy link
Author

Ideasrefined commented Aug 4, 2017

Update # 2:
Tried installing / linking using manual procedure described in the readme. After all the steps when I run "react-native run-android" I get the following error :-

/home/enigma/codes/react/native/innovateBLE/node_modules/react-native-ble-manager/android/src/main/java/it/innove/BleManagerPackage.java:26: error: method does not override or implement a method from a supertype
        @Override
        ^
Note: /home/enigma/codes/react/native/innovateBLE/node_modules/react-native-ble-manager/android/src/main/java/it/innove/LegacyScanManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
:react-native-ble-manager:compileReleaseJavaWithJavac FAILED

FAILURE: Build failed with an exception.

@marcosinigaglia
Copy link
Member

Try with RN 0.46, I don't know if there are breaking changes in 0.47

@virdesai
Copy link

virdesai commented Aug 11, 2017

For RN 0.47, change

public BleManagerPackage() {}

@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactApplicationContext) {
	List<NativeModule> modules = new ArrayList<>();

	modules.add(new BleManager(reactApplicationContext));
	return  modules;
}

@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
	return new ArrayList<>();
}

@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactApplicationContext) {
	return Collections.emptyList();
}

to

public BleManagerPackage() {}

@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactApplicationContext) {
	List<NativeModule> modules = new ArrayList<>();

	modules.add(new BleManager(reactApplicationContext));
	return  modules;
}

public List<Class<? extends JavaScriptModule>> createJSModules() {
	return new ArrayList<>();
}

@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactApplicationContext) {
	return Collections.emptyList();
}

@Ideasrefined
Copy link
Author

Works as is for RN 0.46

@rgstephens
Copy link

I've also run into this issue with 0.47. Seems like this issue should be left open.

@nomoreboredom
Copy link

For future reference, RN version 0.53, Typescript, I needed to import as import * as BleManager from 'react-native-ble-manager';

@dcmayankavi
Copy link

I'm facing same problem with below configuration:

"react": "16.11.0",
"react-native": "0.62.2",
"react-native-ble-manager": "7.2.0"

Android version: 10

@shouer
Copy link

shouer commented Jun 17, 2020

I'm facing same problem with below configuration:

"react": "16.8.3",
"react-native": "0.59.5",
"react-native-ble-manager": "^7.3.0",

Android version: 10

@asukiaaa
Copy link

It depended on importing way in my case.

// import * as BleManager from "react-native-ble-manager" // Bad
import BleManager from "react-native-ble-manager" // OK

BleManager.start()
    "react": "18.2.0",
    "react-native": "0.74.2",
    "react-native-ble-manager": "^11.5.4"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants