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

ReactNative Expo app wrongly listed details in Play Console

$
0
0

I've uploaded a React Native app built in via Expo. I've set permissions to none:

{"expo": {"android": {"permissions": []      ... other settings    }    ... other settings}

And I've set it to portrait mode only:

{"expo": {"orientation": "portrait",    ... other settings  }}

But when I upload the app-bundle to the PLayConsole it lists the app with 15 permissions:

android.permission.ACCESS_NETWORK_STATE android.permission.ACCESS_WIFI_STATE android.permission.FOREGROUND_SERVICE android.permission.INTERNET android.permission.MODIFY_AUDIO_SETTINGS android.permission.RECEIVE_BOOT_COMPLETED android.permission.REQUEST_INSTALL_PACKAGES android.permission.STORAGE android.permission.SYSTEM_ALERT_WINDOW android.permission.USE_BIOMETRIC android.permission.WAKE_LOCK com.google.android.c2dm.permission.RECEIVE com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE com.sja.firstaid.permission.C2D_MESSAGE host.exp.exponent.permission.C2D_MESSAGE

and both orientations under features:

2 features: android.hardware.screen.landscape, android.hardware.screen.portrait

I cannot identify a reason for either of these settings to be ignored.


Why is my react navigation not working on android?

$
0
0

Recently I merged some changes from a colleague and these changes have React Native Navigation setup in it. After installing all the dependencies and setting up everything, When I run the app, I get this error that says

com.app.MainActivity cannot be cast to com.reactnativenavigation.NavigationActivity

Apparently, the error is coming from the following file

react-native-navigation\lib\android\app\src\main\java\com\reactnativenavigation\react\NavigationModule.java

How to reproduce

I am not really sure how to reproduce this error because I don't know what's causing it in the first place. However, the only other unexpected behavior was that my Android Studio or react-native run-android both were failing gradle build when I first added all the required dependencies. The reason for failure was kotlin-android and even though I can confirm that from the build.gradle files of the repository that the required settings exist, still I had to add the relevant required config to my main applications android/gradle.build and android/app/gradle.buildApparently this solved the issue with now react-native run-android running successful gradle build.

The repository has the following dependencies config

classpath 'com.android.tools.build:gradle:3.5.3'classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61"

Despite the presence of above, my gradle builds were failing and complaining about android-kotlin so I added the following dependencies config to my app's android/gradle.build

classpath('com.android.tools.build:gradle:3.6.2')classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72"

Notice the difference in versions of the gradle (This gradle version came by default with RN 0.62) and kotlin-gradle-plugin. I don't know, but could this be the cause of the issue?

enter image description here

The error seems to be coming from here

I am using latest version 5.5.1 for @react-navigation/native

AVD Manager unable to locate adb on mac

$
0
0

I've been struggling for couple of hours, looking for some possible ways online, to get my RN apps run. When I try to run

react-native run-android

in my project, it suppose to automatically launch the simulator device (I've install it in avd manager), but it return:

error Failed to launch emulator. Reason: Emulator exited before boot..

Then, I try to start the simulator manually from avd manager. But, this is what I got when manually start the simulator:

screenshot

As displayed above, appear warning from avd manager that said unable to locate adb, but, idk why the simulator still opened.

But, when I try to check the adb in the terminal (by adb --version), it return:

username@MacBook-Pro android % adb --versionAndroid Debug Bridge version 1.0.41Version 30.0.2-6538114Installed as /Users/username/Library/Android/sdk/platform-tools/adb

So, the adb is found. FYI, here is the java version that I use

username@MacBook-Pro ~ % java -versionopenjdk version "11.0.2" 2019-01-15OpenJDK Runtime Environment 18.9 (build 11.0.2+9)OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)

How to solve this issue?

Custom dropdown header React Native for android

$
0
0

I have a custom dorpdown header component that works as intended on ios devices, however on android when the header has been expanded and I try to click on any of it contents the click event takes place on the content from the page behind the expanded header. I have added pointerEvents attribute to the views that wrap the header and the content from the page which has stopped this content from being clickable when the header is expanded, however, I am now unable to click on the contents within the expanded header.

This is my implementation so far

          this.props.context.screenDimensions.height <          this.props.context.screenDimensions.width && (<View pointerEvents="auto"><HeaderBar {...this.props } /></View>          )}<View style={{ marginTop }} pointerEvents={this.props.context.isHeaderExpanded ? 'none' : 'box-none'}>{this.props.children}</View>```

RTL is forced in RTL devices

How to create local notification in react native and android

$
0
0

I am trying to create a local notification in android using react-native. My application is completely local, so I don't want to use GCM or FCM. I saw this question

where it is done using java. Is there wrapper or a library in react native to achieve the same?

I also saw PushNotificationIOS API, will it work with android?

ReferenceError: Can't find variable: document when importing loadStripe from '@stripe.stripe-js'

$
0
0

While developing an app in React Native intgerating with Stripe, I keep getting a warning [ReferenceError: Can't find variable: document].

I can't get the cause for the error.

The only possiblity I can think is if the Stripe module is only built for react js and is looking for the HTML document to reference.

I am fairly certain it is this line which is causing the warning.

import {loadStripe} from '@stripe/stripe-js';

When it is included the warning shows up. I read the documentation but there's nothing I could find.

If anyone could point me in the right direction for what might be causing the problem or if stripe will work on react native as a cross platform app, please let me know.

reducing Apk size in react native android

$
0
0

Currently my app size is 17 MB. But only 2 main screens. Each screen contains 3 child screens. So totally 6 screens.

My package.json :"dependencies": {"@react-native-community/async-storage": "^1.11.0","@react-native-firebase/app": "^7.2.0","@react-native-firebase/auth": "^8.0.4","@react-native-firebase/firestore": "^7.1.5","@react-navigation/native": "^5.5.0","@react-navigation/stack": "^5.4.1","firebase": "^7.15.0","react": "16.11.0","react-native": "0.62.2","react-native-animatable": "^1.3.3","react-native-asyncstorage": "^1.0.0","react-native-dropdown-picker": "^3.0.0","react-native-floating-action": "^1.20.0","react-native-keyboard-done-button": "^1.0.0","react-native-linear-gradient": "^2.5.6","react-native-loading-spinner-overlay": "^1.1.0","react-native-numeric-input": "^1.8.3","react-native-safe-area-context": "^3.0.2","react-native-screens": "^2.8.0","react-native-scrollable-tab-view": "^1.0.0","react-native-tag-input": "0.0.21","react-native-vector-icons": "^6.6.0","react-navigation": "^4.3.9","react-navigation-stack": "^2.7.0"  }

My react native version : "version": "0.62.2"

I set these two to true :

def enableSeparateBuildPerCPUArchitecture = truedef enableProguardInReleaseBuilds = true

When i was checking the app analyzer using android studio. i got this :Here

I am not sure what is libjsc.so, libflipper.sp and why its consuming this much memory. I am new to this and this is my first application. Any help would be great.

Also i am wondering because of react-native-scrollable-tab-view (top tab view), react-native-vector-icons, react-native-tag-input (just some tag input lib) my app size got increased ?

Thanks


How to capture microphone audio on React Native and stream it to IceCast endpoint?

$
0
0

I'm working on a React Native mobile radio application (testing on Android API 28 as target and 26 as check, both emulator and physical device), and the idea is to enable the radio channel host to talk into the phone microphone and have that audio overlayed on the radio music.

I'm using IceCast 2 and Liquidsoap to (successfully) stream music to the listeners, and mix in a microphone stream (liquidsoap input.harbor, at URL:PORT/ICECAST_ENDPOINT) which I am currently able to stream microphone to using butt.

Now my question is how to capture mic input from the mobile device and then stream it to the same URL endpoint from the React Native app?

I've tried using react-native-microphone-stream, but the listener lambda is never called:

import React, { useState, useEffect } from 'react';import { View, StyleSheet, TouchableOpacity, Text } from 'react-native';import Icon from 'react-native-vector-icons/MaterialCommunityIcons';import MicStream from 'react-native-microphone-stream';/** * STYLING */const styles = StyleSheet.create({  container: {    flex: 0.1,    height: 5,    width: '100%',    flexDirection: 'row',    justifyContent: 'space-around',    alignItems: 'center',    paddingVertical: 4,    paddingHorizontal: 16,    backgroundColor: 'black',    paddingHorizontal: 32,  },  autoFadeButton: {    color: 'white',    textAlignVertical: 'center',    alignSelf: 'center',  },  microphoneButton: {    flexDirection: 'row',    color: '#B52C55',  },});/** * Navigational function for choosing the channel and searching for new channels */export default function ActionBar() {  const [auto, setAuto] = useState(false);  const [recording, setRecording] = useState(false);  const listener = MicStream.addListener((data) => console.log('data', data)); // This never occurs  MicStream.init({    bufferSize: 4096,    sampleRate: 44100,    bitsPerChannel: 16,    channelsPerFrame: 1,  });  function toggleRecord() {    if (recording) {      console.log('starting mic');      MicStream.start();    } else {      console.log('stopping mic');      MicStream.stop();    }  }  useEffect(() => {    return () => listener.remove();  }, []);  useEffect(() => {    toggleRecord();  }, [recording]);  return (<View style={styles.container}><TouchableOpacity onPress={() => setAuto(!auto)}><Text style={styles.autoFadeButton}>Auto.</Text></TouchableOpacity><TouchableOpacity        style={styles.microphoneButtonBroadcasting}        onPress={() => setRecording(!recording)}><Icon          name="microphone-outline"          size={40}          color={recording ? '#B52C55' : 'grey'}        /></TouchableOpacity><TouchableOpacity><Icon          style={[{ transform: [{ scaleX: 2 }, { scaleY: 0.8 }] }]}          name="chevron-down"          size={40}          color="white"        /></TouchableOpacity></View>  );}

React Native Fetch API Call Not Working on Android

$
0
0

My Fetch API Calls in React Native App works in iOS but not working in android.

return fetch(`${API_URL}/get/${API_KEY}?p=${PASSWORD}`, {        method: 'GET',        headers: {            Accept: 'application/json',        },    }).then(res => res.json())        .catch(error => {            console.log(error)        })

I get this error in android "SyntaxError: JSON Parse error: Unrecognized token '<'"

I understand that my response is not correct to parse it to json right?

But in iOS it can be parsed to json why not in android?

What i already tried:

I changed my host http from https updated with ssl

xmlns:tools="http://schemas.android.com/tools"> android:usesCleartextTraffic="true" tools:targetApi="28" /> I add this line of code into my Manifest

I set my php server header like header('Content-Type: application/json; charset=UTF-8');

I tried my own device not in emulator, but still getting the same error.

Thanks for help.

React native android not compiling with react-native-device-info

$
0
0

I'm getting the following error when I try to build the project using $ react-native run-android.

> Task :react-native-device-info:compileDebugJavaWithJavac FAILED/Users/user/Desktop/mobile/node_modules/react-native-device-info/android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java:31: error: package android.support.annotation does not existimport android.support.annotation.Nullable;                                 ^/Users/user/Desktop/mobile/node_modules/react-native-device-info/android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java:838: error: cannot find symbol                         @Nullable Object data) {                          ^  symbol:   class Nullable  location: class RNDeviceModuleNote: /Users/ammiel/Desktop/mobile/node_modules/react-native-device-info/android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java uses or overrides a deprecated API.Note: Recompile with -Xlint:deprecation for details.2 errorsFAILURE: Build failed with an exception.
FAILURE: Build failed with an exception.* What went wrong:Execution failed for task ':react-native-device-info:compileReleaseJavaWithJavac'.> Compilation failed; see the compiler error output for details.

I have jetify running postinstall and have

android.useAndroidX=trueandroid.enableJetifier=true

in my gradle.properties.

Been lurking at many pages/github pages with no success :/ Any help is appreciated!

Other info:

react-native: 0.59.10

react-native-device-info: 5.6.1

React Native DPad "select" button press recognized 3 times instead of once

$
0
0

I am having an issue where when you press the "select" button on the dpad it is recognized 3 times instead of once and haven't been able to figure out why or how to fix this.

Here is the console's output everytime I press an icon within the app once using dpad:

[Tue Jun 16 2020 19:42:37.491]  LOG      Pressed Search[Tue Jun 16 2020 19:42:38.426]  LOG      Pressed DropDown[Tue Jun 16 2020 19:42:41.577]  LOG      Pressed Search[Tue Jun 16 2020 19:42:41.649]  LOG      Pressed Search[Tue Jun 16 2020 19:42:41.654]  LOG      Pressed Search[Tue Jun 16 2020 19:42:42.589]  LOG      Pressed DropDown[Tue Jun 16 2020 19:42:42.668]  LOG      Pressed DropDown[Tue Jun 16 2020 19:42:42.671]  LOG      Pressed DropDown[Tue Jun 16 2020 19:42:43.926]  LOG      Pressed Search[Tue Jun 16 2020 19:42:44.390]  LOG      Pressed Search[Tue Jun 16 2020 19:42:44.550]  LOG      Pressed Search[Tue Jun 16 2020 19:50:24.580]  LOG      Pressed DropDown[Tue Jun 16 2020 19:51:21.694]  LOG      Pressed Search[Tue Jun 16 2020 19:51:21.819]  LOG      Pressed Search[Tue Jun 16 2020 19:51:21.822]  LOG      Pressed Search[Tue Jun 16 2020 19:51:23.934]  LOG      Pressed DropDown[Tue Jun 16 2020 19:51:24.320]  LOG      Pressed DropDown[Tue Jun 16 2020 19:51:24.380]  LOG      Pressed DropDown

Here is the code:

class Second extends React.Component {  render() {    return (<View><Appbar.Header><Appbar.Action            icon="menu"            onPress={() =>              this.props.navigation.dispatch(DrawerActions.toggleDrawer())            }          /><Appbar.Content style={{alignItems: 'center'}} title="" /><Appbar.Action icon="magnify" onPress={() => console.log('Pressed Search') } /><Appbar.Action icon="dots-vertical" onPress={() => console.log('Pressed DropDown') } /></Appbar.Header><Text>TV Shows</Text></View>    );  }}

React Native - Native Base Footer not change color

$
0
0

Here is the code:

 // Bottom.js<StyleProvider style={getTheme(commonColor)}><Footer><FooterTab><Button active><Icon active name="food" size={24}  /><Text active>Lunch Box</Text></Button><Button><Icon name="coins" size={24} /><Text>Point</Text></Button><Button><Icon name="face" size={24} /><Text>Profile</Text></Button></FooterTab></Footer></StyleProvider>// commonColor.js// FooterfooterHeight: 55,footerDefaultBg: '#ffffff',// FooterTabtabBarTextColor: '#FFF',tabBarTextSize: platform === 'ios' ? 14 : 16,activeTab: platform === 'ios' ? '#007aff' : '#fff',sTabBarActiveTextColor: '#007aff',tabBarActiveTextColor: '#fff',tabActiveBgColor: platform === 'ios' ? '#1569f4' : '#1569f4',

here is the result:Result

I've tried edit FooterTab.js directly but no changed at all.

The only changes that can happen on render is tabActiveBgColor: platform === 'ios' ? '#1569f4' : '#1569f4'. And I don't even know why only this code is working, I not even set any active on FooterTab.

What I expected is when I set active the button and text become white.

Any Solution?

Customize Default Splash Screen of react-native

$
0
0

Is there any way to remove the default Splash screen of react-native. Or Coustomize the Default Splash Screen. Like I want to a add a loading bar and fade effects in splash screen. And I want to create 2 splash screens for company & app. Is it possible to change the loading time?

React Native upload image to AWS Server not working for Android

$
0
0

I was having some problem when trying to upload image from React Native to AWS Server. Here is my code:

async function uploadImageAsync(uri) {  console.log(uri);  let apiUrl = '...'  let uriParts = uri.split('.');  let fileType = uri[uri.length - 1];  let formData = new FormData();  formData.append('image', {    uri,    name: `image.jpg`,    filename: `image.jpg`,  });  let options = {    method: 'POST',    body: formData,    headers: {      Accept: 'application/json','Content-Type': 'multipart/form-data',    },  };  return fetch(apiUrl, options);}

The results that printed out at the console are:

file:///data/user/0/host.exp.exponent/cache/ExperienceData/%2540gh%252Ftp2/ImagePicker/37c89140-2172-4566-98a2-e7393ea72e89.jpgObject {"uploadResponse": undefined,}Object {"uploadResult": undefined,}Object {"e": [TypeError: Network request failed],}

What I did is I pick an image from image picker, then I will upload it to AWS server. If success, print out success message. If failed, print out those in the console above.

The strange thing is, it managed to upload on iOS but not Android. Any ideas why is it so?

Thanks!


Error: react-native-permissions: NativeModule.RNPermissions is null

$
0
0

I have an issues running android but when I run it in iOS , everything seems fine. Android

react native - collapse table

$
0
0

I plan to make a collapse table. You can find it in this link

I tried:

  • Using a Custom Component for column name and FlatList for the first column
  • Using Section list for the rest column

=============================================================
| _____Custom Component_____ | __________Section list header__________ |
|============================================================|
| _________Flat List___________| __________ Section list body____________|
|============================================================|

I am able to make the list scroll together. However, if the list has 450+ rows, the performance will be reduced dramatically.

Please let me know if you have any solution.

Thank you in advanced!

React-Native run-android command issue

$
0
0

When starting android project with React-Native it is giving this error:

React-Native Command run-android unrecognized.Did you mean to run this inside a react-native project?

In specific devices my React Native App says location permissions haven't grants yet but all permissions have been granted

$
0
0

I have developed a React Native App that works with the user Location. This app is in the store and seems been working well for months.

The problem is that I have been notified that in some devices the location just doesn't work going for a code way where should go only if the location permissions are not granted. And I have checked personally these cases and I have seen that the permissions are granted in the device but the app still thinking they are not.

In some cases I have solve this with a lot of different steps like disable the permissions, reboot the device and enable them again. But there a lot of other devices that cannot be fixed using this way.

Also I have checked that the devices have access to the Location downloading another app to check the location working fine with no problems.

This problem only have been seen on Android. Do you know about a bug or something like?

Thanks for the help and excuse my poor english.

How do I reduce the size of my react native application

$
0
0

i want to know how i must detect the unused library in my project?i read that removing the unused library can reduce app release size but do not know how to find them or there is way to reduce node_modules file size?any advice that can reduce react native release size of useful for my.at last I'm using react native 0.60.5 and my app release size is 24mb

Viewing all 28476 articles
Browse latest View live


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