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

Share content on LinkedIn for both android and ios using react native

$
0
0

I have an app built in react-native in which I have to share these data to LinkedIn

const options = {            title: 'Share via',            message: 'some message',            image:'images need to be shared' //may be multiple images            } 

I tried so many ways but not working. How can I do this?


React native app firebase crash report on splashscreen

$
0
0

Getting this crash quite often on firebase crashlytics.

Versions I'm consuming in my project:

"react": "16.8.6",

"react-native": "0.60.5",

"react-native-splash-screen": "3.2.0",

Fatal Exception: java.lang.NoClassDefFoundErrororg.devio.rn.splashscreen.fcom.facebook.react.PackageList.getPackages (PackageList.java)com.ingoibibo.MainApplication$1.getPackages (MainApplication.java)com.facebook.react.ReactNativeHost.createReactInstanceManager (ReactNativeHost.java)com.facebook.react.ReactNativeHost.getReactInstanceManager (ReactNativeHost.java)com.facebook.react.HeadlessJsTaskService.access$000 (HeadlessJsTaskService.java)com.facebook.react.HeadlessJsTaskService.onStartCommand (HeadlessJsTaskService.java)android.app.ActivityThread.handleServiceArgs (ActivityThread.java:2983)android.app.ActivityThread.access$2200 (ActivityThread.java:172)android.app.ActivityThread$H.handleMessage (ActivityThread.java:1405)android.os.Handler.dispatchMessage (Handler.java:102)android.os.Looper.loop (Looper.java:146)android.app.ActivityThread.main (ActivityThread.java:5653)java.lang.reflect.Method.invokeNative (Method.java)java.lang.reflect.Method.invoke (Method.java:515)com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1291)com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1107)dalvik.system.NativeStart.main (NativeStart.java)

Unable to understand the cause of it. Let me know if anybody can help.

How to allow one device login in react-native?

$
0
0

I have implemented an APP that should allow one device one account which I will pass the uniqueId to Web API to be save alongside with user account row in SQL database. This validation happen on Splash and Authentication screen. The flow as below:

Logic Flow:

Device 1:

  1. Splash screen: retrieve value from AsyncStorage. If none, proceed to Authentication. If have value, go to #3
  2. Fill username and password and click Login.
  3. APP will fetch with web API together with userName, encrypted password and uniqueId retrieved from DeviceInfo module.
  4. If uniqueId column in SQL is empty, update the column. If have value, compare with uniqueId param. Condition: MATCH-return OK, NOT MATCH-return multiple login alert as exception.
  5. Fetch promise resolve OK:- Save encrypted userId and userName into AsyncStorage and go to Dashboard
  6. Fetch promise reject:- Show alert and stay at current screen.
  7. Notify Web API to clear the uniqueId column and AsyncStorage will clear the token value when user click Logout button

Device 2:

  1. Follow directly as Device 1

Situation:

User register 1 device or 1 account. So, if user have 2 device, they have to logout device 1 and login on device 2 to prevent the "Multiple Device Login" alert.

Problem:

As user reported Device 2 are lost or stolen. Our admin system will clear the uniqueId column for reported login information. But the real deal is(for Android, not familiar with ios yet); If user is not logout and press HOME button which fake the report, the APP will rest at task manager and use Device 1 to login. So at the end, 2 device can use 1 account.

Inquiry for the best solutions for the faced PROBLEM:

  1. Do I need to pass the uniqueId everytime the APP will fetch from the Web API to be validated when I will enquiry Web API for data?
  2. Is it practical to use Headless JS to check with Web API and inform the UI that multiple device alert and automatically logout the current device?
  3. Any other better ideas?

Most of tutorial or example show the validation as I doing now, but not found yet for situation on my problem.

Expo error when building Android build. Stopping at app:singReleaseBundle; gradle error

$
0
0

Hi my Android expo build is erroring out in Step 5 (Running Gradle). This error is coming when I build using APK.

Specifically, it stops at the app:singReleaseBundle task.

Task :app:signReleaseBundle FAILED[stderr]FAILURE: Build failed with an exception.[stderr]* What went wrong:[stderr]Execution failed for task ':app:signReleaseBundle'.[stderr]> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade[stderr]> Failed to read key XXXXXXX= from store "/tmp/turtle/keystore-XXXXXXX.jks": Invalid keystore format[stderr]* Try:[stderr]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.[stderr]* Get more help at https://help.gradle.org[stderr]BUILD FAILED in 4m 40s32 actionable tasks: 32 executedError: ./gradlew exited with non-zero code: 1    at ChildProcess.completionListener (/app/turtle/node_modules/@expo/xdl/node_modules/@expo/spawn-async/build/spawnAsync.js:52:23)    at Object.onceWrapper (events.js:418:26)    at ChildProcess.emit (events.js:311:20)    at ChildProcess.EventEmitter.emit (domain.js:482:12)    at maybeClose (internal/child_process.js:1021:16)    at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)    ...    at spawnAsync (/app/turtle/node_modules/@expo/xdl/node_modules/@expo/spawn-async/build/spawnAsync.js:17:21)    at spawnAsyncThrowError (/app/turtle/node_modules/@expo/xdl/build/detach/ExponentTools.js:190:45)    at buildShellAppAsync (/app/turtle/node_modules/@expo/xdl/build/detach/AndroidShellApp.js:912:11)    at async Object.createAndroidShellAppAsync (/app/turtle/node_modules/@expo/xdl/build/detach/AndroidShellApp.js:406:5)    at async runShellAppBuilder (/app/turtle/build/builders/android.js:83:9)    at async Object.buildAndroid [as android] (/app/turtle/build/builders/android.js:31:28)    at async build (/app/turtle/build/jobManager.js:158:24)    at async processJob (/app/turtle/build/jobManager.js:103:32)    at async Object.doJob (/app/turtle/build/jobManager.js:35:5)    at async main (/app/turtle/build/server.js:44:13)

Does anyone have any suggestions on how to resolve this error?

ADB can't connect to Nox

$
0
0

i have a problem which i trying to solve for about 3 days and i can't find any working solution. The problem is i can't connect my nox player to adb when i trying to connect with localhost and port 62001. Everything i did is:

-nox_adb.exe

nox_adb.exe connect 127.0.0.1:62001 -> unable to connect to 127.0.0.1:62001.

nox_adb.exe connect 127.0.0.1:5037 -> connected to 127.0.0.1:5037 (but when i trying to run react native project with this deviceId, it returns "No Android devices connected")

-adb.exe (from Android SDK)

adb.exe connect 127.0.0.1:62001 -> unable to connect to 127.0.0.1:62001.

adb.exe connect 127.0.0.1:5037 -> failed to connect to 127.0.0.1:5037.

I have installed whole android studio with (i think) needed libraries, Google USB Driver, sdk platforms, etc.Platform: Windows 7 x64Nox: 6.2.0.0

i have read:

Could someone tell me what I'm doing wrong?

React Native App crash in older android version

$
0
0
let carouselRef = React.createRef();

when we are calling this in

setTimeout(() => carouselRef.current.snapToNext(), 250);

working fine in emulator but crash in older android versions with error

com.facebook.react.common.JavascriptException: null is not an object (evaluating 'u.current.snapToNext'),stack:

@993:3659y@118:657callTimers@118:2816value@30:3311@30:822value@30:2565value@30:794value@-1at com.facebook.react.modules.core.ExceptionsManagerModule.showOrThrowError(ExceptionsManagerModule.java at com.facebook.react.modules.core.ExceptionsManagerModule.reportFatalException (ExceptionsManagerModule.java:38) at java.lang.reflect.Method.invoke (Native Method) at

React Native Image Picker: null is not an object (evaluating 'ImagePickerManager.showImagePicker')

$
0
0

I installed react-native-image-picker according to the documentation.When I am trying to select the image from the phone (after hitting the button), the emulator is giving me this error-null is not an object (evaluating 'ImagePickerManager.showImagePicker')

My React native's version is 0.59.8

and image picker's version is 0.28.0

this the code-

import React, { Component } from 'react';import {  StyleSheet,  Text,  View,  Image,  Button} from 'react-native';import ImagePicker from "react-native-image-picker";export default class App extends Component {  state = {    pickedImage: null  }  reset = () => {    this.setState({      pickedImage: null    });  }pickImageHandler = () => {    ImagePicker.showImagePicker({title: "Pick an Image", maxWidth: 800, maxHeight: 600}, res => {      if (res.didCancel) {        console.log("User cancelled!");      } else if (res.error) {        console.log("Error", res.error);      } else {        this.setState({          pickedImage: { uri: res.uri }        });      }    });  }       resetHandler = () =>{            this.reset();          }  render() {    return (<View style={styles.container}><Text style={styles.textStyle}>Pick Image From Camera and Gallery </Text><View style={styles.placeholder}><Image source={this.state.pickedImage} style={styles.previewImage} /></View><View style={styles.button}><Button title="Pick Image" onPress={this.pickImageHandler} /><Button title="Reset" onPress={this.resetHandler} /></View></View>    );  }}

How to store object or string in Objective-C and use it

$
0
0

I'm making a react native app and using a native module to get a "string" inside objective-c ios project.

RCT_EXPORT_MODULE();RCT_EXPORT_METHOD(getEmail:(NSString *)email){  RCTLogInfo(@"Getting %@", email);}

I don't know anything about the Objective-C part and I don't know how to store my "email" into something I can use and retrieve inside the AppDelegate.m

Example : [customFieldsDictionary setObject:email forKey:@"EMail"];

If someone can help or guide me through this, it would be awesome !

Thank you


Expo manifest.android.config missing in build apk

$
0
0

TypeErrorundefined is not an object (evaluating 'f.default.manifest.android.config.googleMaps')

https://sentry.io/ error show me that key config are missing in my manifest in apk.

Any ideas how to fix it?

APK

enter image description here

DEV

enter image description here

creating browser like Tabs (multiple instances of the same component) in react-native?

$
0
0

How do I go about creating a tab Container similar to chrome (mobile version)? like when a user creates a new tab (or new instance of a component), the previous one gets stored in the tab container with its current state. And how to show them as screenshots of the pages like this -

enter image description here

Task 'installDebug' not found in project ':app' - run-android after creating project

$
0
0

After creating a react native project, I tried to run it on my android device. I enter adb devices into the terminal, I saw my device. I ran react-native run-android. And after a while Task 'installDebug' not found in project ':app' popped up.

Jetifier found 962 file(s) to forward-jetify. Using 4 workers...info Starting JS server...'D:\Android\android-sdk\platform-tools' is not recognized as an internal or external command, operable program or batch file.info Launching emulator...error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.info Installing the app...Deprecated 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_warningsFAILURE: Build failed with an exception.* What went wrong:Task 'installDebug' not found in project ':app'.* Try:Run gradlew tasks to get a list of available tasks. 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 15serror Failed to install the app. Make sure you have the Android development environment set up:https://reactnative.dev/docs/getting-started.html#android-development-environment. 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:Task 'installDebug' not found in project ':app'.

Here is react-native info

info Fetching system and libraries information...System:    OS: Windows 7 6.1.7601    CPU: (4) x64 Intel(R) Core(TM) i3-2100 CPU @ 3.10GHz    Memory: 881.91 MB / 3.97 GB  Binaries:    Node: 10.16.1 - C:\Program Files\nodejs\node.EXE    Yarn: 1.17.3 - C:\Program Files (x86)\Yarn\bin\yarn.CMD    npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD    Watchman: Not Found  SDKs:    Android SDK: Not Found  IDEs:    Android Studio: Version  3.2.0.0 AI-181.5540.7.32.5014246  Languages:    Python: Not Found  npmPackages:    @react-native-community/cli: Not Found    react: 16.11.0 => 16.11.0    react-native: 0.62.0 => 0.62.0  npmGlobalPackages:    *react-native*: Not Found

I ran gradlew tasks and I did not see installDebug under the install tasks. I am sure that I set up the environment variables correctly, including android SDK, JDK. I tried reinstalling react-native. I put the location of my sdk in local.properties under android folder. I ran gradlew installDebug and installDebug not found in root project '[app's name]' appeared. None of the solutions on the internet worked.

Can anyone please help me to sort out this?Thank you.

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.

React-native on 64-bit devices - debug works fine but not release. No problem with 32-bit devices at all

$
0
0

I googled a lot but none of findings is equal to my case:

  1. Only 64-bit Android devices affected (tried on several - all the same)
  2. Debug build on same devices attached via USB works with no issues
  3. Release signed build hangs on every 64-bit device (tried both 64/32 versions)
  4. 32-bit and universal signed release works like a charm on 32-bit devices

How it could be possible that SAME CODE works differently in debug and release, why? Different JS Core used?

[UPD]catlog shows problem with pouchdb replication:

{ [Error]10-19 08:55:39.157 22836 22855 I ReactNativeJS:   line: 132,10-19 08:55:39.157 22836 22855 I ReactNativeJS:   column: 7285,10-19 08:55:39.157 22836 22855 I ReactNativeJS:   sourceURL: 'index.android.bundle',10-19 08:55:39.157 22836 22855 I ReactNativeJS:   result: 10-19 08:55:39.157 22836 22855 I ReactNativeJS:    { ok: false,10-19 08:55:39.157 22836 22855 I ReactNativeJS:      start_time: '2019-10-19T05:55:38.997Z',10-19 08:55:39.157 22836 22855 I ReactNativeJS:      docs_read: 0,10-19 08:55:39.157 22836 22855 I ReactNativeJS:      docs_written: 0,10-19 08:55:39.157 22836 22855 I ReactNativeJS:      doc_write_failures: 0,10-19 08:55:39.157 22836 22855 I ReactNativeJS:      errors: [],10-19 08:55:39.157 22836 22855 I ReactNativeJS:      status: 'aborting',10-19 08:55:39.157 22836 22855 I ReactNativeJS:      end_time: '2019-10-19T05:55:39.155Z',10-19 08:55:39.157 22836 22855 I ReactNativeJS:      last_seq: 0 } }

Which works fine in debug on same device.How?

How to fix TypeError: Network request failed at EventTarget.xhr.onerror (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false

$
0
0

TypeError: Network request failed at EventTarget.xhr.onerror (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false

I'm using fetch API post call from react native app to chargebee Node tab for creating new customer and getting JSON response error message on android.

The error message

The code:

   chargebee.configure({"{site}",api_key : "{site_api_key}"})             chargebee.customer.create({             first_name : "John",             last_name : "Doe",             email : "john@test.com",             locale : "fr-CA",             billing_address : {             first_name : "John",             last_name : "Doe",             line1 : "PO Box 9999",             city : "Walnut",             state : "California",             zip : "91789",             country : "US"             }             }).request(function(error,result) {             if(error){             //handle error             console.log(error);             }else{              console.log(result);             var customer = result.customer;             var card = result.card;             }             });

The error in image is coming from handle error console.log(error);

Expo sdk36 react-native application trying to load a website with react-native-webview

$
0
0

Within my expo SDK36 project, I want to display a website in a web view using https://github.com/react-native-community/react-native-webview

This is the expo documentation https://docs.expo.io/versions/latest/sdk/webview/

I did expo install react-native-webview

Basically, my code look like this live demo : https://snack.expo.io/@kopax/sponaneous-waffle

Within the snack, it work on android and ios, but with real redevice, I keep having blank pages.

Any idea how I can solve this and display a website using a webview?

I also tried:

<WebView      style={{        flex: 1,        width: '100%',        height: '100%',        alignSelf: 'stretch',      }}      source={{        uri: 'https://www.lemonde.fr',      }}      startInLoadingState={true}      scalesPageToFit={true}      javaScriptEnabled={true}      domStorageEnabled={true}      {...props}/>

It's always an empty View.

How can I fix it?


Amazon Pay Integration with React Native

$
0
0

I need to integrate Amazon pay with react native app. But I could not find any solution. Is there any way to implement?

React Native: JSON value '' of type NSNULL cannot be converted to a valid URL

$
0
0

For the app that I am currently working on, I am using the following snippets of code to access the device photo gallery to then replace a default image displayed on the screen. I have the default value set to null which should be fine? This works fine on Android however I receive this error on iPhone devices.

Any ideas on how to fix it? (Avatar is what the image is)

state = {user: {  name: "",  email: "",  password: "",  //Fix it!  //Works on Android for some reason? But fix the emulator error  avatar: null},errorMessage: null

};

handlePickAvatar = async () => {UserPermissions.getCameraPermission()let result = await ImagePicker.launchImageLibraryAsync({  mediaTypes: ImagePicker.MediaTypeOptions.Images,  allowsEditing: true,  aspect: [4, 3]})if(!result.cancelled){  this.setState({user: { ...this.state.user, avatar: result.uri} });}

};

<View style={{position: "absolute", top: 45, alignItems: "center", width: "100%"}}><Text style={styles.greeting}>{'Hello!\nSign up to get started.'}</Text><TouchableOpacity style={styles.avatarPlaceholder} onPress={this.handlePickAvatar}><Image source={{uri:this.state.user.avatar}} style={styles.avatar}/><Ionicons         name="ios-add"        size={40}         color="#00d589"        style={{marginTop:6, marginLeft:2}}></Ionicons></TouchableOpacity></View>

I only seem to receive the JSON value of type NSNULL cannot be converted to a valid URL error on the iPhone emulator due to the state that "avatar" is set to null. I followed this Youtube tutorial exactly up to 4:30 https://www.youtube.com/watch?v=UNFDILca9M8

Is there something I am missing? I have all the packages installed and can't see what the issue is.

custom callout image not rendering in android api level 26 react-native-maps?

$
0
0

I am using react-native-maps 0.23.0 version. I am facing image rendering issue in custom callout in android in API level 26 and above. It's working in API 23 but according to google new policy target API level at least 26 to submit apps on play store that's why I can not use API level 23.

<MapView.Callout   tooltip={true}  >   {this.state.isMarkerCallout === true &&  <View style=  {{width:Dimensions.get('window').width-40,height:110,backgroundColor:WHITE_COLOR,borderRadius:20,borderColor:BLACK_COLOR,borderWidth:1,alignItems:'center',marginLeft:20,flexDirection:'column'}}><View style={{flexDirection:'row',backgroundColor:'white',height:80,marginTop:0,borderRadius:20}}><View style={{backgroundColor:WHITE_COLOR,width:Dimensions.get('window').width/2-20,borderRadius:20}}><Text style={{marginLeft:15,lineHeight:12,textAlign:'left',fontSize:12,fontFamily:FONT_FAMILY,fontWeight:'bold',marginTop:10}}> <Text>{marker.title}</Text></Text></View><View style={{backgroundColor:'white',width:Dimensions.get('window').width/2-22,borderRadius:20}}><TouchableOpacity  style={{backgroundColor:'white',alignItems:'center',marginTop:10}}>        {marker.type === "fixcar"?<TouchableOpacity onPress={this.openCarWebsite}><Image   source={require('../images/WCC.png') }  style = {{ width: 112, height: 25,borderRadius:3, resizeMode: "cover", zIndex: 10}}/></TouchableOpacity>          :<TouchableOpacity style={{backgroundColor:LIGHTGRAY_COLOR}} onPress={this.openWebsite}><Image  source={require('../images/spin.png')}  style = {{ width: 112, height: 56,borderRadius:3}}/></TouchableOpacity>          }<Text style={{lineHeight:15,marginLeft:10,textAlign:'center',fontSize:10,fontFamily:FONT_FAMILY,marginTop:10}}> Please visit our website{"\n"}for more details.</Text></TouchableOpacity></View></View><View style={{width:30,height:30,alignItems:'center',marginTop:1}}><TouchableOpacity  onPress={this.showNearLocationPopup}><Image  source={require('../images/Arrow-Up-icon.png')}  style = {{ width: 30, height: 30}}/></TouchableOpacity></View> </View>        }  </MapView.Callout>

Image not showing in callout in android but in iOS is working fine.

React Native "undefined is not an Object"

$
0
0

Code:

import { ImageBackground,StyleSheet } from 'react-native';function WelcomeScreen(props) {    return (<ImageBackground        style={styles.background}         source={require("../assets/background.jpg")}></ImageBackground>    );  }const styles = StyleSheet.create({    background:{        flex: 1    }});export default WelcomeScreen;

Output:

Error message from android phone

Any ideas. I have been stuck for a few hours now, please help

How do I resolve 'You need to have MainApplication in your project' in React native run-android

$
0
0

I ejected from expo, and trying react-native run-android, I'm getting this error;

FAILURE: Build failed with an exception.* Where:Script 'C:\Users\simil\OneDrive\Documents\Codes\react-native\expo\doc\node_modules\react-native-unimodules\gradle.groovy' line: 81* What went wrong:A problem occurred evaluating project ':app'.> You need to have MainApplication in your project* 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 14s

This is my MainActivity path

MyApp\android\app\src\main\java\com\com.example.eg\MainActivity.java

Viewing all 28474 articles
Browse latest View live


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