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.

TypeError: undefined is not an object (evaluating '_BleModule.BleModule.createClient')

See original GitHub issue

I’m new to this library and whole react-native. I’ve done all steps written in this site successfully (It’s the same as the steps in README.md file). To test this library, I used the code in the polidea site (this Link) but faced this error on my Android device (I’m working with a real device):

TypeError: undefined is not an object (evaluating ‘_BleModule.BleModule.createClient’) This error is located at: in SensorsComponent (at renderApplication.js:33) in RCTView (at View.js:60) in View (at AppContainer.js:102) in RCTView (at View.js:60) in View (at AppContainer.js:122) in AppContainer (at renderApplication.js:32)

This is my build.gradle file:

apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
    entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"
    defaultConfig {
        applicationId "com.roboctl"
        minSdkVersion 18
        targetSdkVersion 22
        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 {
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
}

// 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'
}

This is my AndroidManifest.xml file:

`<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.roboctl">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission-sdk-23 android:name="android.permission.ACCESS_COARSE_LOCATION"/>

<!-- Add this line if your application always requires BLE. More info can be found on:
     https://developer.android.com/guide/topics/connectivity/bluetooth-le.html#permissions
  -->
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>

<uses-sdk
    android:minSdkVersion="18"/>

<application
  android:name=".MainApplication"
  android:label="@string/app_name"
  android:icon="@mipmap/ic_launcher"
  android:allowBackup="false"
  android:theme="@style/AppTheme">
  <activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    android:windowSoftInputMode="adjustResize">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>
  <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>

</manifest>`

This is my MainApplication.java file:

package com.roboctl;

import android.app.Application;

import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;

import java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    public boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage()
      );
    }

    @Override
    protected String getJSMainModuleName() {
      return "index";
    }
  };

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
  }
}

How to solve this problem? None of the solutions in the google search was my case.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
mahdieh-devcommented, Apr 22, 2018

Just hadn’t done steps 4 to 6 of the manual setup of react-native-ble-plx. refer to this link.

0reactions
zumi2013commented, Oct 29, 2021

Just hadn’t done steps 4 to 6 of the manual setup of react-native-ble-plx. refer to this link.

@mshavandi How to do that last step Troubleshooting Problems with Proguard?

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is this error? undefined is not an object (evaluating ...
[exp] TypeError: undefined is not an object (evaluating '_BleModule.BleModule.createClient') This error is located at: in App (at ...
Read more >
Cannot Create BLE Manager - react native - Stack Overflow
TypeError : null is not an object (evaluating '_BleModule.BleModule.createClient') This error is located at: in HelloWorldApp (created by ...
Read more >
null is not an object (evaluation of 'bleManager.start')? - Reddit
I use the react-native-ble-manager library to connect an Android smartphone to a BLE device. But when calling the BleManager.start() , an ...
Read more >
RxBLELibraries/react-native-ble - Gitter
Hi, I'm trying to get the bluetooth manager to be initialized in an object, I'm getting "TypeError: null is not an object (evaluating...
Read more >
typeerror: null is not an object (evaluating '_blemodule ...
TypeError : undefined is not an object (evaluating '_BleModule.BleModule.createClient') This error is located at: in DashboardScreen (at App.js:17) in App ...
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