Error: Native Modules for sensors not available. Did react-native link run successfully? - react-native

I am new on React Native, could you helpe me? I have just installed the react-native-sensors(Yarn add --save react-native-sensors), then I imported on my project(import { Accelerometer } from "react-native-sensors";) but I receive this message "Native Modules for sensors not available. Did react-native link run successfully?"
I runned the command "react-native link react-native-sensors", but the error
still persists =(
I am using the "react-native-sensors": "^5.1.5".
and this is my package.json
{
"name": "tcc_mobile",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"lodash": "^4.17.11",
"react": "16.6.1",
"react-native": "0.57.7",
"react-native-gesture-handler": "^1.0.10",
"react-native-sensors": "^5.1.5",
"react-navigation": "^3.0.8",
"rxjs": "^6.3.3"
},
"devDependencies": {
"babel-jest": "23.6.0",
"jest": "23.6.0",
"metro-react-native-babel-preset": "0.48.5",
"react-test-renderer": "16.6.1"
},
"jest": {
"preset": "react-native"
}
}
Thanks ! =)

$ npm install react-native-sensors --save or Yarn add
$ react-native link react-native-sensors
Are you testing on iOS? If you are testing on iOS, you need to add this.
Option: With CocoaPods (iOS only)
Add the following to your Podfile and run $ pod install:
pod 'RNSensors', :path => '../node_modules/react-native-sensors'

Check your AVD for sensor capabilities and try to work with real devices. It woks fine for me with the given dependency version:-
"react-native-sensors": "^5.1.8". Here is a little code snippet:-
import {
accelerometer,
gyroscope,
setUpdateIntervalForType,
SensorTypes
} from "react-native-sensors";
accelerometer.subscribe(({ x, y, z, timestamp }) => {
console.log(X: ${ x }, Y:${y}, Z:${z}, timestamp: ${timestamp} )

Related

The method or property expo-file-system.downloadAsync is not available on android, are you sure you've linked all the native dependencies properly?

I am a newbie with react-native.
I am trying to add expo icons, and when the project is running on the device I get this error:
Screenshot with logs
{
"name": "TrackYourFitness",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"expo": "^36.0.2",
"react": "16.9.0",
"react-native": "0.61.5"
},
"devDependencies": {
"#babel/core": "^7.8.3",
"#babel/runtime": "^7.8.3",
"#react-native-community/eslint-config": "^0.0.6",
"babel-eslint": "^10.0.3",
"babel-jest": "^25.1.0",
"eslint": "^6.8.0",
"eslint-plugin-flowtype": "^4.6.0",
"jest": "^25.1.0",
"metro-react-native-babel-preset": "^0.58.0",
"react-test-renderer": "16.9.0"
},
"jest": {
"preset": "react-native"
}
}
I tried yarn react-native link, but it didn't work.
How can I fix it? Thanks in advance!
According to your error message, you are trying to call the method downloadAsync from the package expo-file-system.
This package is missing in your package.json.
To install it: run the following command:
expo install expo-file-system
But I don't think this is related to your problem, because you're talking about icons. Icons package is already included in Expo, so it will work.
For reference: https://docs.expo.io/versions/latest/guides/icons/
run
npm install react-native-unimodules
npx pod-install //for ios
made changes in your android file based on IOS and Android
see link
https://docs.expo.io/bare/installing-unimodules/
restart react-native again...
npm start
npx react-native run-android
Happy Coding!!!

An error occurs when creating a lower version react-native

I tried to use react-native-beacons-manger to use beacons in react native, but I got an error. So I try to create lower version react-native and run. But it made an error.
$ react-native init BeaconTest --version 0.59.0
$ react-native run-ios
An error looks like
Failed to load bundle(http://localhost:801/index.bundle?platform=ios&dev=true&minify=false with error:(Could not connect to development server)
my package.json file
{
"name": "BeaconTest",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.8.3",
"react-native": "0.59.0"
},
"devDependencies": {
"#babel/core": "^7.7.2",
"#babel/runtime": "^7.7.2",
"babel-jest": "^24.9.0",
"jest": "^24.9.0",
"metro-react-native-babel-preset": "^0.57.0",
"react-test-renderer": "16.8.3"
},
"jest": {
"preset": "react-native"
}
}
I also tried
$ react-native init Test
$ npm install react-native#0.59.0
but it also made some errors
please let me know how to create low version react-native so that I can use beacon package (react-native-beacons-managers)

React-native Run-ios build failed .error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65

I have seen some similar questions. But none of them solved my problems.
react-native-cli: 2.0.1
react-native: 0.59.4
Simulator Version 10.1 (SimulatorApp-877 CoreSimulator-587.35)
Xcode Version 10.2 (10E125)
After upgrading the xcode to 10.2 this problem started
The following build commands failed:
CompileXIB /Users/rezwanakabita/Desktop/Navigation_Practice/react-native-firebase-starter/ios/RNFirebaseStarter/Base.lproj/LaunchScreen.xib
(1 failure)
I tried all the solutions in StackOverflow Previous questions. But none solved my problem. Any help would be appreciated. thank you.
{
"name": "RNFirebaseStarter",
"version": "5.3.0",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios --simulator=\"iPhone X\"",
"apk": "cd android && ./gradlew assembleRelease",
"rename": "node ./bin/rename.js",
"start": "react-native start",
"test": "jest"
},
"dependencies": {
"react": "16.8.3",
"react-native": "0.59.4",
"react-native-firebase": "5.3.0",
"realm": "^2.26.0"
},
"devDependencies": {
"#babel/core": "^7.4.3",
"#babel/runtime": "^7.4.3",
"babel-jest": "^24.7.1",
"jest": "^24.7.1",
"metro-react-native-babel-preset": "^0.53.1",
"react-test-renderer": "16.8.3"
},
"jest": {
"preset": "react-native"
}
}
A temporary fix mentioned in react-native github issue is to use Legacy Build System
File -> Workspace Settings -> Build System -> Legacy Build System

react-native unable to resolve module all the time

Here are some backgrounds:
Windows 10
package.json:
{
"name": "orange",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.6.0-alpha.8af6728",
"react-native": "0.57.3",
"react-navigation": "^2.18.0"
},
"devDependencies": {
"babel-jest": "23.6.0",
"jest": "23.6.0",
"metro-react-native-babel-preset": "0.48.1",
"react-test-renderer": "16.6.0-alpha.8af6728"
},
"jest": {
"preset": "react-native"
}
}
Well, the app runs successfully. However, when I want to add modules, any module, it returns unable to resolve xxx modules. For example, below is when importing react-navigation:
but it installed successfully:
I've tried remove node_modules and reinstall. Also tried react-native start --reset-cache. Neighter works.
Any suggestion?
Try to use the below command to install react-navigation to install.
npm install --save react-navigation
Restart your node packager if its already running.
Run your app with react-native run-ios for iOS, react-native run-android for android.
Rebuild your project in Xcode Command + B for iOS, in Android Studio Command + F9
npm problem. Works with yarn.

Unable to setup native base in my react-native app

I'm trying to setup native-base in react native app. I have followed all the steps and trying to run App on ios simulator. But I'm getting the error like below.
Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/SAW.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist.
what I'm doing wrong?
I'm using below versions.
Does native base support react native version 0.56.0 or not?
react-native-cli: 2.0.1
react-native: 0.56.0
{
"name": "SAW",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"#expo/vector-icons": "^6.3.1",
"native-base": "^2.7.2",
"react": "16.4.1",
"react-native": "0.56.0"
},
"devDependencies": {
"babel-jest": "23.4.2",
"babel-preset-react-native": "5.0.2",
"jest": "23.5.0",
"react-test-renderer": "16.4.1"
},
"jest": {
"preset": "react-native"
}
}
CFBundleIdentifier has got nothing to do with NativeBase.
Also you can check NativeBase vs React Native version compatibility here https://github.com/GeekyAnts/NativeBase#7-compatibility-versions
Looks like your port 8081 is in use. Check for lsof -n -i4TCP:8081 and kill any processes using 8081 and try running again.
If nothing works, try running on the Xcode.
For further readings, check out issue