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

Unable to create round shape button in react native

$
0
0

I want to create round shape button for my app which is build upon react native. I had tried the code below but both of them didn't work out for me.

Code snippet 1: <Button title="+" rounded="true"/>

Code snippet 2: addButton: { width: 20, height: 20, borderRadius: 40 }


Execution failed for task ':app:transformDexArchiveWithDexMergerForRelease'?

$
0
0

I'm trying to release an APK for react native app v0.61.5,But I got this error

Execution failed for task':app:transformDexArchiveWithDexMergerForRelease'

I'm following all answers related but not works for me I don't know why?

I'm releasing the last two weeks an APK and it's generated very well

android/app/build.gradle

 defaultConfig {        applicationId "com.app.example"        minSdkVersion rootProject.ext.minSdkVersion        targetSdkVersion rootProject.ext.targetSdkVersion        versionCode 1        versionName "1.0"        multiDexEnabled true    }...dependencies {    def multidex_version = "2.0.1"    implementation 'androidx.multidex:multidex:$multidex_version' //added this implementation project(':react-native-splash-screen')    implementation fileTree(dir: "libs", include: ["*.jar"])    implementation "com.facebook.react:react-native:+"  // From node_modules    implementation 'androidx.appcompat:appcompat:1.1.0-rc01'    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'    implementation 'com.facebook.android:facebook-login:[5,6)'...}

android/build.gradle

buildscript {    ext {        buildToolsVersion = "28.0.3"        minSdkVersion = 16        compileSdkVersion = 28        targetSdkVersion = 28    }    repositories {        google()        jcenter()    }    dependencies {        classpath("com.android.tools.build:gradle:3.4.2")        // NOTE: Do not place your application dependencies here; they belong        // in the individual module build.gradle files        classpath 'com.google.gms:google-services:4.3.3'    }}allprojects {    repositories {        mavenLocal()        maven {            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm            url("$rootDir/../node_modules/react-native/android")        }        maven {            // Android JSC is installed from npm            url("$rootDir/../node_modules/jsc-android/dist")        }        google()        jcenter()        maven { url 'https://jitpack.io' }    }}

MainApplication.java

..

import androidx.multidex.MultiDexApplication;public class MainApplication extends MultiDexApplication implements ReactApplication {...}

instead of

public class MainApplication extends Application implements ReactApplication {...}

react native application on emulator stuck on white screen

$
0
0

on android only and only in the emulator, if I run my react native app, the app does not launch and get stuck on a white screen. The bundler in the terminal does not receive any connections requests.

It used to work and it works when I run on a device using the same command (react-native run-android)

I'm on react native 0.57.8

enter image description here

enter image description here

Here are the logs I get from react-native log-android:

    02-26 17:12:21.527  6544  6544 D ReactNative: ReactInstanceManager.ctor()    02-26 17:12:21.606  6544  6544 D ReactNative: ReactInstanceManager.createReactContextInBackground()    02-26 17:12:21.606  6544  6544 D ReactNative: ReactInstanceManager.recreateReactContextInBackgroundInner()    02-26 17:12:21.629  6544  6544 D ReactNative: ReactInstanceManager.recreateReactContextInBackgroundFromBundleLoader()    02-26 17:12:21.629  6544  6544 D ReactNative: ReactInstanceManager.recreateReactContextInBackground()    02-26 17:12:21.629  6544  6544 D ReactNative: ReactInstanceManager.runCreateReactContextOnNewThread()    02-26 17:12:21.665  6544  6604 D ReactNative: ReactInstanceManager.createReactContext()    02-26 17:12:21.727  6544  6604 D ReactNative: Initializing React Xplat Bridge.    02-26 17:12:21.729  6544  6604 D ReactNative: Initializing React Xplat Bridge before initializeBridge    02-26 17:12:21.735  6544  6604 D ReactNative: Initializing React Xplat Bridge after initializeBridge    02-26 17:12:21.735  6544  6604 D ReactNative: CatalystInstanceImpl.runJSBundle()

I even tried reverting to older code version via git to version that I know worked, but that still fails, so I think there might be a configuration issue with my machine and the emulator, but I'm unsure what.

Any idea what might be causing this issue?

How to mitigate local network problem with Expo

$
0
0

Expo is crashing when using an Android emulator on my Ubuntu machine. So what I want to do is upload the app to my real Android device using Expo. But when I do this using the local wifi network, I get:

enter image description here

enter image description here

Perhaps I should just physically tether my phone to my Ubuntu laptop instead of going through Wifi? What about bluetooth to upload the app to the phone from my Ubuntu machine?

Using BLE/USB camera/barcode reader in React Native App

$
0
0

I am trying to make a react native app, which connects to an external Barcode Reader/Camera for scanning barcodes. I know that it is easy to implement using react-native-camera but I need to connect it so an external device. Any idea how we could implement it?

Create custom SDK for React Native

$
0
0

What i want to achieve is something like creating my own SDK like what react-native-fbsdk or rn-onesignal-sdk provides , so that those functionalities can be implemented in the react native project.

Basic questions :

  1. Where to start from? Like what are the pre-requisites?
  2. Native coding is required i believe for this functionality?

Any explanation or any such experience in such would be of great help .

I am unable to run android project after ejecting it ,my build stopped working whenever i run cmd react-native run-android

$
0
0

I have build a project using expo ,it is working fine using expo when i eject it and run using android studio.Whenever i entered npm run android or react-native run-android commands it shows me error that given below Can you help anyone help me regarding this matter.

  The Kotlin Gradle plugin was loaded multiple times in different subprojects, which is not   supported and may break the build.  This might happen in subprojects that apply the Kotlin plugins with the Gradle 'plugins {    ... }' DSL if they specify explicit versions, even if the versions are equal.  Please add the Kotlin plugin to the common parent project or the root project, then remove   the versions in the subprojects.   If the parent project does not need the plugin, add 'apply false' to the plugin line.   See: https://docs.gradle.org/current/userguide/plugins.html#sec:subprojects_plugins_dsl    The Kotlin plugin was loaded in the following projects: ':expo-error-recovery', ':expo-    permissions'> Task :app:installDebug  11:01:12 V/ddms: execute: running am get-config  11:01:13 V/ddms: execute 'am get-config' on 'emulator-5554' : EOF hit. Read: -1  11:01:13 V/ddms: execute: returning  Installing APK 'app-debug.apk' on 'Nexus_5X_API_23(AVD) - 6.0' for app:debug  11:01:13 D/app-debug.apk: Uploading app-debug.apk onto device 'emulator-5554'  11:01:13 D/Device: Uploading file onto device 'emulator-5554'  11:01:13 D/ddms: Reading file permision of   C:\xampp\htdocs\MyTest2App\android\app\build\outputs\apk\debug\app-debug.apk as: rwx------  11:01:14 V/ddms: execute: running pm install -r -t "/data/local/tmp/app-debug.apk"  11:01:15 V/ddms: execute 'pm install -r -t "/data/local/tmp/app-debug.apk"' on 'emulator-   5554' :   EOF hit. Read: -1  11:01:15 V/ddms: execute: returning> Task :app:installDebug FAILED  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.

How to launch function when screen in reached in TabNavigator ? [REACT NAVIGATION]

$
0
0

The problem is that the functions constructor() and componentDidMount() are called when the tab navigator is loaded. And I need to call function each time the user reachs the screen named myScreeen for exampleHow we can do that ?


Error while updating property color on shadow node of type: AndroidTextInput

$
0
0

getting this error**strong text**

I don't know when and where this error appeared, so I cant attach any code. This looks like bug, on ios work properly. Is error tells that I should set Integer as property color? What?

Do someone know what should I do, thanks

Not able to setup React native project on windows

$
0
0

Hi I have followed the official documentation for setting up the React native project on windows.I have added the ANDROID_HOME variable as system variable at location

"C:\Users\AKSHAY\AppData\Local\Android\Sdk"enter image description here

In the second step I was supposed to add Environment variable at

"C:\Android\tools\bin\platform-tools"

but there is no tools folder in Android instead I found platform-tools under SDK below is the location

"C:\Users\AKSHAY\AppData\Local\Android\Sdk\platform-tools"

Now when I am running

npx react-native run android

I am getting the below attached error

enter image description here

Here is the SDK folderenter image description herePlease help.

Why is `unstable_Profiler` not profiling on production mode?

$
0
0

I have an issue with unstable_Profiler on my React-Native project that is ignoring onRender callback, but only in production mode. No errors, everything renders fine. I went by this article: https://itnext.io/react-native-profiler-43d131130c5c

I tested solution on dev mode (react-native run-android) and everything worked perfect. Production build of app is not working.I tried recent versions of react and react-native, react-dom, schedule, scheduler, modify .babelrc but nothing worked for me.

import React, { unstable_Profiler as Profiler } from 'react';const withProfiler = (profilerId) => (WrappedComponent) => {  class ProfilerComponent extends React.Component {    async logMeasurement(id, phase, actualDuration, baseDuration) {      // see output during DEV      console.log({id, phase, actualDuration, baseDuration});      // also here is some logic to log durations in prod mode. (eg. logcat)      // but it never happened.     }    render() {      return (<Profiler id={profilerId} onRender={this.logMeasurement}><WrappedComponent {...this.props} /></Profiler>      );    }  }  return ProfilerComponent;};export default withProfiler;

.babelrc

{"presets": ["module:metro-react-native-babel-preset"  ],"plugins": [    ["module-resolver", {"root": ["./"],"alias": {"react-dom$": "react-dom/profiling","scheduler/tracing": "scheduler/tracing-profiling"      }    }]  ],"env": {"production": {"plugins": ["transform-remove-console",      ]    },"development": {"plugins": ["@babel/plugin-transform-react-jsx-source"      ]    }  }}

package.json

"react": "^16.8.1","react-native": "^0.57.8","react-dom": "16.8.1","react-art": "16.8.1","schedule": "^0.4.0","scheduler": "^0.13.1","@babel/core": "7.1.0","@babel/plugin-proposal-decorators": "^7.3.0","@babel/plugin-transform-react-jsx-source": "^7.2.0","@babel/preset-env": "^7.3.1","@babel/register": "^7.0.0","babel-core": "^7.0.0-bridge.0","babel-loader": "^8.0.4","babel-plugin-module-resolver": "^3.1.3","babel-plugin-transform-remove-console": "^6.9.4","metro-react-native-babel-preset": "^0.48.1",

Expected result is that logMeasurement method is running in production app.


EDIT

I have invalid binding of logMeasurement. Here is how I fixed it.

logMeasurement = async (id, phase, actualDuration, baseDuration) => { ... }

However, it did't fix the issue. The callback is still not called.

Get value returned form fetch assigned to a variable

$
0
0

I want to get the returned value "responseData" assigned to the data variable

fetch('http://localhost:8080/users/update, {          method: 'PUT',          headers: {'Accept': 'application/json', 'Content-Type': 'application/json'},          body: JSON.stringify({              name:this.state.name,              Level:this.state.activity,              height:this.state.height,              weight:this.state.weight          })})          .then((response) => {              return response.json()             })          .then((responseData) => {            console.log(responseData)               this.setState({              data:responseData            })          }          );

I does return true I just want to get it assigned to the variable I already tried to use

this.setState({              data:responseData            })

But it didn't work

React-Native-Sound path for ios file?

$
0
0

I'm curently developping an app on React-Native and I need to play sound.The fact is that I am on Ubuntu and developing with IntelIJ Idea.

I'm using react-native-sound library to play sounds.

Thanks to this post, I know where I put my .mp3 file for android, but the files have to be somewhere in the ios section as well ?

Where do we put them ?

Import aar file from Android Studio into React Native and use aar file

$
0
0

i am new to react native. i dont have knowledge of java/android studio.i have some work to do with VPN app. i am making a VPN App. and i found no library for react native to call VPN features and connect VPN (If there are any please help me out).i Found a solution to make VPN app. that is:1. make a vpn project on java/android studio and then make an "aar" file and import into react native and call the classes.but i dont know exactly how to do this.i am using android studio 3.6.3

as an example or to do PoC: i have created android library "mylibrary" which has file "Util.java" and made aar file named as "mylibrary-release.aar" as well you can see whole project in this pic =>andriod studio project with library

now i want to import this in my react native project and use it and call it as PoC. this is my React Native Project. react-native VS code project

can anyone guide me what to do next, how to add this aar to dependencies and also how to call it?thankyou.

How to reuse android device back button handler component from multiple classes using react native?

$
0
0

In my scenario, I am trying to use android back handler class in single file. How to access this from multiple class files instead of duplicating.

my code below

export default class hardware extends Component {  constructor(props) {    super(props);    this.BackButton = this.BackButton.bind(this);  }  componentWillMount() {    BackHandler.addEventListener'BackPress',this.BackButton);  }  componentWillUnmount() {    BackHandler.removeEventListener('BackPress',this.BackButton);  }  BackButton() {    if(this.props.navigation){        this.props.navigation.goBack(null);        return true;      }    }}

How to access from multiple other class files screens?

export default class screenone extends Component {   // how to access here?}

How to validate TextInput values in react native?

$
0
0

for example, While entering an email in the TextInput, it should validate and display the error message. where the entered email is valid or not

enter image description here

Cross platform Mobile SDK with react native for IOS and Android

$
0
0

I am beginner to react native. Please forgive if it is a very basic question. I have a Javascript client library which I want to write for both IOS and Android also. Instead of writing separately. would like to know if I could create such libraries using React Native.Like writing the library in react native and convert it to IOS or Android compatible. like adding the dependency in the existing Native application like Android or Swift codebase.

I checked with many articles where everything is explaining about integrating the react native app to native application with View but what I am looking for is different I need to integrate that library like dependency.Kindly help me with this

Thanks in Advance.

React Native Runtime Error: No native client found. Is Bugsnag React Native installed in your native code project?

$
0
0

I am trying to integrate bugsnag to my react native application. The app builds successfully but when the app loads on a simulator or emulator it throws an exception

Bugsnag: No native client found. Is BugsnagReactNative installed in your native code project?Client<unknown>    global.js:4:27loadModuleImplementation    require.js:331:6<unknown>    index.android.js:9loadModuleImplementation    require.js:331:6guardedLoadModule    require.js:197:45global code

I have updated my AndroidManifest.xml, MainApplication.java, Info.plist, build.gradle to include the api-key and bugsnag-react-native was successful too.

my package.json versions look like

"react": "16.8.3","react-native": "0.59.10","bugsnag-react-native": "^2.23.2",

AndroidManifest.xml

<meta-data android:name="com.bugsnag.android.API_KEY"               android:value="API KEY"/>

MainApplication.java

@Override public void onCreate() {    super.onCreate();    BugsnagReactNative.start(this);    SoLoader.init(this, /* native exopackage */ false);  }

info.plist

<key>BugsnagAPIKey</key><string>API KEY</string>

How do I launch a splash screen for every launch in React Navigation V5?

$
0
0

I want to launch SplashScreen, for every App launch where I'll be performing a large number of tasks. Once this is done, I'll navigate to AuthScreen or MainScreen.

Since there is no SwitchNavigator in V5. How do I achieve the following conditions,

  1. AuthScreen: When a user clicks the Android hardware back button, he has to exit the App without going back to SplashScreen.

  2. MainScreen: Same scenario as above, When a user clicks the Android hardware back button, he has to exit the App.

I can place SplashScreen inside <RootStack.Navigator/> making SplashScreen as initialRouteName but it didn't satisfy the above conditions.

Can anyone help me out where should I place the SplashScreen component in V5?

Here is the AppNavigation.js file

const RootStackScreen = ({ userStatus }) => {    return (<RootStack.Navigator headerMode="none">            {userStatus ? (<RootStack.Screen name="AppDrawerScreen" component={AppDrawerScreen} />            ) : (<RootStack.Screen name="AuthStackScreen" component={AuthStackScreen} />            )}</RootStack.Navigator>    );};const AppContainer = ({ user }) => {    return (<NavigationContainer><RootStackScreen userStatus={user} /></NavigationContainer>    );};

borderRadius and padding styling for nested text

$
0
0

I want to apply a different borderRadius and padding styling to nested texts, but as far as I could understand this is not supported by react native yet. Is there a workaround for this ?

What I tried so far is :

<Text><Text          style={{            backgroundColor: 'green',            borderRadius: 12,          }}>          Text1</Text><Text          style={{            backgroundColor: 'blue',            borderRadius: 12,          }}>          Text2</Text></Text>

Expected Result: Text with different backgrounds and with a borderRadius.

Actual Result: backgrounds are differnet but no borderRadius is applied

Viewing all 28476 articles
Browse latest View live


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