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

React Native - Build successful on android but app crash

$
0
0

When I build (> react-native run-android) with my dependencies the build is successful !However, when the app is launch it crash immediately ...How don't know how is it possible, there is no error, nothing to tell me why the application is crashing...

It's sure it is from the dependencies...

dependencies {    implementation project(':react-native-intercom')    implementation "io.intercom.android:intercom-sdk:3.+"    implementation project(':react-native-onesignal')    implementation 'com.google.android.gms:play-services-location:+'    implementation project(':react-native-linear-gradient')    implementation project(':react-native-i18n')    implementation fileTree(dir: "libs", include: ["*.jar"])    implementation "com.facebook.react:react-native:+"    implementation project(':tipsi-stripe')    implementation (project(':react-native-maps')) {        exclude group: 'com.google.android.gms', module: 'play-services-base'        exclude group: 'com.google.android.gms', module: 'play-services-maps'    }    implementation (project(':react-native-camera')) {        exclude group: "com.google.android.gms"        exclude group: "com.android.support", module: 'support-v4'    }    implementation "com.android.support:appcompat-v7:23.0.1"    implementation 'com.google.android.gms:play-services-base:10.0.1'    implementation 'com.google.android.gms:play-services-maps:10.0.1'    implementation 'com.google.android.gms:play-services-gcm:10.0.1'}

Thank you really much


Change React Native App Name Based On Mobile Language Direction

$
0
0

Is it possible to change app name before installation of APK based on target mobile language direction ?

For example if the app name is Hello in ltr language phone , now if phone language is Persian (which is rtl ) we have "سلام" (equivalent of hello) for the app name

how do I upload Big files to Google Drive from React Native

How to create link to camera react native

$
0
0

I found camera API in react-native: react-native-cameraThis API allows having a camera inside of Components. But I don't like this, because by default it hasn't what has a camera app of the device. I want just to open the camera app of the device by clicking the button. Is it possible?

React-native app closes immediately after launching in android emulator

$
0
0

After the upgrading to latest react-native version when i launch my app in android emulator it closes immediately without any error or logs but works in smartphone, when i downgrade the react-native version in package.json file, it works fine.

I have tried clearing cache , removing old node_modules and reinstalling it,clean build gradle file , nothing seems to work.

old react-native version: "~0.61.4"
new react-native version: "^0.62.0"

SyntaxError: JSON Parse error: Unrecognized token '

$
0
0

I'm trying to send a fetch request using post to an api, I'm doing a search using a keyword and it should return a JSON containing users, whenever I try this on Android using expo it doesn't work however it seems to work on iOS using expo. The error I get back is a JSON parse error, I get a status code of 308.

import User from '../../Model/User';import { BearerToken }  from '../../Constants/BearerToken';export const GETRESULTS = 'GETRESULTS';export const getResults = (item) => {    return async dispatch => {        const response = await fetch("https://example.com",            {              method: 'POST',              headers: {'Accept': 'application/json','Content-Type': 'application/json','Authorization': BearerToken              },              body: JSON.stringify({                query: item              }),              redirect: 'follow'            }           );        console.log(response.status);        if(!response.ok) {          console.log("fack off");          const errorResData = await response.json();          console.log(errorResData);          let message = 'Something went wrong';          throw new Error(message);        }        const resData = await response.json();        const searchResultsArray = [];        for(const searchResult in resData){          searchResultsArray.push(new User(          resData[searchResult].education,          resData[searchResult].email,          resData[searchResult].full_name,          resData[searchResult].gender,          resData[searchResult].job_title,          resData[searchResult].location,          resData[searchResult].password,          resData[searchResult].phone,          resData[searchResult].preferred_name,          resData[searchResult].profile_image,          resData[searchResult].profile_type,          resData[searchResult].score,          resData[searchResult].short_bio,          resData[searchResult].story          )         );        }        dispatch({type: GETRESULTS,usersArray:searchResultsArray});    };};

Android App Production Methods by React Native

$
0
0

Introducing Android App Production Methods by React Native without installing or using Android Studio.

React native firebase - clear "ongoing" notification if app is cleared/killed

$
0
0

I am using react-native-firebase to show notifications in my application. I am showing a notification with property "ongoing" for some activity in my application as given below:

new firebase.notifications.Notification()                    .android.setLocalOnly(true)                    .android.setChannelId("channelid")                    .setNotificationId("activityId");                    .setTitle("Activity")                    .setBody("Activity in progress")                    .android.setOngoing(true);

I am programmatically clearing this notification when the activity is finished.

But if the user clears/kills the app without ending the activity, then the ongoing notification is not cleared from android status bar.

Which is the best way to remove the ongoing notification if the app is cleared/killed?

Versions I am using:

"react-native-firebase": "^5.6.0","react": "16.9.0","react-native": "0.61.5",

Getting the upload key used when app was built using 'expo ba' while in managed workflow. The app is now in bare workflow

$
0
0

My app was previously built while in the expo managed workflow. I did this using expo ba. Because android apps require that you release your app before you can add in-app-purchases, I uploaded this apk and released a beta using it.

I needed to switch to the bare workflow in order to implement in-app-purchases. Now, when trying to create a build to release the actual app, I am following the React Native instructions but must create another upload key in order to create a build(which is an aab this time).

On the play console it states

Upload key: The key you use to sign your first release. Sign every subsequent release with the same key to verify it’s from you. Keep your upload key safe. If it’s ever lost or compromised, contact developer support to replace it.

I'm pretty sure this is a problem because I used whatever expo was giving me to sign the original apk.I also cannot delete my original app and create a new app with the same bundle name because once an app is released it cannot be deleted.


Apparently the aab isn't even being signed, I'm receiving this when I upload the aab.I am pretty sure that everything I wrote above still applies though.

enter image description here

Publishing a bare-workflow expo React-Native app to the Google Playstore which was previously published while in the managed workflow

$
0
0

My app was previously built while in the expo managed workflow. I did this using expo ba. Because android apps require that you release your app before you can add in-app-purchases, I uploaded this apk and released a beta using it.

I needed to switch to the bare workflow in order to implement in-app-purchases. Now, when trying to create a build to release the actual app, I am following the React Native instructions but must create another upload key in order to create a build(which is an aab this time).

On the play console it states

Upload key: The key you use to sign your first release. Sign every subsequent release with the same key to verify it’s from you. Keep your upload key safe. If it’s ever lost or compromised, contact developer support to replace it.

I'm pretty sure this is a problem because I used whatever expo was giving me to sign the original apk.I also cannot delete my original app and create a new app with the same bundle name because once an app is released it cannot be deleted.

ADB can't connect to Nox

$
0
0

i have a problem which i trying to solve for about 3 days and i can't find any working solution. The problem is i can't connect my nox player to adb when i trying to connect with localhost and port 62001. Everything i did is:

-nox_adb.exe

nox_adb.exe connect 127.0.0.1:62001 -> unable to connect to 127.0.0.1:62001.

nox_adb.exe connect 127.0.0.1:5037 -> connected to 127.0.0.1:5037 (but when i trying to run react native project with this deviceId, it returns "No Android devices connected")

-adb.exe (from Android SDK)

adb.exe connect 127.0.0.1:62001 -> unable to connect to 127.0.0.1:62001.

adb.exe connect 127.0.0.1:5037 -> failed to connect to 127.0.0.1:5037.

I have installed whole android studio with (i think) needed libraries, Google USB Driver, sdk platforms, etc.Platform: Windows 7 x64Nox: 6.2.0.0

i have read:

Could someone tell me what I'm doing wrong?

How to get current route name in react-navigation?

$
0
0

I want the name of the current route or screen in react-navigation which I want to use inside if condition to make some changes.

How to solver the error : " Execution failed for task ':app:checkDebugDuplicateClasses'"

$
0
0

So I was running a react native project in windows and then I encountered this error can anyone help why I am getting so much duplicate errors.

View moves out of the screen when Text Input is focused used on Bottom Sheet in React Native for Android

$
0
0

I'm using the library - https://github.com/osdnk/react-native-reanimated-bottom-sheet

I'm using a TextInput on this bottom sheet. And now when the Text Input is focused or typed in, the bottom sheet should remain at the same position. It works fine for iOS, shown in the below screenshot.

enter image description here

And when I focus the Text Input on Android, the bottom sheet moves up along with the keyboard, shown in below 2 screenshots.

(Bottom Sheet in Android not focused)

enter image description here

(Bottom Sheet in Android focused)

enter image description here

I've also tried wrapping my bottom sheet inside KeyboardAvoidingView and it's props accordingly but it didn't work. Please help

How to make my react-native android app appear in the share list of another android app

$
0
0

Here, I am adding the image for more clarification of my problem statement.

enter image description here


Cant run RN app on real android device. MacOS

$
0
0

I am trying to test react native app on mobile device but I have error after launching npx react-native run-android.

Here is the error.

"Install Android SDK Build-Tools 28.0.3 (revision: 28.0.3)" finished.Checking the license for package Android SDK Platform 28 in /Users/admin/Library/Android/sdk/licensesLicense for package Android SDK Platform 28 accepted.Preparing "Install Android SDK Platform 28 (revision: 6)"."Install Android SDK Platform 28 (revision: 6)" ready.Installing Android SDK Platform 28 in /Users/admin/Library/Android/sdk/platforms/android-28"Install Android SDK Platform 28 (revision: 6)" complete."Install Android SDK Platform 28 (revision: 6)" finished.Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.Use '--warning-mode all' to show the individual deprecation warnings.See https://docs.gradle.org/4.10.1/userguide/command_line_interface.html#sec:command_line_warningsFAILURE: Build failed with an exception.* What went wrong:A problem occurred configuring project ':app'.> Failed to find target with hash string 'android-28' in: /Users/admin/Library/Android/sdk* 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.orgBUILD FAILED in 35serror Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081FAILURE: Build failed with an exception.* What went wrong:A problem occurred configuring project ':app'.> Failed to find target with hash string 'android-28' in: /Users/admin/Library/Android/sdk* 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.orgBUILD FAILED in 35s    at checkExecSyncError (child_process.js:611:11)    at execFileSync (child_process.js:629:15)    at runOnAllDevices (/Users/admin/Desktop/BST/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:39)    at processTicksAndRejections (internal/process/task_queues.js:97:5)

I have sdk downloaded and placed in /Users/admin/Library/android/sdk. $ANDROID_HOME shows same location...

I have enabled USB debugging over the phone and etc..

any help?

Value cannot be cast from ReadableNativeMap to double

$
0
0

I have a custom marker image and want to use a variable for the opacity of the image. I doing the following and gettin this error "Value for opacity cannot be cast from ReadableNativeMap to double"

var status=1;<MapView.Marker         key={marker.latitude}         coordinate={{ latitude: marker.latitude, longitude: marker.longitude }}          onPress={() => this.props.Quiz2(marker.latitude, marker.longitude)} ><View><Image source={require('../assets/icons/quiz.png')} style={{ width: 40, height: 40,opacity:status}}/></View></MapView.Marker>

enter image description here

Crashing on loading Home page component react native

$
0
0

I have created an app using react native cli, when ever trying to access the home page component the app get crashes. Other pages like splash, login, register components are loading perfectly. But after login the Home doesnot loading.

The app is perfectly working in debug mode, but when I create an release APK it is crashing, I have tried both in emulator and android phone.

I have tried to check the error log using adb logcat *:E. You can check the error log attached below.

ADb Logcat Error

Please check the code below,

package.json

{"name": "DoctorsBox","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": {"@fortawesome/fontawesome-svg-core": "^1.2.28","@fortawesome/free-solid-svg-icons": "^5.13.0","@fortawesome/react-native-fontawesome": "^0.2.3","@react-native-community/async-storage": "^1.9.0","@react-native-community/masked-view": "^0.1.7","@react-navigation/drawer": "^5.4.0","@react-navigation/material-top-tabs": "^5.1.7","@react-navigation/native": "^5.1.4","@react-navigation/stack": "^5.2.9","axios": "^0.19.2","firebase": "^7.13.2","lodash": "^4.17.15","moment": "^2.24.0","react": "16.11.0","react-native": "0.62.1","react-native-gesture-handler": "^1.6.1","react-native-gifted-chat": "^0.13.0","react-native-reanimated": "^1.7.1","react-native-safe-area-context": "^0.7.3","react-native-screens": "^2.4.0","react-native-svg": "^12.0.3","react-native-tab-view": "^2.13.0","react-redux": "^7.2.0","redux": "^4.0.5","redux-thunk": "^2.3.0"    },"devDependencies": {"@babel/core": "7.9.0","@babel/runtime": "7.9.2","@react-native-community/eslint-config": "0.0.5","babel-jest": "24.9.0","eslint": "6.8.0","jest": "24.9.0","metro-react-native-babel-preset": "0.58.0","react-test-renderer": "16.11.0"    },"jest": {"preset": "react-native"    }}

Home.js

import React, { Component } from 'react';import {StyleSheet,View,Text,AsyncStorage} from 'react-native';import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs';import ChatScreen from './ChatTab';const Tab = createMaterialTopTabNavigator();function HomeScreen() {    return (<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}><Text>Home!</Text></View>    );}function CallsScreen() {    return (<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}><Text>Calls!</Text></View>    );}export default class Home extends Component {    constructor(props) {        super(props);        this.state = {            refreshing: false,            category: null        };    }    async componentDidMount() {        let loginCategory = await AsyncStorage.getItem('SESS_CATEGORY');        await this.setState({category: loginCategory});    }    render() {        return (<View style={styles.container}><Tab.Navigator><Tab.Screen name="Home" component={HomeScreen} /><Tab.Screen name="Chats" component={ChatScreen} /><Tab.Screen name="Calls" component={CallsScreen} /></Tab.Navigator></View>        );    }}

ChatTab.js

import React, { Component } from 'react';import {StyleSheet,View,Text,AsyncStorage,FlatList,TouchableOpacity} from 'react-native';import firebase from 'firebase';import moment from 'moment';let colors = ["#0d2c4f", "#76ac42", "#2a55a5", "#1975a9"];export default class ChatTab extends Component {    constructor(props) {        super(props);        this.state = {            id: null,            loading: true        };    }    async componentDidMount() {        let loginId = await AsyncStorage.getItem('SESS_ID');        this.setState({id: loginId});        this.fetchConversations();    }    fetchConversations = () => {        let messagesTemp = [];        var ref = firebase.database().ref("Conversation");        ref.child(this.state.id).on("value", function(snapshot) {            // console.log(snapshot.val());            snapshot.forEach(function(childSnapshot) {                var key = childSnapshot.key;                var name = snapshot.child(key +'/name').val();                var title = snapshot.child(key +'/title').val();                var to_id = snapshot.child(key +'/to_id').val();                var sender = snapshot.child(key +'/sender').val();                var receiver = snapshot.child(key +'/receiver').val();                var msg_text = snapshot.child(key +'/text').val();                var timestamp = snapshot.child(key +'/timeStamp').val();                messagesTemp.push({_key: key, _name: name, _title: title, _to_id: to_id, _sender: sender, _receiver: receiver, _msg: msg_text, _timestamp: timestamp});            })        });        this.setState({ messages: messagesTemp });        if (this.state.messages !== null)            this.setState({ loading: false });    }    startChat = (uid, id, name, title) => {        this.props.navigation.navigate('Chat', {'to_uid': uid, 'to_id': id, 'chat_name': name, 'chat_title': title});    }    render() {        return (<View style={styles.container}><FlatList                    data={this.state.messages}                    showsVerticalScrollIndicator={false}                    renderItem={({ item, index }) => (<TouchableOpacity onPress={() => this.startChat(item._sender, item._to_id, item._name, item._title)}><View style={styles.singleList} key={item._key}><View style={[styles.viewCircle, [{backgroundColor: colors[index % colors.length]}]]}><Text style={styles.textCircle}>{item._name.charAt(0)}</Text></View><View style={{flex: 1, marginLeft: 10}}><Text style={styles.name}>{item._name}</Text><Text style={styles.title}>{item._msg}</Text></View><Text>{moment(item._timestamp).format('ddd hh:MM a')}</Text></View></TouchableOpacity>                    )}                    keyExtractor={item => item._key}                    ref={ref => this.flatList = ref}                    onContentSizeChange={() => this.flatList.scrollToEnd({animated: true})}                /></View>        );    }}

I am really stuck here. If someone got the idea it will be very helpfull.

react native vector icons won't show in android device

$
0
0

I used react-native-vector-icons in my react native project and start app with npm start.

Icons are displaying normally in iOS, but won't show in android.

Things I tried:

  • three method in the doc of react-native-vector-icons (finally I can see *.tff files in the fonts folder)
  • use react-native run-android to start app. Icon shows normal but what I want is integrating react native with my existing android app, not a totally RN app.
  • use jsbundle file instead of debug server in my app

None of above works

So, should I add something to my existing android app?

I don't know how to solve this problem


react@15.2.0

react-native@0.30.0

react-native-vector-icons@2.0.3

node v5.10.1

npm v3.8.3

getExpoPushTokenAsync not responding on Android testing device

$
0
0

i know there have been a few similar post regarding “standalone” devices out there, but this is about a (still) testing device in connection with the Expo XDE.

In short:

I am trying to get the Push Notification token using getExpoPushTokenAsyncthis is working perfectly for iphones, but not for android phones

Code:token = await Notifications.getExpoPushTokenAsync();–> return token for iphone, but nothing happens on Android (not even any following console.log)

just before:const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS);–> returns “granted”

I am using:“expo”: “^36.0.0”,

// if no existing permission ask user for permission   console.log("status: -"+ status +'-');    if (status !== 'granted') {      // Android remote notification permissions are granted during the app      // install, so this will only ask on iOS      const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS);      finalStatus = status;    }    // If no permission, exit ...    if (finalStatus !== 'granted') {      return;    }    // Get the token that uniquely identifies this device    console.log("BEFORE TOKEN....");    let token = await Notifications.getExpoPushTokenAsync();    console.log("TOKEN: "+ token);

Output Android:

status: -granted-TOKEN BEFORE....

Output iPhone:

status: -granted-TOKEN BEFORE....TOKEN: ExponentPushToken[Xxxxx_Xxxxxxxxxxxxxx]
Viewing all 29516 articles
Browse latest View live


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