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

react-navite-change-icon Android having duplicate app icons on my phone

$
0
0

I am currently using the react-native-change-icon package to change my application icon from within my app programmatically. It works perfectly on iOS but not that well on android... On first install my app only has one icon, which is from the tag in my manifest below. But when I change my icon through the changeIcon function provided by the react-native-change-icon package, my phone will have one icon from the tag and the other icon is from one of the two tags in my manifest. Thus, having two icons but both lead to the same app.

Below is my manifest file:-

<application        android:name="com.testing_rn.MainApplication"        android:allowBackup="false"        android:icon="@mipmap/ic_launcher"        android:label="@string/app_name"        android:networkSecurityConfig="@xml/network_security_config"        android:roundIcon="@mipmap/ic_launcher_round"        android:theme="@style/AppTheme"><activity            android:name="com.testing_rn.SplashActivity"            android:label="@string/app_name"            android:launchMode="singleTask"            android:theme="@style/SplashTheme"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity><activity            android:name="com.testing_rn.MainActivity"            android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"            android:exported="true"            android:label="@string/app_name"            android:launchMode="singleTask"            android:windowSoftInputMode="adjustPan"></activity><activity-alias        android:name="com.testing_rn.MainActivityori"        android:enabled="false"        android:icon="@mipmap/ori"        android:targetActivity=".MainActivity"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity-alias><activity-alias        android:name="com.testing_rn.MainActivityprivateicon"        android:enabled="false"        android:icon="@mipmap/privateicon"        android:targetActivity=".MainActivity"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity-alias><activity android:name="com.facebook.react.devsupport.DevSettingsActivity" /></application>

Did I set something wrong in my manifest? When I use the changeIcon method on android, my app closes and crashes, is that the expected behavior on Android? Whereas on iOS, when I use the changeIcon method, it just pops out an alert that says I successfully changed the icon without crashing or closing the app.


React Native force close when running on emulator and android device

$
0
0

I am new to react native, first I create a new RN project using "npx react-native init MyTestApp" then start with "npx react-native start" and run it with "npx react-native run-android", the build is successful and the application is installed but the application immediately closes forcefully, I've tried it on the emulator (android 7.0 API 24) and android (Android 4.4.2) but the results are the same...

Start RNRun AndroidApp Force Close on emulator

Someone please help me

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.

How to solve "config.h file not found"? when running app from the react native on the device?

Force close non responding Android Studio Emulator

$
0
0

How do I force shut down an Android Studio emulator after it stops responding?I tried to end task from task manager but nothing happensI even tried to kill the running process from PowerShell and still it doesn't stop.Can someone please help?

Getting error while using react native component on Android 4.4.2 and 4.2.2

$
0
0

While trying to init the react native component in Android app getting this error on Android os version 4.4.2 and 4.2.2.

Fatal Exception: java.lang.VerifyError: com/facebook/soloader/g at com.facebook.soloader.SoLoader.initImpl$1a54e370(SoLoader.java:189) at com.facebook.soloader.SoLoader.init(SoLoader.java:1105) at com.facebook.react.ReactInstanceManager.initializeSoLoaderIfNecessary(ReactInstanceManager.java:1358) at com.facebook.react.ReactInstanceManagerBuilder.build(ReactInstanceManagerBuilder.java:227)

React native webview loses injected data on state change

$
0
0

Is there any way to keep injected javascript data in the webview when there are state changes?

I use the injectJavascript prop to enter data into a web view. The data is entered as expected but when the react native state changes the data is lost which probably means the webview is reloaded. Is there any way to keep this data after state changes?

Verified on android device

How to embed a Flutter ui view into a React Native app?

$
0
0

We are merging some flutter and react native components. Thus, in the React Native app, we need to embed some Flutter views.

Thanks for any ideas and suggestions!

P.S. My naive thoughts: Flutter can be embedded into native Android/iOS apps. At the same time, React Native allow rendering a native component. Thus, I can make Flutter a native Android/iOS component, and then let RN render it. But I do not know whether this will have a huge overhead, or any traps that I have not considered?


Execution failed for task ':app:packageDebug' on react native cli run android

$
0
0
Execution failed for task ':app:packageDebug'.> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade> java.io.IOException: Failed to read zip file 'C:\Users\PC\stuff\Project\android\app\build\outputs\apk\debug\..\..\..\..\..\release\APP-1.0.8.apk'.

For some reason I am randomly getting this error when trying to run my react native app on android via the react native CLI (react-native run-android). What is weird is this happened randomly, everything was working fine, and I made no changes, this just randomly started happening today. I had it running on my emulator, killed my metro server for a second, went to start everything back up via the command and started getting this error. I tried a few things such as deleting the build folder, running gradlew clean, and pretty much every other thing I could find online for this issue and nothing seems to work.

C:\Users\PC\stuff\Project\android\app\build\outputs\apk\debug\..\..\..\..\..\release\APP-1.0.8.apk

This path does not exist after apk\debug so I am pretty sure it has to do with that but I have no idea how to fix it. And the fact this happened randomly without me making any changes after everything working perfect has me even more confused lol. Has anyone ran into this that may know how to solve it? After a few hours of messing with it and trying everything possible that was online already I am stumped.

How to awake phone screen when app is in background and screen is locked in react native?

$
0
0

I'm making an application, Let's see what i want to do actually. I executed my code using react-native run-android and my home screen is active now. Then i went to the background and locked my phone using lock key of the mobile phone. then i'm sending notification to the app, the notification is being showing in the phone but the screen is still locked, home screen is still inactive. I want to awake my phone on receiving notification and i have used react-native-firebase for push notification.

Thank You.

I had tried to make it using react-native-keep-awake.

On receiving the notification, My code is KeepAwake.activate() but its not awaking my screen.

How to display GIF in react-native android app?

$
0
0

I want to display a simple gif via URL in my Image tag in my android react-native app but when I start it no image is shown.The code as provided in the docs does work only for iOS but not for android:

<Image  style={styles.gif}  source={{uri: 'http://38.media.tumblr.com/9e9bd08c6e2d10561dd1fb4197df4c4e/tumblr_mfqekpMktw1rn90umo1_500.gif'}}/>

There was a similar question here but as already said this only works for iOS:How do I display an animated gif in React Native?
Regarding this commit it should work though:https://github.com/facebook/react-native/commit/fcd7de5301655b39832d49908e5ca72ddaf91f7e

Offset problem on Android keyboard with expo 37

$
0
0

PROBLEM

I am currently on react native (Expo) and when I updated my app from expo 35 to expo 37, I started to have padding or margin problems on my application (only on Android).These problems appear at the level of the keyboard, which creates an offset when it is opened.And a permanent separation that forms when a dropdown is activated. (The GIF (link) show you the offsets in neon green).

CODE

<KeyboardAvoidingView style={{ width:'100%', height:'100%' }} behavior={'padding'} keyboardVerticalOffset={40}><View style={{ width:'100%', height:'100%' }}><GiftedChat/></View></KeyboardAvoidingView>

SOLUTIONS (Not working)

(I have tried SOOOOO MANY solutions in internet :

  • eject expo and change the android:windowSoftInputMode="adjustResize"

  • Tried so many things inside the style code Add

    The method with react-navigation --> tabBarOptions : { ... keyboardHidesTabBar: true}

VERSIONS

React Native: Emulator stuck on "loading from localhost:8081.."

$
0
0

Screenshot from Android phone running the app

I am working on a react-native project and I run it on my android phone via USB debugging and the command "react-native run android".

It was working all fine but now even though the build is successful, the app gets stuck on the white screen "loading from localhost:8081". No changes were made in any of the app files.

I tried running the react-native demo app (using react-native init) and I still face the same issue.

Solutions I tried but still same issue:

  1. rm -rf node_modules && npm install
  2. adb reverse tcp:8081 tcp:8081
  3. Running it on Android Emulator from Android Studio.
  4. Using the command npm run android

This is what shows up in the command line:

lenovo@lenovo-Lenovo-ideapad-500S-14ISK:~/IRMSold$ react-native run-android Scanning folders for symlinks in /home/lenovo/IRMSold/node_modules (6ms) JS server already running. Building and installing the app on the device (cd android && ./gradlew installDebug)...

Configure project :app WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'. It will be removed at the end of 2018. For more information see:http://d.android.com/r/tools/update-dependency-configurations.html

Configure project :react-native-google-signin WARNING: Configuration'compile' is obsolete and has been replaced with 'implementation' and'api'. It will be removed at the end of 2018. For more information see:http://d.android.com/r/tools/update-dependency-configurations.html WARNING: The specified Android SDK Build Tools version (23.0.3) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.1. Android SDK Build Tools 27.0.3 will be used. To suppress this warning, remove "buildToolsVersion '23.0.3'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

Configure project :react-native-vector-icons WARNING: Configuration'compile' is obsolete and has been replaced with 'implementation' and'api'. It will be removed at the end of 2018. For more information see:http://d.android.com/r/tools/update-dependency-configurations.html WARNING: The specified Android SDK Build Tools version (26.0.1) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.1. Android SDK Build Tools 27.0.3 will be used. To suppress this warning, remove "buildToolsVersion '26.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

Task :app:installDebug Installing APK 'app-debug.apk' on 'Lenovo X3a40 - 6.0.1' for app:debug Installed on 1 device.

BUILD SUCCESSFUL in 13s 66 actionable tasks: 1 executed, 65 up-to-date Running adb -s 567bf688 reverse tcp:8081 tcp:8081 Starting the app on 567bf688 (adb -s 567bf688 shell am start -n com.irms/com.irms.MainActivity)... Starting: Intent { cmp=com.irms/.MainActivity }

Kindly help me out, as I tried every other fix I could find online.

React-native-maps Polygon fillColor not working on android

Problem: Why react native video does not play video in full screen?

$
0
0

I am creating an application for android and ios in react-native(0.57.7) and using react-native-video to play videos uploaded into vimeo. After integrate react video plugin, tested in both device. In ios it works perfectly but in android, I am not able to play video in full-screen mode. Here is my code for Android:

import React, { PureComponent } from 'react';import {    View,    Text,    Image,    ImageBackground,    StyleSheet,    SafeAreaView,    TouchableOpacity,    ActivityIndicator} from 'react-native';import PropTypes from 'prop-types'import Video from "react-native-video";import Orientation from 'react-native-orientation-locker';import { widthPercentageToDP as wp, heightPercentageToDP as hp } from '../components/Resposive';import RF from "react-native-responsive-fontsize"export default class Videoplayer extends PureComponent {    constructor(props){        super(props);        this.state = {            loading: true,            videoFileArr:[],            showPlayer:false,            playing:false        }    }    componentDidMount() {        Orientation.lockToLandscape();        this.fetchVimeoVideo();    }    componentWillUnmount() {        Orientation.lockToPortrait();    }    goToHome(){        Orientation.lockToPortrait();        this.props.navigation.goBack();    }    fetchVimeoVideo = async () => {        await this.setState({ loading: true });        const { navigation } = this.props;        const jsonReceived = navigation.getParam('item', {})        const url = "https://api.vimeo.com/me/videos/"+ jsonReceived.video_link        console.log(url)        const response = await fetch(            url, {                method: "get",                headers: {                    Accept: 'application/json','Content-Type': 'application/json',                    Authorization:"Bearer f9e937d64037e657addcf088f28e6cb5"                }            });        const jsonResponse = await response.json();        const { files} = jsonResponse;        if (response.status != 200) {            alert(response.status)        }        console.log(files)        await this.setState({ videoFileArr:files, loading: false });    };    renderOptions = () => {        if (this.state.loading === true) {            return (<View style={{                    flex: 1,                    alignItems: "center",                    justifyContent: "center"                }}><ActivityIndicator size="large" color="#00ff00" /><Text style={{ fontFamily: "Futura Std", fontSize: RF(3.0), fontWeight: "900", color: "#244E25", textAlign: "center" }}>Please wait while we are loading questions for you</Text></View>            )        }else if (this.state.videoFileArr.length> 0 && this.state.playing === false) {            const { navigation } = this.props;            const jsonReceived = navigation.getParam('item', {})            return(<ImageBackground style={{width:"100%",height:"100%",alignItems:"center",justifyContent:"center"}}  source={{uri:jsonReceived.video_banner}}> <TouchableOpacity                        onPress={() => {                            this.setState({playing:true})                        }}><Image source={require("../assets/Common/Play/playIcon.png")}/></TouchableOpacity></ImageBackground>            )        } else if (this.state.videoFileArr.length > 0 && this.state.playing === true) {            return (<View style={styles.container}><Video source={{ uri:this.state.videoFileArr[0].link}}   // Can be a URL or a local file.                        ref={ ref =>                             this.player = ref                        }                                      // Store reference                        onBuffer={this.onBuffer}                // Callback when remote video is buffering                        onError={this.videoError}               // Callback when video cannot be loaded                        style={styles.backgroundVideo}                        controls={true}                        paused={false}                        fullscreen={true}                    /></View>            )        }    }    render() {        return (<SafeAreaView style={{ flex: 1 }}><View style={{ flex: 1, overflow: "hidden" }}><View style={{ flex: 1, backgroundColor: "green" }}>                        {this.renderOptions()}</View>                    {/* top navigationBar */}<View                        style={{                            position: "absolute",                            top: 0,                            left: 0,                            right: 0,                            width: "100%",                            flexDirection: "row",                            justifyContent: "space-between",                            alignItems: "center",                            height: 80,                            backgroundColor: null                        }}><TouchableOpacity onPress={                            ()=>this.goToHome()                        }><Image style={{ margin: 8 }} source={require("../assets/Common/goBack/goBack.png")} /></TouchableOpacity><TouchableOpacity><Image style={{ margin: 8 }} source={require("../assets/Common/Star/starOff.png")} /></TouchableOpacity></View></View></SafeAreaView>        )    }}const styles = StyleSheet.create({    container:{ flex: 1, justifyContent: "center"},    backgroundVideo: {      position: 'absolute',      top: 0,      left: 0,      bottom: 0,      right: 0,    },});

and this is the output screen where I can not play video in full screen:

enter image description here

Please help, What I'm doing wrong ?


Border radius for launch app icon in react native in andoid tablet

$
0
0

I have used similar app icon image, I don't know why it is showing different results for android mobile and tablet. android

#tablet

Adb command similar to reverse?

$
0
0

I used to run adb reverse tcp:8081 tcp:8081 to connect/reconnect my devices to react native development server. but it's not supported on android 5. since adb reverse not supported on android <5x. i need it to do test app in old android versionalso i cant connect the device to react native server via wi-fi because it is an emulator

is there any similar command to do this?

React Native app avoid open in top of Chrome when sharing

$
0
0

I am using react-native-file-share-intent to receive the share intent from others app in my React Native app.


  • Here is my issue:

Let's suppose that my app is already opened in background.

If I share a web page from Chrome app, my app is opened on top of the Chrome screen. So I have a duplicate of my app.

As I am using a Camera, I wuold like to avoid that and always have a single instance of the app.

Same happens with Google Maps app.

Note: I am using android:documentLaunchMode="never" in Manifest.

Show notification on foreground react native firebase v6

$
0
0

I am using the latest react native version 0.62 and latest version of react-native-firebase i.e. v6. I am able to get the notification and it working fine on the background but its not displaying on foreground.

Here is the screenshot:enter image description here

And here is my code:

checkPermission = async () => {    const enabled = await messaging().hasPermission();    console.log('enabled ******* ',enabled)    if (enabled) {      this.getFcmToken();    } else {      this.requestPermission();    }  };  getFcmToken = async () => {    const fcmToken = await messaging().getToken();    if (fcmToken) {      console.log('Your Firebase Token is:', fcmToken);      // this.showAlert('Your Firebase Token is:', fcmToken);    } else {      console.log('Failed', 'No token received');    }  };  requestPermission = async () => {    try {      await messaging().requestPermission();      // User has authorised    } catch (error) {      // User has rejected permissions    }  };  messageListener = async () => {    console.log('inside message listener ****** ')    messaging().onMessage(async remoteMessage => {      Alert.alert('A new FCM message arrived!', JSON.stringify(remoteMessage));  };  showAlert = (title, message) => {    Alert.alert(      title,      message,      [{ text: 'OK', onPress: () => console.log('OK Pressed') }],      { cancelable: false },    );  };  componentDidMount() {    this.checkPermission();    this.messageListener();  }

How focus the next field input in react native?

$
0
0

I need focus the next field input in react native, in android platform.But the focus() function, not exists in android react native, only in IOS.

How make this ? I use react native with typescript.

enter image description here

Viewing all 28460 articles
Browse latest View live


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