Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all 28463 articles
Browse latest View live

Disable native library for some Android version in React Native

$
0
0

So, basically, I'm trying to use react-native-webrtc and it's required to have minSdk 24 to use this library. I'm not really experienced in Android, so question is can you make this library "optional"? Like if your phone doesn't support it, just ignore it?I can't provide any code, since I don't really know where to start digging, so any tips could help.

java.lang.NoSuchMethodError: No static method createEgl14([I)Lorg/webrtc/EglBase14; in class Lorg/webrtc/EglBase; or its super classes


Unable to resolve module `./Linking/Linking` from `node_modules/expo/build/ExpoLazy.js`

$
0
0

Has anyone experience this error with expo, when running react-native run-android?

error: bundling failed: Error: Unable to resolve module `./Linking/Linking` from `node_modules/expo/build/ExpoLazy.js`: None of these files exist:  * node_modules/expo/build/Linking/Linking(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)  * node_modules/expo/build/Linking/Linking/index(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)

"expo": "^37.0.9",

Exchange data simultaneously between mobile devices via NFC

$
0
0

Background

I would like to achieve a peer-to-peer connection to transmit data between two mobile devices. The amount of data to be transmitted would be around 70-200 bytes, so it is quite small. This transmission also won't be some stream-like continuous flow. It would be a one-time thing to get the acknowledgement of the devices.

TL;DR: I want to exchange data between 2 mobile phones which would be using the same app.

Requirements

  • Has to work offline
  • Has to work between IOS & Android

So Far

I have analyzed a few possible ways to achieve that and I am quite confused about what to pick.

  • NFC: I want to simultaneously send data for both phones and NFC does not work as a tag in the IOS. If there is a workaround for that let me know.
  • NFC + BLE: This approach utilizes the NFC to pair devices to use Bluetooth then the data transfer is conducted on BLE.

So, I'm humbly asking a direction about getting my head around those concepts to solve my problem. If you have another technology that might help me, please specify it. Also, I'm making the development with React Native.

Problems with expo and android emulator to connect with proxy

$
0
0

Problems with expo and android emulator to connect with proxyI have a problem with expo and android emulator. When I configured a proxy in android-studio/emulator expo doesn`t work, but when I set proxy off, expo start to work, but without internet.

  • I`m using windows 10.
  • I`ve already set proxy in android studio using 10.0.2.2/expo build IP in bypass.
  • I try set proxy manualy in emulator advanced settings.
  • And try set manualy in android wi-fi and mobile network, (Only this case internet works)

After Expo Eject, run-android error: spawnSync gradlew.bat Enoent

$
0
0

I was using expo, but then needed to link a third party package so I ejected from expo with Expo Kit. now when i try react-native run-android, the metro bundler starts but then the following error occurs:

info Building and installing the app on the device (cd android && gradlew.bat app:installDebug)...error Could not install the app on the device, read the error above for details.Make sure you have an Android emulator running or a device connected and haveset up your Android development environment:https://facebook.github.io/react-native/docs/getting-started.htmlerror spawnSync gradlew.bat ENOENTdebug Error: spawnSync gradlew.bat ENOENT    at Object.spawnSync (internal/child_process.js:981:20)    at spawnSync (child_process.js:585:24)    at execFileSync (child_process.js:613:13)    at runOnAllDevices (C:\Users\Mahmoud's Laptop\RN\ikraawarka\node_modules\@react-native-community\cli\build\commands\runAndroid\runOnAllDevices.js:58:39)    at buildAndRun (C:\Users\Mahmoud's Laptop\RN\ikraawarka\node_modules\@react-native-community\cli\build\commands\runAndroid\runAndroid.js:142:41)    at then.result (C:\Users\Mahmoud's Laptop\RN\ikraawarka\node_modules\@react-native-community\cli\build\commands\runAndroid\runAndroid.js:104:12)    at process._tickCallback (internal/process/next_tick.js:68:7)

more info:react-native-cli: 2.0.1react-native: 0.59.8expo: 2.20.2

I'm still able to run expo start and it works in the expo client app. Thanks

react-native-ble-plx not detecting all nearby devices

$
0
0
import {BleManager} from 'react-native-ble-plx';const DeviceManager = new BleManager();export const scan = function scan() {    const subscription = DeviceManager.onStateChange((state) => {        if (state === 'PoweredOn') {          DeviceManager.startDeviceScan(null, null, (error, device) => {            if (error) {              console.log("error",error);            }            if (device !== null) {                console.log("device found ----> [id,name]", device.id, device.name);            }          });          subscription.remove();        }    }, true);}

This is my code to scan for nearby devices. When I run the app, only my laptop is detected although there are other nearby devices (phones that support Bluetooth LE) with Bluetooth turned on.

Also for my laptop, only the device id is shown, and the device name is shown as null.

Is my code missing something to detect all nearby devices and all the data of detected devices?

How to solve: my React Native downloaded apk cannot open?

$
0
0

I'm trying to test my React Native apk app file.

Here are the steps I made before generate the apk:

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

then

cd android && .\gradlew assembleRelease -x bundleReleaseJsAndAssets

I created the key store about a month ago. At that time, I built a AAB to publish to Play Store

I didn't re-generate a new one before doing this

And here's the behavior:It can't open

I uploaded the apk to a social media app called: Zalo. Then downloaded it to my phone. At first I can't open since the Play Store blocked it. Only when I disabled that ability of Play Service in Settings than I could download it

PLEASE HELP MEEEE

Can't Run React-Native Run-Anroid

$
0
0

I've checked on similar topics but couldn't find my problem and solution. Would you help me please , what should i do ? I was learning React-Native 1-2 months ago and back then there were no problem. I made my first App and never used it again. Now i'm trying to make a new app this thing show up when i try to run.I've installed my project as react-native init CarComplaints then i opened Android Studio and Nexus 5 emulator then i tried react-native run-android , it fails. If I try to use react-native start or npm start nothing happens.

C:\reactnative>cd CarComplaints

C:\reactnative\CarComplaints>npx react-native run-androidinfo Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.Jetifier found 960 file(s) to forward-jetify. Using 12 workers...info Starting JS server...info Installing the app...Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.Use '--warning-mode all' to show the individual deprecation warnings.See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings

FAILURE: Build failed with an exception.

  • What went wrong:Task 'installDebug' not found in project ':app'.

BU�LD FAILED in 10s

at makeError (C:\reactnative\CarComplaints\node_modules\execa\index.js:174:9)at C:\reactnative\CarComplaints\node_modules\execa\index.js:278:16at processTicksAndRejections (internal/process/task_queues.js:97:5)at async runOnAllDevices (C:\reactnative\CarComplaints\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:5)at async Command.handleAction (C:\reactnative\CarComplaints\node_modules\react-native\node_modules\@react-native-community\cli\build\index.js:186:9)

Android NFC: How transceive method working with memory?

$
0
0

I have ntag213. I'm trying to understand how work blocks, sections of memory of my tag.I found project https://github.com/lepunk/react-native-nfc-demo/blob/master/RNNFCDemo/App.jsbut cannot understand what is agruments for transceive method:

let text = this.state.text;        let fullLength = text.length + 7;        let payloadLength = text.length + 3;        let cmd = Platform.OS === 'ios' ? NfcManager.sendMifareCommandIOS : NfcManager.transceive;        resp = await cmd([0xA2, 0x04, 0x03, fullLength, 0xD1, 0x01]); // 0x0C is the length of the entry with all the fluff (bytes + 7)        resp = await cmd([0xA2, 0x05, payloadLength, 0x54, 0x02, 0x65]); // 0x54 = T = Text block, 0x08 = length of string in bytes + 3

What it the arguments in every cmd?

Show toast every time after user passed the lock screen using React Native

$
0
0

I'm totally new on React Native and I'm struggling to create an app that shows a temporary message(2-3 sec) every time I pass the lock screen(by PIN or Finger Print). How to approach it? Any suggestion can be helpful.

React Native Android Fetch failing on connection to local API

$
0
0

I'm using the fetch API in my react-native Android app to make requests to a local API. I usually query said API from react web apps at http://localhost:8163.

I'm testing my app on my physical device in debugger mode. I read somewhere that react-native can't query localhost the same way a web app can. Apparently you have to use http://10.0.2.2:[PORT_NUMBER_HERE]/ which is an alias for `http://127.0.0.1:[PORT_NUMBER_HERE] according to the the Android emulator docks. I'm not sure if this is what I'm supposed to be doing for testing on a physical device.

My fetch code looks like the following:

fetchToken() {    fetch('http://10.0.2.2:8163/extension/auth', {        method: 'GET',        headers: {'Accept': 'application/json','Content-type': 'application/json'        }    })    .then((response)) => console.log('successful fetchToken response: ', response.json()))    .catch((error) => console.log('fetchToken error: ', error))    .done();}

The request always hangs for a while and then reaches the catch block with the unhelpful error TypeError: Network request failed(...). Checking the logs for my local API, they don't register the request at all.

So I have no idea if I'm querying my local API correctly to get the resource that I want, and if I am, I don't know why the fetch is failing.

gradlew assembleRelease it gives the following error in react-native

$
0
0

I want to make apk file of my application code, but whenever I am running gradlew assembleRelease it gives the following error, I just want to create the build with anything, as I have to deliver my project on Monday. Any help will be appreciated

 C:\Users\dines\Documents\ANUJ\managementportal\android>gradlew assembleRelease    :ReactNative:Unexpected empty result of running '[node, undefined, config]' command.    :ReactNative:Running '[node, undefined, config]' command failed.    FAILURE: Build failed with an exception.    * Where:    Script 'C:\Users\dines\Documents\ANUJ\managementportal\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 170    * What went wrong:    A problem occurred evaluating script.> internal/modules/cjs/loader.js:584    throw err;    ^Error: Cannot find module 'C:\Users\dines\Documents\ANUJ\managementportal\android\undefined'    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)    at Function.Module._load (internal/modules/cjs/loader.js:508:25)    at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)    at startup (internal/bootstrap/node.js:283:19)    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)    * Try:    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.    * Get more help at https://help.gradle.org    BUILD FAILED in 2s    C:\Users\dines\Documents\ANUJ\managementportal\android>

Expo - APK bundle must contain the expected embedded asset

$
0
0

I'm new on react, and i tried to run my app but i got this following error

E/AndroidRuntime: FATAL EXCEPTION: main    Process: com.bits.bee.bwc, PID: 12601    java.lang.AssertionError: APK bundle must contain the expected embedded asset asset_c2f3d742a18a28238b7cd34a5d4b7316.png        at expo.modules.updates.loader.EmbeddedLoader.copyAllAssets(EmbeddedLoader.java:174)        at expo.modules.updates.loader.EmbeddedLoader.processManifest(EmbeddedLoader.java:137)        at expo.modules.updates.loader.EmbeddedLoader.loadEmbeddedUpdate(EmbeddedLoader.java:57)        at expo.modules.updates.UpdatesController.start(UpdatesController.java:286)        at expo.modules.updates.UpdatesController.initialize(UpdatesController.java:96)        at com.bits.bee.bwc.MainApplication.onCreate(MainApplication.java:98)        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1011)        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4552)        at android.app.ActivityThread.access$1500(ActivityThread.java:147)        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1342)        at android.os.Handler.dispatchMessage(Handler.java:102)        at android.os.Looper.loop(Looper.java:135)        at android.app.ActivityThread.main(ActivityThread.java:5255)        at java.lang.reflect.Method.invoke(Native Method)        at java.lang.reflect.Method.invoke(Method.java:372)        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652)

Can someone explain to me how it's work because i looked it up in my asset folder there's nothing named like that. And how do i fix this? Thanks

error "Could not get BatchedBridge, make sure your bundle is packaged properly" on start of app

$
0
0

Trying to create a react-native project on Android 4.4.2 I get this error screen

said error

and couldn't find any way to resolve it. I tried restarting packager, reconnecting device, even reinstalling react native and starting new project. On 6.0.0 and later versions it works just fine.

How to solve: EEXIST: file already exists, mkdir 'C:\Users\OKR\Desktop\MeetUp' after generating apk failed in React Native?

$
0
0

I'm trying to test my React Native apk app file.

Here are the steps I made before generate the apk:

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

then

cd android && .\gradlew assembleRelease -x bundleReleaseJsAndAssets

I created the key store about a month ago. At that time, I built a AAB to publish to Play Store

I didn't re-generate a new one before doing this

And here's the behavior:It can't open

I uploaded the apk to a social media app called: Zalo. Then downloaded it to my phone. At first I can't open since the Play Store blocked it. Only when I disabled that ability of Play Service in Settings than I could download it

EDIT 1:I follow instructions on how to generate the apk from Android Studio, but at the end, it crashes and gives the error:

the transform cache was reset.EEXIST: file already exists, mkdir 'C:\Users\OKR\Desktop\MeetUp'

I don't know why this happens since I don't have that folder in the Desktop

PLEASE HELP MEEEE


react native blur not working over react native camera in Android

$
0
0

I'm using react-native-blur with Modal to create a blurred background. Everything seems to be working fine in Ios but the blur is not getting applied over when there is a camera preview in the background in Android

Ios

In Android

const styles = StyleSheet.create({  modalStyle: { backgroundColor: 'transparent' },  blurStyles: {    position: 'absolute',    top: 0,    bottom: 0,    left: 0,    right: 0  }})export default function BlurredModal({ children, modalProps, blurProps }) {  return (<Modal      animationType={'fade'}      transparent={true}      customStyle={styles.modalStyle}      {...modalProps}      radius={14}      downsampling={2}      brightness={-200}      blurStyle='dark'><BlurView        blurAmount={100}        blurType={'light'}        style={styles.blurStyles}        blurRadius={25}        downsampleFactor={25}        {...blurProps}      />      {children}</Modal>  )}

Expo - Icon doesn't show on Android

$
0
0

I'm using NativeBase icon on my react app. But when i tried to run it on Android, all of my icons won't show up and i got this following error

WARN Possible Unhandled Promise Rejection (id: 11): Error: The method or property expo-file-system.downloadAsync is not available on android, are you sure you've linked all the native dependencies properly?

Can someone help me? I've been stuck in this problem for days. Thanks.

Compatible side by side NDK version was not found React Native

$
0
0

I Have created a blank react native app and added webrtc package and now when I install my react native on my phones ,after installation it gets closed automatically and I don't know why app gets closed .The only thing i have noticed in my terminal is that it is saying Compatible side by side NDK version was not found .my Package.json is

{"name": "calling_App","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": {"react": "16.11.0","react-native": "0.62.2","react-native-webrtc": "^1.75.3"  },"devDependencies": {"@babel/core": "^7.9.0","@babel/runtime": "^7.9.2","@react-native-community/eslint-config": "^1.0.0","babel-jest": "^25.3.0","eslint": "^6.8.0","jest": "^25.3.0","metro-react-native-babel-preset": "^0.59.0","react-test-renderer": "16.11.0"  },"jest": {"preset": "react-native"  }}

Why my fetch request have problem Network Request Error in react native

$
0
0

i always get network request faith. Below is my code. It take me two days.

const res = await fetch('https://mydomain:8099/login', {    method: 'POST',    headers: {'Accept': '*/*','Content-Type': 'application/json',"Access-Control-Allow-Origin": "*",    },    body: JSON.stringify({        user: "my user name",        password: "my password"    })});console.log(res);return res;

pls help me.

Buildfailed : Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0

$
0
0

I'm using react-native and even I'm able to run my app in my simulator succesfully. But when i build the app I'm getting this error.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.Use '--warning-mode all' to show the individual deprecation warnings.See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings

I even installed jetifier. But nothing worked fine..

for both ./gradlew bundleRelease and ./gradlew assembleRelease I'm getting the Error.But for ./gradlew assembleRelease -x bundleReleaseJsAndAssets I'm not getting erro BUT that apk is not working in a physical device. It simply crashes.

Viewing all 28463 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>