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

Hardware backpress is not working after exit once with backpress in react native with react navigation

$
0
0

Here is my project structure:

 - StackNavigator        - Auth Navigator       - APP Navigator         - Drawer Navigator           - Drawer Screen-1             - Stack navigator               - Screen 1               - Screen 2           - Drawer Screen-2               - Stack navigator                 - Screen 1                 - Screen 2           - Drawer Screen-3             - Stack navigator               - Screen 1               - Screen 2

Steps to reproduce:

  • Now when we exit the app with hardware back press in the android app goes in background mode.
  • After reopening the application, Hardware back press stopped working.

If anyone faced issue like this please give a solution for this. Thanks in advance.

I am using following versions:    @react-navigation/native: 5.0.7    @react-navigation/stack: 5.0.9    @react-navigation/drawer: 5.0.7    react-native-reanimated 1.7.0    react-native-gesture-handler: 1.6.1    react-native-safe-area-context: 0.7.3    react-native-screens: 2.0.0-beta.13    react-native: 0.61.5    node: 12.11.1

I haven't implemented any backhandler listener for handling the back operation.


getInitialNotification method not getting called when app is in background in react native

$
0
0

In android, I am trying to call getInitialNotification() method in my componentDidMount of App.js Class but when my app is in background and i click on notification my app is not opening by clicking on notification and also notification is getting remove

here is my componentDidMount method code

  firebase.notifications().getInitialNotification()            .then((notificationOpen: NotificationOpen) => {                if (notificationOpen) {                    console.log('getInitialNotification AppJS : ########: ')                    // App was opened by a notification                    // Get the action triggered by the notification being opened                    const {action, notification} = notificationOpen                    let item = JSON.parse(notification.data.body)                    console.log('getInitialNotification AppJS : ########: item ', item)                    console.log('getInitialNotification AppJS : ########: action ', action)                    setTimeout(() => {                        EventBus.getInstance().fireEvent('NOTIFICATION', {item: item})                    }, 5000)                }            })

here is my AndroidManifest.xml

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/><uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/><uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /><uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/><uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /><uses-permission android:name="android.permission.VIBRATE" /><uses-permission android:name="android.permission.CAMERA"/><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/><application      android:name=".MainApplication"      android:label="@string/app_name"      android:icon="@mipmap/ic_launcher"      android:roundIcon="@mipmap/ic_launcher_round"      android:allowBackup="false"      android:usesCleartextTraffic="true"      android:theme="@style/AppTheme"><activity          android:name=".SplashActivity"          android:label="@string/app_name"          android:launchMode="singleTask"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity><activity          android:name=".MainActivity"          android:label="@string/app_name"          android:configChanges="keyboard|keyboardHidden|orientation|screenSize"          android:screenOrientation="portrait"          android:exported="true"          android:windowSoftInputMode="adjustResize"          android:launchMode="singleTask"      /><activity android:name="com.facebook.react.devsupport.DevSettingsActivity" /><meta-data        android:name="com.google.android.geo.API_KEY"        android:value="APIKEYVALUE"/><service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService"><intent-filter><action android:name="com.google.firebase.MESSAGING_EVENT" /></intent-filter></service><service android:name="io.invertase.firebase.messaging.RNFirebaseInstanceIdService"><intent-filter><action android:name="com.google.firebase.INSTANCE_ID_EVENT"/></intent-filter></service><service android:name="io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService" /></application></manifest>

here is my SplashActivity.java code

@Override        protected void onCreate(Bundle savedInstanceState) {            super.onCreate(savedInstanceState);            Intent fcmIntent = this.getIntent();            Bundle bundle = fcmIntent.getExtras();            Intent intent = new Intent(this, MainActivity.class);            intent.putExtras(fcmIntent);            startActivity(intent);            finish();        }

Push notifications send bird messaging

$
0
0

I am using sendbird library as a messaging client in react-native. I aim to receive push notifications triggered by sendbird in a channel. I did all the configuration from my side by following documentation given by send bird. Even token is also successfully registered by sendbird. But, when I send message in a group channel the other user of the same channel is not receiving it.

Using below line of code to trigger notifications.

Have used react-native-firebase for notifications as sendbird by default use Firebase for triggering notifications.

    groupChannel.setMyPushTriggerOption('default', function(response, error) { if (error) { return; }  // Do something in response to setting });

Add Style to DropDown React native

$
0
0

I add this plugin and try to draw the Dropdown, it works fine in this way

<View style={{ flex: 1, justifyContent: 'center', alignItems: 'flex-start',alignSelf:'center', backgroundColor:'#ebeef0'}}><Select style={{  alignItems: 'flex-start' }}            width={250}            ref="SELECT1"            optionListRef={this._getOptionList.bind(this)}            defaultValue="Select One of Option ..."            onSelect={this._canada.bind(this)}><Option>First</Option><Option>Second</Option><Option>Third</Option><Option>Forth</Option><Option>Fifth</Option><Option>Six</Option><Option>Seven</Option><Option>Eight</Option><Option>Ten</Option><Option>Eleven</Option><Option>Twelve</Option></Select>          <OptionList ref="OPTIONLIST"/></View>

What I need ,to make it looks like the asp.net dropdown with arrow asenter image description here

At least I want to know how to change the style of the Dropdown how can I override the style of the installed plugin.

npx react-native run-android does not launch app stays in IDLE

$
0
0

I have been trying to learn react-native. On day one of initial setup, I was able to run the application on my android phone using following.

npx react-native init AwesomeProjectcd AwesomeProjectnpx react-native startnpx react-native run-android

On day two, I resumed working, but now the app would not launch or refresh. I had the app installed in phone from previous day. When I do npx react-native run-android I see following output.

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no- jetifier" flag.Jetifier found 970 file(s) to forward-jetify. Using 12 workersinfo JS server already running.info Installing the appTask :app:stripDebugDebugSymbols UP-TO-DATECompatible side by side NDK version was not found.<============-> 99% EXECUTING [4m 49s]IDLEIDLEIDLEIDLE:app:installDebugIDLEIDLEIDLEIDLEIDLEIDLEIDLE

I am trying to run following versions.

react-native : 0.62.2

On Android oneplus 7 physical device.I have tried following.npx react-native start --reset-cacheadb kill-serveradb start-server./gradlew build

How to touch and hold to select text in React Native

$
0
0

I'm new to Android and trying to implement a rich editor using Text component of React Native. However when I touch the text and hold for a moment, the text was not highlighted and the top bar with selection actions was not shown like what behaves in a webview or other applications.What am I missing or do I need to implement this feature by myself? If so could you point a direction?

'react-native-image-picker' Error while updating property 'src' of a view managed by: RCTImageView

$
0
0

Does anyone know how to resolve this error?

"Error while updating property 'src' of a view managed by: RCTImageView"

This error appear when the component is rendering. I think that the images do not give them time to download or something like this.

Dependences: "firebase": "^4.8.2","react": "16.0.0-alpha.12","react-native": "0.47","react-native-image-picker": "^0.26.7",

ERROR

enter image description here

Gallery.js

  import React, { Component } from 'react';  import { View, Image, ScrollView, StyleSheet, Dimensions } from 'react-native';  import { connect } from 'react-redux';  import firebase from '../../config/firebase';  import { nameChanged } from '../../actions';  import { CardSectionTransp, InputBlack } from '../common';  import { SnapshotToArray } from '../../config/helpers';  const { width, height } = Dimensions.get('window');  class EventDetail extends Component {    constructor(props) {      super(props);      this.state = {        images: [],        objImages: []      };    }    componentWillMount() {      firebase.database().ref().child('images').orderByChild('order').once('value', snapshot => {        const images = SnapshotToArray(snapshot);        this.setState({ objImages: images });        const arrayImages = [];        for (const image of images) {          const starsRef = firebase.storage().refFromURL('gs://bealegendapp.appspot.com/images/'+ image.path);          // Get the download URL          starsRef.getDownloadURL().then((url) => {            arrayImages.push(url);            this.setState({ objImages: arrayImages });          }).catch((error) => {            // A full list of error codes is available at            // https://firebase.google.com/docs/storage/web/handle-errors            switch (error.code) {              case 'storage/object_not_found':                // File doesn't exist                break;              case 'storage/unauthorized':                // User doesn't have permission to access the object                break;              case 'storage/canceled':                // User canceled the upload                break;              case 'storage/unknown':                // Unknown error occurred, inspect the server response                break;              default:                break;            }          });        }      });    }    onNameChange(text) {        this.props.nameChanged(text);    }    render() {      return (<ScrollView style={styles.container}><CardSectionTransp><InputBlack               label="Nombre"               onChangeText={this.onNameChange.bind(this)}               value={this.props.name}             /></CardSectionTransp><View style={{ flex: 1, flexDirection: 'row', flexWrap: 'wrap', marginTop: 10 }}>            {this.state.objImages && this.state.objImages.length > 0 &&              this.state.objImages.map((image, key) => {                return (<View key={key} style={{ width: width / 3 }}><Image <-------------EEEEEEERRRRRRRROOOOOOORRRRRRR!!!!                      source={{ uri: image }}                      style={styles.image}                    /></View>                );              })            }            {this.props.photos &&              this.props.photos.map((image, key) => {                return (<View key={key} style={{ width: width / 3 }}><Image                      source={{ uri: image }}                      style={styles.image}                    /></View>                );              })            }</View></ScrollView>     );   }  }  const styles = StyleSheet.create({    container: {      flex: 1,      backgroundColor: '#F5FCFF',      paddingBottom: 123    },    image: {      height: height / 5,      resizeMode: 'contain',      width: width / 3,      borderWidth: 1,      borderColor: 'white'    }  });  const mapStateToProps = ({ gallery }) => {    const { name, photos } = gallery;    return { name, photos };  };  export default connect(mapStateToProps, {    nameChanged  })(EventDetail);

Android Studio React Native Build fails

$
0
0

Hi Guys I took the project I am developing at my workplace home and wanted to run it here on my machine..

I got many many errors wich I fixxed but there are some that I dont know how maybe you guys know a fixx.

\android\app\build\intermediates\external_file_lib_dex_archives\debug\out

this output get generated when building the project from AS.

I read that the fixx is to add this : android.enableBuildCache=false to gradle.properties but when I do that I get this error wich make 0 sense tbh.

: Cannot parse project property android.enableBuildCache='false ' of type 'class java.lang.String' as boolean. Expected 'true' or 'false'.

EDIT: Ok there was an empty space after false hence the second error but even with that corrected I get the first error.

Running it from vsCode gives me: Execution failed for task ':app:processDebugResources'.

EDIT2: Newest Error in AS:

> Task :app:mergeExtDexDebugjava.nio.file.NoSuchFileException: C:\Users\Faded\Desktop\Development\React Native\FitnessApp\FitnessApp\android\app\build\intermediates\external_file_lib_dex_archives\debug\out    at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79)    at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)    at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)    at sun.nio.fs.WindowsDirectoryStream.<init>(WindowsDirectoryStream.java:80)    at sun.nio.fs.WindowsFileSystemProvider.newDirectoryStream(WindowsFileSystemProvider.java:522)    at java.nio.file.Files.newDirectoryStream(Files.java:457)    at java.nio.file.Files.list(Files.java:3451)    at com.android.build.gradle.internal.tasks.DexMergingParams.getAllDexFiles(DexMergingTask.kt:502)    at com.android.build.gradle.internal.tasks.DexMergingTaskRunnable.run(DexMergingTask.kt:423)    at com.android.build.gradle.internal.tasks.Workers$ActionFacade.run(Workers.kt:335)    at org.gradle.workers.internal.AdapterWorkAction.execute(AdapterWorkAction.java:50)    at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:50)    at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1$1.create(NoIsolationWorkerFactory.java:65)    at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1$1.create(NoIsolationWorkerFactory.java:61)    at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:98)    at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.execute(NoIsolationWorkerFactory.java:61)    at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)    at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)    at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)    at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)    at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)    at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)    at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)    at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)    at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:53)    at org.gradle.workers.internal.DefaultWorkerExecutor$3.call(DefaultWorkerExecutor.java:217)    at org.gradle.workers.internal.DefaultWorkerExecutor$3.call(DefaultWorkerExecutor.java:212)    at java.util.concurrent.FutureTask.run(FutureTask.java:266)    at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:215)    at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:164)    at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:131)    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)    at java.util.concurrent.FutureTask.run(FutureTask.java:266)    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)    at java.lang.Thread.run(Thread.java:748)> Task :app:transformClassesWithDexBuilderForDebug> Task :app:validateSigningDebug UP-TO-DATE> Task :app:signingConfigWriterDebug> Task :app:mergeDebugJavaResource> Task :app:mergeExtDexDebug FAILEDFAILURE: Build failed with an exception.* What went wrong:Execution failed for task ':app:mergeExtDexDebug'.> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade> java.nio.file.NoSuchFileException: C:\Users\Faded\Desktop\Development\React Native\FitnessApp\FitnessApp\android\app\build\intermediates\external_file_lib_dex_archives\debug\out* 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.0.1/userguide/command_line_interface.html#sec:command_line_warningsBUILD FAILED in 19s150 actionable tasks: 147 executed, 3 up-to-date

Making a VPN client using nativescript

$
0
0

I'm new to NativeScript and i want to build a VPN client app for android and IOS. I've tried searching online for some guides on how to do it but i'm not able to find one yet. how can i do it ?

Screen Recording with Audio in React Native or Flutter

$
0
0

I am new to React Native and flutter, Is there any module available or any tutorial from where I could learn and build the Screen recording with audio for both iOS and Android.

TypeError: undefined is not an object gotten when using navigation.openDrawer()

$
0
0

On trying to open my sidedrawer component using navigation.openDrawer(), I get this error.I have tried nesting the drawer component within the NavigationCOntainer which didn't workthe expected behavior is for the sidedrawer to slide in on clicking the icon

HomeStack.js

import 'react-native-gesture-handler';import React from 'react';import {NavigationContainer} from '@react-navigation/native';import {createStackNavigator} from '@react-navigation/stack';import Login from '../login/login';import Register from '../register/register';import Welcome from '../welcome/welcome';import ResetPWD from '../register/resetpwd';import RegisterLogin from '../register/registerlogin';import About from '../screens/about';import More from '../screens/more';import Gallery from '../screens/gallery';import Excos from '../screens/excos';import AbuladWebsite from '../screens/abuladwebsite';import LifeInAbu from '../screens/lifeinabu';import {Icon} from 'react-native-elements';// import SideStack from '../routes/sideStack';import {createDrawerNavigator} from '@react-navigation/drawer';const Stack = createStackNavigator();const Drawer = createDrawerNavigator();function sideDrawer({navigation}) {  return (<Drawer.Navigator><Drawer.Screen name="Gallery" component={Gallery} /><Drawer.Screen name="Life in ABU" component={LifeInAbu} /><Drawer.Screen name="Buy and Sell" component={AbuladWebsite} /><Drawer.Screen name="About" component={About} /><Drawer.Screen name="Excos" component={Excos} /><Drawer.Screen name="More" component={More} /></Drawer.Navigator>  );}function homeStack({navigation}) {  return (<NavigationContainer><Stack.Navigator><Stack.Screen          name="Login"          component={Login}          options={{headerShown: false}}        /><Stack.Screen          name="Register"          component={Register}          options={{headerShown: false}}        /><Stack.Screen          name="ResetPWD"          component={ResetPWD}          options={{headerShown: false}}        /><Stack.Screen          name="RegisterLogin"          component={RegisterLogin}          options={{headerShown: false}}        /><Stack.Screen name="sideStack" component={sideDrawer} /><Stack.Screen          name="Welcome"          component={Welcome}          options={{            title: 'Abulad',            headerLeft: () => (<Icon                name="android"                onPress={() => navigation.openDrawer()}                // title="Info"                color="#000"              />            ),          }}        /></Stack.Navigator></NavigationContainer>  );}export default homeStack;

App.js

import React, {Component} from 'react';import SplashScreen from 'react-native-splash-screen';import HomeStack from './src/components/routes/homeStack';import SideStack from './src/components/routes/sideStack';class App extends Component {  componentDidMount() {    SplashScreen.hide();  }  render() {    return <HomeStack />;  }}export default App;

error image

React Native video not showing without error

$
0
0

I created React Native project which has a video and player. I run the program with 'yarn android' and emulator runs program without any error. Video has started but it is not displaying, only sound is heard. What should I do? version "react-native": "0.62.2",

Screenshot from the emulator(Pixel 3 XL)

What is the right mobile framework for a dating app?

$
0
0

I am in the early stages of building a Tinder-like dating app, what will have a certain edge that is not related to this question. I am thinking about using Firestore/Firebase as the backend, and I am trying to decide if the app needs to be coded in native for IOS and Android, or if I can have is coded in React Native.

Every discussion I read, has a first comment saying “that depends on the budget and on the app”, so let’s start there. I CAN afford to have it made in two native versions – if it is needed. The question is, IF it is needed. The Tinder app is coded in two native versions, but I am having a hard time understanding exactly what I would “lose” by using React Native.

Would it look and feel the same? The main features of the app is setting up a profile, setting up a gallery, swiping yes or no on profiles and being able to chat with matches. That is the app in a nutshell. I read that things like push messages are not an option in React Native, but is push messages all I am “giving up” in this if I choose React Native? Or is there something more?

How to instantiate React Native Java class without MainApplication

This app contains a virus. Please uninstall this app immediately

$
0
0

We received a serious customer feedback. The customer says he's getting the error on the screenshot as soon as he installs our app from the google play store. In all our test cases we didn't received this error once. So I'm really out of ideas, there are no special applications on this device and it's a very new Android Device, so said the problem was not replicable.

Special about the app is that it is build with react-native but actually I really don't believe this should be a problem.

Has anyone ever seen a screen like this or has a hint why this could happen? I'm happy with every point to think about.

enter image description here


React Native: How to open OS settings in Android and iOS?

$
0
0

I am developing a mobile application using React Native in which I want to open mobile device's settings when user clicks on a specific button.

I have gone through the docs of RN, but still couldn’t find anything that can help me in achieving the same. Can someone guide me on the same, how can that be implemented?

Thanks :)

react-native-google-places-autocomplete not working on React native 0.61

$
0
0

I have added react-native-google-places-autocomplete with yarn in my react-native cli project but it is not working. Here are the issues I am facing at the moment.

  1. the places drop down is not showing up on IOS, however the input text field allows me to enter a place name but the predictions list does not appear

  2. onPress handler is not triggered at all on both IOS and android

  3. The Text Input coming from react-native-google-places-autocomplete does not allow me to enter anything on ANDROID. It is like disabled all the time ( although the focus is set to true)

Note: all google location apis are enabled , google maps api, places api and geocode api are enabled and a valid api key is given.

I tried all possible solutions available including the following:

  1. setting zIndex: 1000 a high value to avoid it being hidden behind some other view

  2. Tried creating new RN App and added only this component to keep the project clean

  3. Regenerating the API and even using another api which works with previous versions of REACT NATIVE.

The logs don't show anything on both Xcode and Android Studio. Here is the code snippet:

<View style = {[{zIndex: 2, backgroundColor: 'white'}]}><GooglePlacesAutocomplete                    ref = {ref => setSearchTextRef(ref)}                    placeholder='Search for gym'                    styles={{                        container: {backgroundColor: 'transparent'},                        textInputContainer: styles.viewStyle,                        textInput: styles.textInputStyle,                    }}                    keyboardShouldPersistTaps = {'handled'}                    listUnderlayColor = {'transparent'}                    textInputProps = {{                        onFocus: () => focusInput(),                        onBlur: () => blurInput(),                        onChangeText: (text) => onChange(text)                    }}                    minLength={1} // minimum length of text to search                    returnKeyType={'search'}                    listViewDisplayed={'auto'}   // true/false/undefined                    fetchDetails={true}                    renderDescription={row => row.description} // custom description render                    onPress={(data, details = null) => {                        let coordinates = details.geometry.location;                        sendCoordinates(coordinates, {data, details});                    }}                    getDefaultValue={() => ''}                    query={{                        key: googleAPIKey,                        language: 'en', // language of the results                        // types: '(cities)' // default: 'geocode'                    }}                    nearbyPlacesAPI='GooglePlacesSearch' // Which API to use: GoogleReverseGeocoding or GooglePlacesSearch                    GooglePlacesSearchQuery={{                        rankby: 'distance',                        types: 'gym'                    }}                    filterReverseGeocodingByTypes={['locality', 'administrative_area_level_3']}                     debounce={200}                /></View>

Thank you in advance

TouchableOpacity Not Working In Absolute View Android React Native

$
0
0

I've tried to fix this issue for the past 2 hours and I can't seem to get it to work. I've gone ahead and made a custom keyboard in React Native and it works perfectly on my iOS. However, on Android I can't seem to be able to press the TouchableOpacity. Everything I press, goes through the keyboard.

I've tried replacing TouchableOpacity with TouchableNativeFeedback and that gives it at least a ripple effect. However, the OnPress code never gets executed. I tried to nest my component within a <View> but didn't work either. No idea on how to solve this. This is my code:

const styles = StyleSheet.create({  keyboardContainer: {    position: "absolute",    bottom: 0,    zIndex: 1000,    height: width * 0.8,    width: width,    backgroundColor: "rgb(1,80,185)",    flexDirection: "row",    flexWrap: "wrap",    shadowColor: "#000",    shadowOffset: {      width: 0,      height: 7,    },    shadowOpacity: 0.43,    shadowRadius: 9.51,    elevation: 1000,  },  buttonNum: {    borderColor: "white",    width: width * 0.25,    height: width * 0.2,    justifyContent: "center",    alignItems: "center",  },  numText: {    fontSize: 25,    color: "white",  },});class Keyboard extends Component {  static contextType = KeyboardContext;  render() {    if (this.context.keyboard)      return (<View style={styles.keyboardContainer}><TouchableOpacity            style={styles.buttonNum}            onPress={() => this.context.handleText("1")}><Text style={styles.numText}>1</Text></TouchableOpacity><TouchableOpacity            style={styles.buttonNum}            onPress={() => this.context.handleText("2")}><Text style={styles.numText}>2</Text></TouchableOpacity><TouchableOpacity            style={styles.buttonNum}            onPress={() => this.context.handleText("3")}><Text style={styles.numText}>3</Text></TouchableOpacity><TouchableOpacity            style={styles.buttonNum}            onPress={() => this.context.setContext({ keyboard: false })}><Icon name="keyboard-close" style={styles.numText} /></TouchableOpacity><TouchableOpacity            style={styles.buttonNum}            onPress={() => this.context.handleText("4")}><Text style={styles.numText}>4</Text></TouchableOpacity><TouchableOpacity            style={styles.buttonNum}            onPress={() => this.context.handleText("5")}><Text style={styles.numText}>5</Text></TouchableOpacity><TouchableOpacity            style={styles.buttonNum}            onPress={() => this.context.handleText("6")}><Text style={styles.numText}>6</Text></TouchableOpacity><TouchableOpacity style={styles.buttonNum} onPress={this.removeText}><Icon name="plus-circle" style={styles.numText} /></TouchableOpacity><TouchableOpacity            style={styles.buttonNum}            onPress={() => this.context.handleText("7")}><Text style={styles.numText}>7</Text></TouchableOpacity><TouchableOpacity            style={styles.buttonNum}            onPress={() => this.context.handleText("8")}><Text style={styles.numText}>8</Text></TouchableOpacity><TouchableOpacity            style={styles.buttonNum}            onPress={() => this.context.handleText("9")}><Text style={styles.numText}>9</Text></TouchableOpacity><TouchableOpacity            style={styles.buttonNum}            onPress={() => this.context.handleText("-")}><Icon name="minus-circle" style={styles.numText} /></TouchableOpacity><TouchableOpacity            style={styles.buttonNum}            onPress={() => this.context.handleText(".")}><Text style={styles.numText}>.</Text></TouchableOpacity><TouchableOpacity            style={styles.buttonNum}            onPress={() => this.context.handleText("0")}><Text style={styles.numText}>0</Text></TouchableOpacity><TouchableOpacity            style={styles.buttonNum}            onPress={this.context.removeText}><Feather name="delete" style={styles.numText} /></TouchableOpacity><TouchableOpacity            style={styles.buttonNum}            onPress={this.context.clearText}><Text style={[styles.numText, { fontSize: 18 }]}>CLEAR</Text></TouchableOpacity></View>      );    return null;  }}

react-native run-android not working. Could not initialize class org.codehaus.groovy.runtime.InvokerHelper

$
0
0

I am trying to run react-native with the CLI method.I also got the react-native-vector-icons and linked it to react native as following this tutorial from traversy media - https://www.youtube.com/watch?v=Hf4MJH0jDb4&t=933s.I had android studio installed and also Gradle all updated to the latest version.

Java Versionjava 14.0.1 2020-04-14Java(TM) SE Runtime Environment (build 14.0.1+7)Java HotSpot(TM) 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing)

What cmd says the problem is.

* What went wrong:Could not initialize class org.codehaus.groovy.runtime.InvokerHelper* 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

This is what I am getting in my cmd. What is the problem? This is my entire console when I run the command to start with the above included.

C:\Users\Devesh\ShoppingList>react-native run-androidinfo Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.Jetifier found 967 file(s) to forward-jetify. Using 4 workers...info Starting JS server...info Installing the app...FAILURE: Build failed with an exception.* What went wrong:Could not initialize class org.codehaus.groovy.runtime.InvokerHelper* 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 864mserror Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081FAILURE: Build failed with an exception.* What went wrong:Could not initialize class org.codehaus.groovy.runtime.InvokerHelper* 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 864ms    at makeError (C:\Users\Devesh\ShoppingList\node_modules\execa\index.js:174:9)    at C:\Users\Devesh\ShoppingList\node_modules\execa\index.js:278:16    at processTicksAndRejections (internal/process/task_queues.js:97:5)    at async runOnAllDevices (C:\Users\Devesh\ShoppingList\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:5)    at async Command.handleAction (C:\Users\Devesh\ShoppingList\node_modules\react-native\node_modules\@react-native-community\cli\build\index.js:186:9)

React-native android back button in react-navigation

$
0
0

Well, I have a react-native app with multiple screen, each screen having a top bar where a back button is situated, it's main behavior is that the app returns to the main screen when this button is pressed. What I want to do is to copy this behavior to the hardware back button (now by pressing on hardware back button the app closes), how can I do this?

UPDATE:

I'm using react-navigation and redux

Viewing all 28476 articles
Browse latest View live


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