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

react-native-fs DocumentDirectoryPath Where is the catalog on the phone?

$
0
0

https://github.com/itinance/react-native-fs

import RNFS from 'react-native-fs';console.log(RNFS.DocumentDirectoryPath);// /data/data/a.a.a/filesRNFS.writeFile(  RNFS.DocumentDirectoryPath +'/test.txt','Lorem ipsum dolor sit amet','utf8',)  .then(success => console.log('FILE WRITTEN!'))  .catch(err => console.log(err.message));

But this file is not on the phone /Android/data/a.a.a/files/test.txt

Where is this file ?


Is it possible to transfer parameter's from one react-native application to another react-native application?

$
0
0

Am trying to pass parameter from one react-native application to another react-native application. I know it is possible & did it well in Android, but just want to know about how it will be done in react-native.

One caller application let's say Param_send_App, Param_receive_app.

From Param_send_App I will call Linking.openURL('param_receive_app://app?param1=test&param2=test2')but how Will I receive the param in Param_receive_app ?

Splash screen blur when using react native with expo

$
0
0

When I opened my splash screen on gallery it looks fine, no blur, but why when I add it to my react native expo project it looks like this? can I use svg for my splash?

enter image description here

here's code on my app.json.

{"name": "thisisname","displayName": "thisisname","expo": {"name": "thisisname","slug": "thisisname","version": "1.0.0","orientation": "portrait","icon": "./assets/icon.png","assetBundlePatterns": ["**/*"    ],"splash": {"image": "./assets/splash.png","resizeMode": "contain","backgroundColor": "#000000"    },"android": {"package": "nameofpackage"    }  }}

Accessing webrtc audio stream in react-native app

$
0
0

I'm developing a react-native app and it has audio conference rooms functionality.

I performed the whole react-native-webrtc setup and achieved some good results. The only big problem i have to tackle yet is how do i route the audio stream i receive from my RTCPeerConnection into some kind of "background" audio player. Ideally i see it implemented like podcasts are implemented on Spotify etc... What i tried yet is react-native-callkeep which is not kinda what i want since i want more of a "podcast" feeling rather than a "call" feeling.

Did anyone solved similar problem before? If yes, i would really appreciate some thoughts or insights. Are you a native swift/kotlin mobile engineer? If yes i would be glad to hear your thoughts on a native approach i could use to turn it into a RN package

How to change the style of Urban Airship Push Notification

$
0
0

I am using React Native and PHP and Urban Airship Push notification.

Please take a look at these three images.

Actual Result:

Actual Result:

Expected Results:

Expected Result:

Expected Result:

As you can see, I am going to use user avatars instead of the app icon and add user name in front of "Notifications now" and remove the Notification title.

PHP code is like below.

$request = ['audience' => ['named_user' => $accountIDs,    ],'notification' => ['alert' => "Content text"'android' => ['title' => "Notification title",         ],     ],'device_types' => ['android','ios',      ],];

Any help is appreciated.

Thanks.

getting error Task :expo-permissions:compileReleaseKotlin FAILED when i try to build an apk with .\gradlew bundleRelease

$
0
0

I'm getting BUILD FAILED everytime I try to run ./gradlew bundleRelease to create the apk for my react-native project. I'm not getting any error on emulator or android device. The code compiles and when I do expo start (also with --no-dev --minify) it works perfectly on my device (Galaxy J7 2017).

'''

Task :expo-permissions:compileReleaseKotlin FAILEDe: C:\Users\fedet\Documents\openart\node_modules\react-native-unimodules\node_modules\expo-permissions\android\src\main\java\expo\modules\permissions\PermissionsService.kt: (16, 40): Unresolved reference: PermissionAwareActivitye: C:\Users\fedet\Documents\openart\node_modules\react-native-unimodules\node_modules\expo-permissions\android\src\main\java\expo\modules\permissions\PermissionsService.kt: (170, 17): Unresolved reference: PermissionAwareActivitye: C:\Users\fedet\Documents\openart\node_modules\react-native-unimodules\node_modules\expo-permissions\android\src\main\java\expo\modules\permissions\PermissionsService.kt: (236, 19): Unresolved reference: PermissionAwareActivitye: C:\Users\fedet\Documents\openart\node_modules\react-native-unimodules\node_modules\expo-permissions\android\src\main\java\expo\modules\permissions\PermissionsService.kt: (237, 62): Too many arguments for public final fun requestPermissions(@NonNull p0: Array<(out) String!>, p1: Int): Unit defined in android.app.Activitye: C:\Users\fedet\Documents\openart\node_modules\react-native-unimodules\node_modules\expo-permissions\android\src\main\java\expo\modules\permissions\PermissionsService.kt: (237, 64): Cannot infer a type for this parameter. Please specify it explicitly.e: C:\Users\fedet\Documents\openart\node_modules\react-native-unimodules\node_modules\expo-permissions\android\src\main\java\expo\modules\permissions\PermissionsService.kt: (237, 77): Cannot infer a type for this parameter. Please specify it explicitly.e: C:\Users\fedet\Documents\openart\node_modules\react-native-unimodules\node_modules\expo-permissions\android\src\main\java\expo\modules\permissions\PermissionsService.kt: (237, 97): Cannot infer a type for this parameter. Please specify it explicitly.w: Detected multiple Kotlin daemon sessions at build\kotlin\sessionsFAILURE: Build failed with an exception.'''

this the error log that appears on my terminal.

And this is my package.json

{"main": "index.js","scripts": {"android": "react-native run-android","ios": "react-native run-ios","web": "expo start --web","start": "react-native start","test": "jest"  },"dependencies": {"@expo-google-fonts/montserrat": "^0.1.0","@expo/vector-icons": "^12.0.0","@fortawesome/fontawesome-svg-core": "^1.2.32","@fortawesome/free-solid-svg-icons": "^5.15.1","@fortawesome/react-native-fontawesome": "^0.2.6","@react-native-community/masked-view": "0.1.10","@react-navigation/bottom-tabs": "^5.2.8","@react-navigation/native": "^5.1.7","@react-navigation/stack": "^5.2.14","expo": "^40.0.0","expo-app-loading": "^1.0.1","expo-font": "~8.4.0","expo-linear-gradient": "~8.4.0","expo-splash-screen": "~0.8.1","expo-status-bar": "~1.0.2","expo-updates": "~0.4.1","react": "16.13.1","react-dom": "16.13.1","react-native": "https://github.com/expo/react-native/archive/sdk-40.0.0.tar.gz","react-native-elements": "^3.1.0","react-native-gesture-handler": "~1.8.0","react-native-global-props": "^1.1.5","react-native-image-pan-zoom": "^2.1.12","react-native-maps": "0.27.1","react-native-reanimated": "~1.13.0","react-native-safe-area-context": "3.1.9","react-native-screens": "~2.15.0","react-native-svg": "^12.1.0","react-native-unimodules": "~0.11.0","react-native-vector-icons": "^7.1.0","react-native-web": "^0.13.18","expo-permissions": "9.1.0"  },"devDependencies": {"@babel/core": "~7.9.0","babel-jest": "~25.2.6","jest": "~25.2.6","react-test-renderer": "~16.13.1"  },"jest": {"preset": "react-native"  },"private": true}

Can someone help me with that? Is the first time I try to develop an android app with react native, expo and gradlew and I don't even know where to check.Thanks in advance

Cannot package APK after adding expo to react-native project

$
0
0

I've been developing a react native app for a while now and I was able to generate APKs using the ./gradlew assembleRelease command. I recently added expo to the project as I replaced the react-native-camera library with expo-camera. My debug builds are running fine (using react-native run-android). But when I try to package the app into an APK, I'm met with the following error:

./gradlew assembleRelease> Configure project :appInstalling unimodules: unimodules-core@6.0.0 from /Users/anil/testing/node_modules/@unimodules/core unimodules-react-native-adapter@5.7.0 from /Users/anil/testing/node_modules/@unimodules/react-native-adapter expo-application@2.4.1 from /Users/anil/testing/node_modules/expo-application expo-camera@9.1.1 from /Users/anil/testing/node_modules/expo-camera expo-constants@9.3.5 from /Users/anil/testing/node_modules/expo-constants expo-error-recovery@1.4.0 from /Users/anil/testing/node_modules/expo-error-recovery expo-file-system@9.3.0 from /Users/anil/testing/node_modules/expo-file-system expo-font@8.4.0 from /Users/anil/testing/node_modules/expo-font expo-image-loader@1.3.0 from /Users/anil/testing/node_modules/expo-image-loader expo-keep-awake@8.4.0 from /Users/anil/testing/node_modules/expo-keep-awake expo-linear-gradient@8.4.0 from /Users/anil/testing/node_modules/expo-linear-gradient expo-location@10.0.0 from /Users/anil/testing/node_modules/expo-location expo-permissions@10.0.0 from /Users/anil/testing/node_modules/expo-permissions expo-secure-store@9.3.0 from /Users/anil/testing/node_modules/expo-secure-store expo-splash-screen@0.8.1 from /Users/anil/testing/node_modules/expo-splash-screen expo-sqlite@8.5.0 from /Users/anil/testing/node_modules/expo-sqlite expo-updates@0.4.1 from /Users/anil/testing/node_modules/expo-updates unimodules-app-loader@1.4.0 from /Users/anil/testing/node_modules/unimodules-app-loader unimodules-barcode-scanner-interface@5.4.0 from /Users/anil/testing/node_modules/unimodules-barcode-scanner-interface unimodules-camera-interface@5.4.0 from /Users/anil/testing/node_modules/unimodules-camera-interface unimodules-constants-interface@5.4.0 from /Users/anil/testing/node_modules/unimodules-constants-interface unimodules-face-detector-interface@5.4.0 from /Users/anil/testing/node_modules/unimodules-face-detector-interface unimodules-file-system-interface@5.4.0 from /Users/anil/testing/node_modules/unimodules-file-system-interface unimodules-font-interface@5.4.0 from /Users/anil/testing/node_modules/unimodules-font-interface unimodules-image-loader-interface@5.4.0 from /Users/anil/testing/node_modules/unimodules-image-loader-interface unimodules-permissions-interface@5.4.0 from /Users/anil/testing/node_modules/unimodules-permissions-interface unimodules-sensors-interface@5.4.0 from /Users/anil/testing/node_modules/unimodules-sensors-interface unimodules-task-manager-interface@5.4.0 from /Users/anil/testing/node_modules/unimodules-task-manager-interface> Task :react-native-video:compileReleaseJavaWithJavacNote: Some input files use or override a deprecated API.Note: Recompile with -Xlint:deprecation for details.> Task :app:bundleReleaseJsAndAssetswarning: the transform cache was reset.                 Welcome to React Native!                Learn once, write anywhereTypeError: (intermediate value).eachMapping is not a functionerror index.js: (intermediate value).eachMapping is not a function. Run CLI with --verbose flag for more details.    at toBabelSegments (/Users/anil/testing/node_modules/metro/node_modules/metro-source-map/src/source-map.js:167:46)    at /Users/anil/testing/node_modules/metro/src/JSTransformer/worker.js:425:15    at Generator.next (<anonymous>)    at asyncGeneratorStep (/Users/anil/testing/node_modules/metro/src/JSTransformer/worker.js:75:24)    at _next (/Users/anil/testing/node_modules/metro/src/JSTransformer/worker.js:95:9)    at /Users/anil/testing/node_modules/metro/src/JSTransformer/worker.js:100:7    at new Promise (<anonymous>)    at /Users/anil/testing/node_modules/metro/src/JSTransformer/worker.js:92:12    at JsTransformer._minifyCode (/Users/anil/testing/node_modules/metro/src/JSTransformer/worker.js:437:7)> Task :app:bundleReleaseJsAndAssets FAILEDFAILURE: Build failed with an exception.* What went wrong:Execution failed for task ':app:bundleReleaseJsAndAssets'.> Process 'command 'node'' finished with non-zero exit value 1* 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.orgDeprecated 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.5/userguide/command_line_interface.html#sec:command_line_warningsBUILD FAILED in 1m 4s93 actionable tasks: 93 executed

I tried the following before running release:

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

but that does not seem to fix the issue.

When I use Android Studio and use the menu option Build -> Build Bundle -> Build APK(s), I get the debug build of the app (the one that looks for the react-native server). Currently, in our distribution setup, I can only use APKs. App Bundle is not supported yet. I also tried updating the metro-react-native-babel-preset version to the latest. That did not seem to make any difference either.

Convert Lat Long to XYZ Coordinates AR React Viro

$
0
0

I'm working on converting lat long into xyz coordinates of AR using ViroReact. To adjust the real world coordinate system to the compass coordinates, on the iOS side, I use worldAlignment = {"GravityAndHeading"}, displaying it is relative, and on Android I don't know how to handle this paragraph? Anyone who has ever studied or worked on this, let me consult?

I also checking this: https://github.com/viromedia/viro/issues/131, but I could not find a suitable solution :(

Below I capture the code that transforms from the actual coordinates to the coordinates XYZ in AR.

enter image description here

enter image description here


React Native app for android when moved to background shows white screen?

$
0
0

When I move my React native app to background irrespective on which screen I am on, it shows white screen instead of the screen I should be in? I am not talking about the white splash screen.This issue happens only on android and not on iOS

https://preview.redd.it/yhalbullg3b61.jpg?width=720&format=pjpg&auto=webp&s=a690d3470b7923d8de64d38fa335d86257fd6612

I am using React Navigation. I am not even sure what code to post or where to look for debugging.I also tried with release mode apk but the issue persists for android.

com.app.MainActivity cannot be cast to com.facebook.react.ReactActivity

$
0
0

Getting this Android error when using a React Native third party library, did some debug and narrow down to the following Kotlin code

class GModule(private val reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {    val activity = reactContext.currentActivity as ReactActivity

tried to debug it myself but have no idea where to start as I am not familiar with Kotlin, any help or guidance is much appreciated :) thankssssss

React native Material drop down get id from json data

$
0
0

I have used react-native-material-dropdown in my react native project. I am getting a data from API.

The issue is i am getting name successfully in drop-down but i want a hotelId of that selected name. I am not able to parse the whole JSON in the drop-down.

JSON :

    {"message": "Success","notificationCount": 0,"result": [{"hotelId": "india3c71a2b8-05d3-476e-825a-f31e08ac3bdc","name": "Hotel Samrat"            }, {"hotelId": "indiae4ef0d05-f46e-48f3-9bce-a37bfde089a4","name": "Hotel Kalinga Ashok"            }],"status": 1,"totalRecord": 2,"scopeId": ""   }

I have parsed data by :

var count = Object.keys(responseJSON.result).length;            let drop_down_data = [];            for (var i = 0; i < count; i++) {                console.log(responseJSON.result[i].name) // I need to add                 drop_down_data.push({ value: responseJSON.result[i].name }); // Create your array of data            }

And added that array in dropdown :

<Dropdown       label={'Select hotel name'}       data={this.state.data}       baseColor='#79292F'  />

I have gone through all stack overflow answers. but i ma not able to get the exact answer.

How to build Expo APK local

$
0
0

Is it possible to build the APK of an expo app locally?

The doc says:

If you haven’t used exp before, the first thing you’ll need to do is login with your Expo account using exp login.

I tried exp start, exp build:android but the commands require a login.

I don't want to build the APK using expo server. Is there a way to run this build locally? So no login and push of source code required?

If not, can I view the whole source code of the generated APK?

'react-native-mathjax' not rendering for single backslash

$
0
0

I am using 'react-native-mathjax' to render math equations. 'react-native-mathjax' not able to render for single backslash. When I add double backslash in place of single backslash and four backslashes in place of double backslash in the equation given below, 'react-native-mathjax' renders the equation, is there any solution?

    import React from 'react';    import { View, Text } from 'react-native';    import MathJax from 'react-native-mathjax';    function Test() {            return (<View><MathJax                        html={<p><span class="math-tex">\(\begin{bmatrix} 2 &1 \\[0.3em] 3&4\\[0.3em] \end{bmatrix}\)</span></p>} // not rendering this eqation                    /></View>     );    }    export default Test;

React native Linking.getInitialUrl on Android called always

$
0
0

I've a React-Native app with the following code (here App.js, the app entry point) that manages deep link on Android.

Linking.getInitialURL().then((deepLinkUrl) => {  if (deepLinkUrl) {    manageDeepLink(deepLinkUrl);  } else {    Navigation.startSingleScreenApp('rootScreen');  }});

The problem here is that getInitialURL is called every time I launch my app, from both deep link or normally, and everytime it contains deepLinkUrl parameter empty.I've registered in AndroidManifest my intent as follows:

<application    android:name=".MainApplication"    android:allowBackup="true"    android:launchMode="singleTask"    android:icon="@mipmap/ic_launcher"    android:label="@string/app_name"    android:theme="@style/AppTheme"><activity        android:name=".MainActivity"        android:label="@string/app_name"        android:windowSoftInputMode="adjustResize"><!-- deeplink --><intent-filter android:label="@string/app_name"><action android:name="android.intent.action.VIEW" /><category android:name="android.intent.category.DEFAULT" /><category android:name="android.intent.category.BROWSABLE" /><data android:scheme="myapp" /></intent-filter><intent-filter><action android:name="android.intent.action.MAIN"/><action android:name="android.intent.action.DOWNLOAD_COMPLETE"/><category android:name="android.intent.category.LAUNCHER"/></intent-filter></activity>

UPDATEI'm using react-native navigation to register screens, if this can e useful.

React native TouchableOpacity onPress not working on Android

$
0
0

TouchabelOpacity works fine on iOS but the onPress method does not work on Android for me.

My react-native version: 0.57.4

My code:

const initDrawer = navigation => (<TouchableOpacity    style={{ left: 16 }}    onPress={() => onPressDrawerButton(navigation)}><Ionicons name="ios-menu" color="white" size={30} /></TouchableOpacity>);

adb server version (40) doesn't match this client (41); killing [duplicate]

$
0
0

Couldn't start project on Android: adb server version (40) doesn't match this client (41); killing...could not read OK from ADB Server* failed to start daemonadb.exe: failed to check server version: cannot connect to daemon

i have installed android platform development tools but it still doesn't work even after changing Genymotion settings to use my android Software development kit instead of its default android tools

React native Xiaomi Phone axios not working

Using webview payment in IOS

$
0
0

I'm a new developer. I'm using react native expo managed base. I'm going to develop an application that must have payment, my question is that is it possible to use webview to handle payment inside my app ? I searched a lot but I couldn't find the clear answer. I hope you give me a clear answer.Thank you and best regards

Is it possible to emulate esim on AVD?

$
0
0

I've created a simple native module for React Native to see if the phone supports eSim.I've used this instruction Here's the module's code.

package com.nativetest;import android.app.assist.AssistStructure;import android.content.Context;import android.os.Build;import android.telephony.euicc.EuiccManager;import android.util.Log;import androidx.annotation.RequiresApi;import com.facebook.react.bridge.NativeModule;import com.facebook.react.bridge.ReactApplicationContext;import com.facebook.react.bridge.ReactContext;import com.facebook.react.bridge.ReactContextBaseJavaModule;import com.facebook.react.bridge.ReactMethod;public class EsimModule extends ReactContextBaseJavaModule {    private static ReactApplicationContext reactContext;    EsimModule(ReactApplicationContext context) {        super(context);        reactContext = context;    }    @RequiresApi(api = Build.VERSION_CODES.P)    @ReactMethod    public void checkIfEsimEnabled() {        EuiccManager mgr = (EuiccManager) reactContext.getSystemService(Context.EUICC_SERVICE);        assert mgr != null;        Log.d("EsimModule", "Is Esim enabled " + mgr.isEnabled());        mgr.isEnabled();    }    @Override    public String getName() {        return "Esim";    }}

The problem is that when I run my app on emulator (Google Pixel 3a, API 30), the result of mgr.isEnabled() is always false, so I can't check if I get the right data on RN side. Is there a way to configure an emulator with eSim support?

Checking whether you can open an external app & opening it with React Native

$
0
0

I have a third party app that apparently has some deep linking protocol (x-mythirdpartyapp://). I don't need to do any deep linking to the contents of it just open it. It also does not react to the corresponding url (i.e. https://mythirdpartyapp.com) so the answers for similar questions related to whatsapp are useless here.

Based on my research so far, these custom deep linking protocols are iOS only, so this should work for iOS

Linking.canOpenUrl("mythirdpartyapp://")andLinking.openUrl("mythirdpartyapp://")

But can't confirm them as I don't have any iOS devices.

As for Android you can apparently open intents with Linking.sendIntent but this is not enough as in my use case I need to know whether I can send the intent before actually sending it.

Viewing all 29537 articles
Browse latest View live


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