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

React-native android "Program type already present: com.reactnativecommunity.asyncstorage.AsyncLocalStorageUtil"

$
0
0

We just upgrade a package and this happens. It works in the IOS part but not on the android part. I tried excluding this class but no avail is there any way to diss able this class from a package? I search for same issue but no avail I tried to rollback but we have changes that need the new package

app/build.gradle

    apply plugin: "com.android.application"apply from: project(':react-native-config').projectDir.getPath() +"/dotenv.gradle"import com.android.build.OutputFileproject.ext.react = [    entryFile: "index.js",    enableHermes: false,  // clean and rebuild if changing]apply from: "../../node_modules/react-native/react.gradle"def enableHermes = project.ext.react.get("enableHermes", false);android {    compileSdkVersion rootProject.ext.compileSdkVersion    compileOptions {        sourceCompatibility JavaVersion.VERSION_1_8        targetCompatibility JavaVersion.VERSION_1_8    }    defaultConfig {        applicationId "com.ginko.ginko"        minSdkVersion rootProject.ext.minSdkVersion        targetSdkVersion rootProject.ext.targetSdkVersion        versionCode 1        versionName "1.0"        multiDexEnabled true        missingDimensionStrategy 'react-native-camera', 'general'    }    splits {        abi {            reset()            enable enableSeparateBuildPerCPUArchitecture            universalApk false  // If true, also generate a universal APK            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"        }    }    signingConfigs {        debug {            storeFile file('debug.keystore')            storePassword 'android'            keyAlias 'androiddebugkey'            keyPassword 'android'        }        release {            if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {                storeFile file(MYAPP_UPLOAD_STORE_FILE)                storePassword MYAPP_UPLOAD_STORE_PASSWORD                keyAlias MYAPP_UPLOAD_KEY_ALIAS                keyPassword MYAPP_UPLOAD_KEY_PASSWORD            }        }    }    buildTypes {        debug {            signingConfig signingConfigs.debug        }        release {            // Caution! In production, you need to generate your own keystore file.            // see https://facebook.github.io/react-native/docs/signed-apk-android.            signingConfig signingConfigs.release            minifyEnabled enableProguardInReleaseBuilds            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"            // signingConfig signingConfigs.release        }    }    // applicationVariants are e.g. debug, release    applicationVariants.all { variant ->        variant.outputs.each { output ->            // For each separate APK per architecture, set a unique version code as described here:            // https://developer.android.com/studio/build/configure-apk-splits.html            def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]            def abi = output.getFilter(OutputFile.ABI)            if (abi != null) {  // null for the universal-debug, universal-release variants                output.versionCodeOverride =                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode            }        }    }}dependencies {    compile(project(':react-native-nearby-api')) {         exclude group: 'com.google.android.gms'    }    implementation project(':react-native-contacts')    implementation (project(':@react-native-community_async-storage')){        exclude group: 'com.reactnativecommunity.asyncstorage.AsyncStorageErrorUtil'    }    implementation (project(":react-native-device-info"))    implementation project(':@react-native-community_geolocation')    implementation project(':react-native-permissions')    implementation project(':react-native-camera')    implementation (project(':react-native-ble-plx')){        exclude group: 'com.reactnativecommunity.asyncstorage.AsyncStorageErrorUtil'    }    implementation project(':react-native-linear-gradient')    implementation fileTree(dir: "libs", include: ["*.jar"])    implementation "com.facebook.react:react-native:+"  // From node_modules    implementation 'androidx.appcompat:appcompat:1.1.0-rc01' // for react-native-screens    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02' // for react-native-screens    // implementation project(':WebRTCModule')    implementation 'com.google.android.gms:play-services-nearby:17.0.0'    if (enableHermes) {        def hermesPath = "../../node_modules/hermes-engine/android/";        debugImplementation files(hermesPath +"hermes-debug.aar")        releaseImplementation files(hermesPath +"hermes-release.aar")    } else {        implementation jscFlavor    }}// Run this once to be able to run the application with BUCK// puts all compile dependencies into folder libs for BUCK to usetask copyDownloadableDepsToLibs(type: Copy) {    from configurations.compile    into 'libs'}apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"apply plugin: 'com.google.gms.google-services'// googleServices { disableVersionCheck = true }

how to store/save data in react native

$
0
0

How to store/save data in react native.Like we use shared-preference in android is there any solution for react native.I am new to react-nactive.

please add sample example

Unable to load script from assets index.android.bundle on windows

$
0
0

I'm trying to run my first React Native project for first time on my device (Android 4.2.2).

And I get:

unable to load script from assets index.android.bundle

Commands that I used:

  1. cd (project directory)
  2. react-native start
  3. react-native run-android

react-native how use OkHttp Proxy.NO_PROXY?

$
0
0
OkHttpClient okHttpClient = new OkHttpClient.Builder()            .proxy(Proxy.NO_PROXY)            .build();Request request = new Request.Builder()        .url("https://stackoverflow.com/questions/ask")                        .build();

How does the above code use react-native fetch api ?

i need use proxy(Proxy.NO_PROXY)

Integrate Python OpenCV with React Native/Android/iOS

$
0
0

I have an app built on React Native whose core functionality is to capture some images, analyse and process the images and return some results. As of now the image analysis was done in the server side using python and opencv. Only the results and the resultant images were returned. Now as per the requirement by the clients, due to privacy concerns, they want the image processing to be done on the mobile app itself. (As the images are medical related and they don't want the images to be sent to the server)

So, my question is, if there is a way I can use my existing python with opencv code and integrate it directly into react-native/android/ios?

Right now what I am doing is using the library react-native-opencv3 , numjs, etc to re-write the algorithm in react-native as I feel comfortable using javascript (I have no experience in swift). However not all opencv, numpy functions are supported by these libraries and it is consuming all the time to re-write the code.

I found about using jython, python-for-android and swift-python-interoperabilityCan I use these to directly integrate python opencv code into my current application? If yes, it would be great if someone can help me with some small example or guidelines as I cannot find anything.

Other method that I considered was:

Re-write the algorithm using native code and opencv-android and opencv-ios sdks and create the react-native bridge to call the algorithm. (I am guessing it will take a lot of time as I have to write in 2 different languages. Time that I don't have)

Could not connect to React Native development server on Android

$
0
0

When I run react-native run-android, it gives me the following error:

Could not connect to development server

Error screen

  • Package server is running and I can access it directly from browseron my mobile device.
  • My Android device is connected to computer and has debugging enabled (Ichecked using adb devices command).
  • My Android version is 4.4.4 so I cannot use adb reverse command.
  • I have set the ID address and port in Dev setting.
  • USB debug is on.
  • I use Windows 7.

How to fix this error?

Tengo problemas al emular mi disposotivo android en VS code, Pd: recien estoy empezando a aprender

Network request failed Android

$
0
0

While working on a Weather app written in react native, I am getting the 'Network request failed' error on Android while the app is working fine on iOS.

enter image description here

Here is the fetch function -

componentDidMount: function() {    navigator.geolocation.getCurrentPosition(    location => {      // this variable will contain the full url with the new lat and lon      var formattedURL = REQUEST_URL +"lat="+ location.coords.latitude +"&lon="+ location.coords.longitude+"&APPID=e5335c30e733fc682907a126dab045fa";      // this will output the final URL to the Xcode output window      console.log(location.coords.latitude);      console.log(location.coords.longitude);      console.log(formattedURL);      // get the data from the API      this.fetchData(formattedURL);      },    error => {      console.log(error);    });  },  // fetchdata takes the formattedURL, gets the json data and  // sets the apps backgroundColor based on the temperature of  // the location  fetchData: function(url) {    fetch(url)      .then((response) => response.json())      .then((responseData) => {        // set the background colour of the app based on temperature        var bg;        var temp = parseInt(responseData.main.temp);        if(temp < 14) {          bg = BG_COLD;        } else if(temp >= 14 && temp < 25) {          bg = BG_WARM;        } else if(temp >= 25) {          bg = BG_HOT;        }        // update the state with weatherData and a set backgroundColor        this.setState({          weatherData: responseData,          backgroundColor: bg        });      })      .done();  },

I have also referred to other questions here on stackoverflow but they all revolve around changing localhost to your local ip address like 127.0.0.1. In my case I have no where used localhost.


How to get current route name in react-navigation?

$
0
0

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

"Network Error" Coming after successfully build apk from react native in android 8 and above version

$
0
0

I need your help in solving this issue in react native. I have completed the app in react native and trying to upload it on play store. but HTTPS request is not working in expo of android version 8 and above. I also tried detaching the project to make the build but again same issue is coming

Error message - "Network Error"

Thanks in advance!

borderWidth on Android in React Native

$
0
0

I don't understand why on Android the text is ON the border (not inside), when the borderWidth property of the Text element is greater than 1.

enter image description here

const BoxScreen = () => {  return (<View style={styles.viewStyle}><Text style={styles.textStyle}>Child #1</Text><Text style={styles.textStyle}>Child #2</Text><Text style={styles.textStyle}>Child #3</Text></View>  );};const styles = StyleSheet.create({  viewStyle: {    borderWidth: 3,    borderColor: 'black',    alignItems: 'flex-end'  },  textStyle: {    borderWidth: 50,    borderColor: 'red'  }});

Keyboard aware scroll view Android issue

$
0
0

I've created a react native project using Expo XDE (xde-2.19.3) with a few TextInputs on the screen. Im using KeyboardAwareScrollView to scroll the inputs from under the keyboard into view and works fine on iOS but does not work on Android. Hope that makes sense.

Looked at the KeyboardAwareScrollView docs and saw that I need to configure AndroidManifest.xml but it seems that Expo has already sorted this out: https://github.com/expo/expo/blob/master/template-files/android/AndroidManifest.xml

However I'm still not able to get this working on Android...

What could I be missing?

render() {    return (<KeyboardAwareScrollView        enableOnAndroid='true'        enableAutoAutomaticScrol='true'        keyboardOpeningTime={0}><ScrollView style={styles.container}><View style={styles.subcontainer}><View style={styles.form}><TextInput                ref='NoduleCountInput'                onFocus={() => this.onFocus()}                onBlur={() => this.onBlur()}                keyboardType='phone-pad'                returnKeyType='done'                placeholder='Test'                style={styles.field}              /><TextInput                ref='NoduleCountInput'                onFocus={() => this.onFocus()}                onBlur={() => this.onBlur()}                keyboardType='phone-pad'                returnKeyType='done'                placeholder='Test'                style={styles.field}              /><TextInput                ref='NoduleCountInput'                onFocus={() => this.onFocus()}                onBlur={() => this.onBlur()}                keyboardType='phone-pad'                returnKeyType='done'                placeholder='Test'                style={styles.field}              /><TextInput                ref='NoduleCountInput'                onFocus={() => this.onFocus()}                onBlur={() => this.onBlur()}                keyboardType='phone-pad'                returnKeyType='done'                placeholder='Test'                style={styles.field}              /><TextInput                ref='NoduleCountInput'                onFocus={() => this.onFocus()}                onBlur={() => this.onBlur()}                keyboardType='phone-pad'                returnKeyType='done'                placeholder='Test'                style={styles.field}              /><TextInput                ref='NoduleCountInput'                onFocus={() => this.onFocus()}                onBlur={() => this.onBlur()}                keyboardType='phone-pad'                returnKeyType='done'                placeholder='Test'                style={styles.field}              /><TextInput                ref='NoduleCountInput'                onFocus={() => this.onFocus()}                onBlur={() => this.onBlur()}                keyboardType='phone-pad'                returnKeyType='done'                placeholder='Test'                style={styles.field}              /></View></View></ScrollView></KeyboardAwareScrollView>    );  }

React native navigation drawer is not covering header in my application

$
0
0

I am new to react native development, but i have some requirement with react navigation drawer. I want to display the navigation drawer from top of the screen but it is display below from toolbar. It is a combination of both Stack and Drawer screens. Following is my code in App.js

function App() {  SplashScreen.hide()  return (<NavigationContainer>      {/* headerMode='float' */}<Stack.Navigator initialRouteName='Login'><Stack.Screen name="Login" component={LoginScreen}          options={{ headerShown: false }} />        {/* <Stack.Screen name="Home" component={HomeScreen} /> */}<Stack.Screen name="DrawerScreens" component={DrawerScreens}           options={({ navigation, route }) => ({            title: "Home",            headerTintColor: '#FFFFFF', headerStyle:{backgroundColor:'#154493'},            headerLeft: props => <NavigationDrawerStructure navObj={navigation} />,          })} /><Stack.Screen name="Dashboard" component={Dashboard}             options={({ route }) => ({headerTintColor: '#FFFFFF', headerStyle:{backgroundColor:'#154493'}})} /></Stack.Navigator></NavigationContainer>

DrawerScreens function is like following..

function DrawerScreens({ route, navigation }) {  // console.log("param:"+route.params.token)  return (    //drawerContent={props=>CustomDrawerContent(props)}    // <SafeAreaProvider><Drawer.Navigator drawerContent={props => CustomDrawerContent(props)} headerMode="float">    {/* <Drawer.Navigator drawerContent={props => CustomDrawerContent(props)}> */}      {/* options={{ drawerLabel: 'Updates' }} */}<Drawer.Screen name="LandingScreen" component={LandingScreen}        initialParams={{ token: route.params.token }}/>  );}

CustomDrawer function contains list of the menu items which is dynamic and NestedMenuView is taking care of that..

function CustomDrawerContent(props) {  return (<SafeAreaView style={{flex: 1}} forceInset={{ top: "always" }}><NestedMenuView navObj={props.navigation} /></SafeAreaView>         );};

Please check the reference image here, I want left menu starts from header instead of below from header

Thanks in advance.

Android ReactNative java.lang.UnsatisfiedLinkError:could find DSO to load: libreactnativejni.so

$
0
0

I have been trying to add ReactNative to my existing android application. I followed the instructions from this link. I could add it but the app gets crashed once I open the react native activity. I have started server using

adb reverse tcp:8081 tcp:8081

and started react-native using

react-native start

I get a dialogue that the js files are loading. But finally end up with a crash. Following is the error that is being printed in logcat:

java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libreactnativejni.so    at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:213)    at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:178)    at com.facebook.react.bridge.JSCJavaScriptExecutor.<clinit>(JSCJavaScriptExecutor.java:19)    at com.facebook.react.ReactInstanceManager.onJSBundleLoadedFromServer(ReactInstanceManager.java:413)    at com.facebook.react.ReactInstanceManager.createReactContextInBackground(ReactInstanceManager.java:236)

I am completely lost as I am unable to figure out the cause for this issue.

Thanks in advance.

Width of buttons not changing in react native

$
0
0

I have two buttons in a row separated by the padding of 20 and they have occupied the width needed for the title of the button. Their width doesn't change!

Code for buttons

<View style={styles.buttonContainer}><View style={{ paddingLeft: 20 }}><Button title={tick} style={styles.button} onPress color="tomato" /></View><View style={{ paddingLeft: 20 }}><Button title="X" style={styles.button} onPress color="tomato" /></View></View>

CSS for buttons

buttonContainer: {    flex: 1,    flexDirection: 'row',    justifyContent: 'flex-end'},button: {    width: 50, // no matter what value I set here, their width doesn't changes    height: 20,},

Unable to build react native android library project

$
0
0

Error:

Cause: internal/modules/cjs/loader.js:985  throw err;  ^Error: Cannot find module 'react-native/cli'Require stack:- E:\APP\DemoTest\[eval]    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)    at Function.Module._load (internal/modules/cjs/loader.js:864:27)    at Module.require (internal/modules/cjs/loader.js:1044:19)    at require (internal/modules/cjs/helpers.js:77:18)    at [eval]:1:13    at Script.runInThisContext (vm.js:120:20)    at Object.runInThisContext (vm.js:311:38)    at Object.<anonymous> ([eval]-wrapper:10:26)    at Module._compile (internal/modules/cjs/loader.js:1158:30)    at evalScript (internal/process/execution.js:94:25) {  code: 'MODULE_NOT_FOUND',  requireStack: [ 'E:\\APP\\DemoTest\\[eval]' ]}

Unable to inspect PICKER/DROPDOWN on Appium Inspector(Android)

$
0
0

Device: Android

App: react native hybrid app

Appium/Appium Inspector version: Version 1.15.1 (1.15.1.20191013.2)

Issue:I am unable to inspect a picker/dropdown. It doesn't appear in the app source at all. Hence unable to find any locators to do further automation.

Description:

  1. I open the android app on the mobile and navigate to a form wherecertain details need to be filled.One of the things to be filled isa dropdown.
  2. I click on the arrow on the dropdown field
  3. A NEW window/popup appears on top of the ORIGINAL form for thepicker values to be displayed, which can be scrolled to see variousvalues.
  4. This new picker value window/pop up doesnt not come in the appsource in the appium inspector at all

Can you please tell me a workaround to automate this scenario to select values in the dropdown.I am using Java + Selenium + Appium for the automation framework .

Thank you!

Couldn't start project on Android: Error running adb: This computer is not authorized to debug the device

$
0
0

I'm using a Pixal 2XL and I'm running Windows 10. I am using Expo and Visual Studio Code to develop.

I've enabled developer options and I've enabled USB debugging. I was able to run the application on my phone about a month ago however now it doesn't work. Recently my phone did an update so I'm unsure if that caused this error.

I've already looked for solutions and non of them worked. I've tried turning on developer options on and off and I've tried revoking all authorizations.

I'm not using genymotion, Android Studio, or an emulator.

Android app keeps crashing after adding react-native-notifications wix

$
0
0

I had react-native-navigation already installed for my react-native app . As I installed react-native-notification by wix android app keeps crashing without any error message.Can somebody help with this or suggest how to implement local notification in react native.

React native Keyboard pushes Bottomsheet out of screen

$
0
0

I am struggling with this issue now for 2 weeks.I am using the package osdnk/react-native-reanimated-bottom-sheet and I want to use textinputs inside the bottomsheet. The problem appears when opening the keyboard. The bottomsheet is pushed out of the screen.

I am using expo and don't want to escape, so please don't provide solutions with the Android.xml file.

My code looks like the following: (simplyfied)

const renderInner = () => (<View><FormTextInput/></View>)return (<BottomSheet        snapPoints={['100%']}        renderContent={renderInner}        renderHeader={renderHeader}        initialSnap={0}    />)

How can I fix this weird behaviour?I also tried different variations with KeyboardAvoidingView & ScrollView, but I didn't managed it yet.

Viewing all 28468 articles
Browse latest View live