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

React Native android camera2 aspect ratio issue

$
0
0

I have created a library (check this for more information) for Android for Android Camera2 functionality in Android all is working good, but in the aspect ratio issue with full screen camera.

Please Check below image how it looks in preview and the real picture (Only preview has the issue not the real picture after capturing)

Captured image horizontal:

enter image description here

Preview image horizontal:

enter image description here

Captured image vertical:

enter image description here

Preview image vertical:

enter image description here

Google sample of Camera2 API have similar issue and resolved here.

But same code not working in my react native library code. May be I am using one code for image and video both and add additional code for video capture.


Unable to debug react-native app using debugger-ui

$
0
0

May be this query is solved long back but I'm unable to find the solution

Trying to debug react-native app with the help of http://localhost:8081/debugger-ui/. For this i've deployed the app in android emulator, clicked ctrl + m | chose Debug option but ended up with below error

Invariant Violation: Calling synchronous methods on native modules is not supported in Chrome, Consider providing alternative methods to expose this method in debug mode, e.g. by exposing constants ahead-of-time, Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)

enter image description here

To solve this, i gone through link1, link2, link3, link4 but unable to solve. Can anyone help in this.

React Native: Background job not executing on some Android OS versions?

$
0
0

I have tried to integrate the following npm packages regarding sending Push Notification:

  • react-native-background-job
  • react-native-background-fetch
  • react-native-background-task

For Push Notifications:

  • react-native-push-notification

The Notifications work fine in the foreground. The problem is that the background service does not run in certain Android OS. Take a look at the following code:

// Importsimport BackgroundJob from 'react-native-background-job';..// Define the Jobconst backgroundJob = {  jobKey: "PNJob",  job = () => {  console.log("Running in Background!");  // Execute Push Notification  }};// Register Background JobBackgroundJob.register(backgroundJob);var backgroundSchedule = {  jobKey: "PNJob",  period: 1800000, // Interval every half Hour (in ms)  timeout: 5000,  requiresCharging: false,  override: true,  persist: true,  // allowExecutionInForeground: true,  allowWhileIdle: true,  requiresDeviceIdle: false,  // exact: true};// ***  Schedule  ***BackgroundJob.schedule(backgroundSchedule)  .then(() => console.log("The Job has been scheduled!"))  .catch(() => console.log("There was a problem in scheduling"));

I've tried debugging several possible issues but there is still some underlying issue I can not place.

React Native - Android - The header moves up when the keyboard opens on a TextInput

$
0
0

I have a long form, longer than a screen height, so it needs a scroll view.When focusing on a TextInput, I want the content to move so it's not behind the keyboard.

I managed to handle this on iOS using react-native-keyboard-aware-scroll-view package.But for android, I can't get over the native behavior, which is almost ok, the problem is that the header gets out of the screen.

Please note that I'm using expo, so for android the windowSoftInputMode is set to adjustPan in AndroidManifest.xml and I can't change it.

Look here for the visual on iOS and Android

  • I tried to set enableOnAndroid:true as a prop of react-native-keyboard-aware-scroll-view but nothing changes.

  • I tried many, many things with ```KeyboardAvoidingView````

Here is my code :

import React from 'react'import { View, Text, TextInput, ScrollView, StyleSheet } from 'react-native'import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view'const TextInputPage = () => {  const textInputArray = [1, 2, 3, 4, 5, 6, 7, 8]  return (<View style={styles.screen}><View style={styles.header}><Text bold={true}>HEADER</Text></View><KeyboardAwareScrollView        style={styles.container}        extraScrollHeight={85}        enableOnAndroid={true}><ScrollView contentContainerStyle={styles.content}>          {textInputArray.map((inputIndex) => (<View key={inputIndex} style={{ ...styles.item }}><View style={styles.label}><Text style={styles.labelText}>Text Input {inputIndex}</Text></View><TextInput                style={styles.textInput}                multiline={true}                value={'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.'                }              /></View>          ))}</ScrollView></KeyboardAwareScrollView></View>  )}const styles = StyleSheet.create({  screen: {    flex: 1,  },  header: {    height: 98,    justifyContent: 'center',    alignItems: 'center',    backgroundColor: 'cornflowerblue',    paddingTop: 44,    zIndex: 2,  },  container: {    flex: 1,    paddingTop: 10,    paddingHorizontal: 10,  },  content: {    //flex: 1,    //justifyContent: 'flex-end',  },  item: {    marginBottom: 20,  },  label: {    alignItems: 'center',    marginBottom: 5,  },  labelText: {    fontSize: 12,    color: 'deepskyblue',  },  textInput: {    borderColor: 'grey',    borderWidth: 1,    padding: 5,  },})export default TextInputPage
  • I tried to setup a snack to share but it doesn't behave in the same way, so it is useless

react-native android: security settings are blocking Metro server

$
0
0

I am trying to set up Admob mediation with Facebook Audience Network. The tutorial herehttps://developers.facebook.com/docs/audience-network/android-network-security-config

suggest that I modify my Android security config with this:

<?xml version="1.0" encoding="utf-8"?><network-security-config>...<domain-config cleartextTrafficPermitted="true"><domain includeSubdomains="true">127.0.0.1</domain></domain-config>...</network-security-config>

However when I do this, my app stops working in dev mode:

The Metro server is running. I am perfectly able to access http://127.0.0.1:8081 from my mobile Chrome. It's just that this security setting blocks my app from fetching the JS bundle from this address.

Currently I am disabling this security config while developing the app and enabling it again when building the production bundle, but this is not sustainable long-term.

How do I work around that?

Android app built for release still trying to connect to localhost:8081

$
0
0

I'm trying to get an alpha build of my React Native app on my Android phone, but when I open it, it immediately crashes. Fortunately, it's instrumented so I can see that the errors are all because it's still trying to connect to the metro server, which I would expect from a debug build, but I can't figure out how to prevent these calls in a release build. Here are the errors:

Cannot connect to host http://localhost:8081/inspector/deviceCannot connect to host http://localhost:8081/message

Steps taken:

  • I'm generating a signed APK via Android Studio, then sending it to myself and installing on my phone.
  • Even though I choose a release build in the "Generate signed Bundle or APK" dialog, I also set the default build variant to "release". This oddly changed the connection attempts from "10.0.0.22" to "localhost" but didn't fix my problem.
  • I've tried cleaning the project.
  • I've searched the project for any references to localhost or 10.0.0.22 and found nothing that should relate to an Android build.
  • Removed Expo updates metadata from AndroidManifest.xml (e.g., expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH).
  • Built an APK in a different project and installed on my phone—it worked as expected.

Possibly pertinent information:

  • I began this as an Expo project and ejected a few weeks ago, but Expo seems to have left some cruft behind.

----------- UPDATE July 23 ------------

After a few changes, I've moved onto an error where the 3rd party auth screen won't load. Here's what changed:

  • Ran code analyzer in Android Studio and removed some permissions that shouldn't be there: MANAGE_DOCUMENTS, WRITE_SETTINGS, USE_FINGERPRINT
  • Also auto-fixed an error where the superclass wasn't called (I forget the exact details and it doesn't appear to be in a file that's under source control because there's nothing in my diff)
  • Branched code from a commit a few days ago, before I added launcher icons and a 3rd party monitoring tool.

I still need to debug authentication, but it looks like I've probably moved on to a new issue. I'll still do some digging to see if I can narrow in on what actually caused the issue.

----------- UPDATE Later on July 23 ------------

All is well now, though I don't know what made the difference. Builds got into a strange state after my last update, and I ended up deleting my .gradle folder after reading this. I also updated gradle, and my theory at this point is that the upgrade combined with deleting that folder was the actual fix.

I've re-installed the monitoring software and didn't have any trouble.

What is the best way to manage shared dependencies in Android Studio?

$
0
0

I have a react-native project which has several modules. One of my module "@react-native-firebase_admob" uses "com.google.firebase:firebase-ads" as dependency.

What I'm trying to do here is to write my own react-native module which uses react native bridge to enable Admob Native Advance Ads Unit. And they might use shared dependency.

What is the best way to implement this? I'm new to android development, but this project is finished on ios using react native.

React Native Release build application crashing on Android

$
0
0

I have an application that I built for Android TV (API 28) and it works great on an emulator on debugging. But I built the release version and when I first launch the application, it crashed. And it then launches fine on the second try. It sometimes takes a third try. So I logcat while the app crashed and here is the result.

com.iptv is the application name and the PID was 8478.

Process: com.iptv, PID: 847808-07 00:51:19.919  8478  8478 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.iptv/com.iptv.MainActivity}: androidx.fragment.app.Fragment$InstantiationException: Unable to instantiate fragment com.swmansion.rnscreens.ScreenFragment: calling Fragment constructor caused an exception08-07 00:51:19.919  8478  8478 E AndroidRuntime:    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)08-07 00:51:19.919  8478  8478 E AndroidRuntime:    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)08-07 00:51:19.919  8478  8478 E AndroidRuntime:    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)08-07 00:51:19.919  8478  8478 E AndroidRuntime:    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)08-07 00:51:19.919  8478  8478 E AndroidRuntime:    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)08-07 00:51:19.919  8478  8478 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)08-07 00:51:19.919  8478  8478 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:106)08-07 00:51:19.919  8478  8478 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:193)08-07 00:51:19.919  8478  8478 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:6669)08-07 00:51:19.919  8478  8478 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)08-07 00:51:19.919  8478  8478 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)08-07 00:51:19.919  8478  8478 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)08-07 00:51:19.919  8478  8478 E AndroidRuntime: Caused by: androidx.fragment.app.Fragment$InstantiationException: Unable to instantiate fragment com.swmansion.rnscreens.ScreenFragment: calling Fragment constructor caused an exception08-07 00:51:19.919  8478  8478 E AndroidRuntime:    at androidx.fragment.app.Fragment.instantiate(Fragment.java:566)08-07 00:51:19.919  8478  8478 E AndroidRuntime:    at androidx.fragment.app.FragmentContainer.instantiate(FragmentContainer.java:57)08-07 00:51:19.919  8478  8478 E AndroidRuntime:    at androidx.fragment.app.FragmentManager$3.instantiate(FragmentManager.java:390)08-07 00:51:19.919  8478  8478 E AndroidRuntime:    at androidx.fragment.app.FragmentStateManager.<init>(FragmentStateManager.java:74)08-07 00:51:19.919  8478  8478 E AndroidRuntime:    at androidx.fragment.app.FragmentManager.restoreSaveState(FragmentManager.java:2454)08-07 00:51:19.919  8478  8478 E AndroidRuntime:    at androidx.fragment.app.FragmentController.restoreSaveState(FragmentController.java:196)08-07 00:51:19.919  8478  8478 E AndroidRuntime:    at androidx.fragment.app.FragmentActivity.onCreate(FragmentActivity.java:287)08-07 00:51:19.919  8478  8478 E AndroidRuntime:    at androidx.appcompat.app.AppCompatActivity.onCreate(AppCompatActivity.java:106)08-07 00:51:19.919  8478  8478 E AndroidRuntime:    at com.facebook.react.ReactActivity.onCreate(ReactActivity.java:43)08-07 00:51:19.919  8478  8478 E AndroidRuntime:    at android.app.Activity.performCreate(Activity.java:7136)08-07 00:51:19.919  8478  8478 E AndroidRuntime:    at android.app.Activity.performCreate(Activity.java:7127)08-07 00:51:19.919  8478  8478 E AndroidRuntime:    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)08-07 00:51:19.919  8478  8478 E AndroidRuntime:    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)08-07 00:51:19.919  8478  8478 E AndroidRuntime:    ... 11 more08-07 00:51:19.919  8478  8478 E AndroidRuntime: Caused by: java.lang.reflect.InvocationTargetException08-07 00:51:19.919  8478  8478 E AndroidRuntime:    at java.lang.reflect.Constructor.newInstance0(Native Method)08-07 00:51:19.919  8478  8478 E AndroidRuntime:    at java.lang.reflect.Constructor.newInstance(Constructor.java:343)08-07 00:51:19.919  8478  8478 E AndroidRuntime:    at androidx.fragment.app.Fragment.instantiate(Fragment.java:548)08-07 00:51:19.919  8478  8478 E AndroidRuntime:    ... 23 more08-07 00:51:19.919  8478  8478 E AndroidRuntime: Caused by: java.lang.IllegalStateException: Screen fragments should never be restored08-07 00:51:19.919  8478  8478 E AndroidRuntime:    at com.swmansion.rnscreens.ScreenFragment.<init>(ScreenFragment.java:36)08-07 00:51:19.919  8478  8478 E AndroidRuntime:    ... 26 more08-07 00:51:19.923  3499  7669 W ActivityManager:   Force finishing activity com.iptv/.MainActivity08-07 00:51:19.931  8478  8478 I Process : Sending signal. PID: 8478 SIG: 908-07 00:51:19.958  3499  3514 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.stats.service.DropBoxEntryAddedReceiver08-07 00:51:19.958  3499  3514 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver08-07 00:51:19.990  3219  3219 I Zygote  : Process 8478 exited due to signal (9)08-07 00:51:19.991  3499  7669 I ActivityManager: Process com.iptv (pid 8478) has died: vis  +99TOP 08-07 00:51:19.993  3499  3517 W libprocessgroup: kill(-8478, 9) failed: No such process

I have already read and tried this solution. But it still crashes and this is the new log:

Process: com.iptv, PID: 996308-07 01:10:27.608  9963  9963 E AndroidRuntime: java.lang.IllegalStateException: Fragment already added: ScreenFragment{25288ab} (83e0bd68-d279-4447-8230-7298073e391b) id=0x55}08-07 01:10:27.608  9963  9963 E AndroidRuntime:    at androidx.fragment.app.FragmentStore.addFragment(FragmentStore.java:67)08-07 01:10:27.608  9963  9963 E AndroidRuntime:    at androidx.fragment.app.FragmentManager.addFragment(FragmentManager.java:1565)08-07 01:10:27.608  9963  9963 E AndroidRuntime:    at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:405)08-07 01:10:27.608  9963  9963 E AndroidRuntime:    at androidx.fragment.app.FragmentManager.executeOps(FragmentManager.java:2169)08-07 01:10:27.608  9963  9963 E AndroidRuntime:    at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1992)08-07 01:10:27.608  9963  9963 E AndroidRuntime:    at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1953)08-07 01:10:27.608  9963  9963 E AndroidRuntime:    at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1849)08-07 01:10:27.608  9963  9963 E AndroidRuntime:    at androidx.fragment.app.FragmentManager$4.run(FragmentManager.java:413)08-07 01:10:27.608  9963  9963 E AndroidRuntime:    at android.os.Handler.handleCallback(Handler.java:873)08-07 01:10:27.608  9963  9963 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:99)08-07 01:10:27.608  9963  9963 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:193)08-07 01:10:27.608  9963  9963 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:6669)08-07 01:10:27.608  9963  9963 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)08-07 01:10:27.608  9963  9963 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)08-07 01:10:27.608  9963  9963 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)08-07 01:10:27.614  3499  4044 W ActivityManager:   Force finishing activity com.iptv/.MainActivity08-07 01:10:27.627  9963  9963 I Process : Sending signal. PID: 9963 SIG: 908-07 01:10:27.636  3499  3514 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.stats.service.DropBoxEntryAddedReceiver08-07 01:10:27.636  3499  3514 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver08-07 01:10:27.724  3499  3630 W InputDispatcher: channel 'e4aa437 com.iptv/com.iptv.MainActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x908-07 01:10:27.724  3499  3630 E InputDispatcher: channel 'e4aa437 com.iptv/com.iptv.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!08-07 01:10:27.735  3499  3858 D ConnectivityService: ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ TRACK_DEFAULT id=51, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED Unwanted:  Uid: 10072] ], android.os.BinderProxy@22118f5)08-07 01:10:27.736  3499  3858 I WindowManager: WIN DEATH: Window{e4aa437 u0 com.iptv/com.iptv.MainActivity}08-07 01:10:27.736  3499  3858 W InputDispatcher: Attempted to unregister already unregistered input channel 'e4aa437 com.iptv/com.iptv.MainActivity (server)'08-07 01:10:27.737  3499  3722 D ConnectivityService: releasing NetworkRequest [ TRACK_DEFAULT id=51, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED Unwanted:  Uid: 10072] ] (release request)08-07 01:10:27.738  3219  3219 I Zygote  : Process 9963 exited due to signal (9)08-07 01:10:27.738  3499  3870 I ActivityManager: Process com.iptv (pid 9963) has died: vis  TOP 08-07 01:10:27.739  3499  3517 W libprocessgroup: kill(-9963, 9) failed: No such process

This is where I am stuck at now. I am not sure where I am with this right now. Thanks in Advance!


StrictMode policy violation: android.os.strictmode.NonSdkApiUsedViolation React Native

$
0
0

What could be a quick solution to fix below warning raised at Google Play Console below, please?

I used "react-native": "~0.61.4" to build the app.

StrictMode policy violation: android.os.strictmode.NonSdkApiUsedViolation: Landroid/widget/TextView;->mCursorDrawableRes:Iat android.os.StrictMode.lambda$static$1(StrictMode.java:407)at android.os.-$$Lambda$StrictMode$lu9ekkHJ2HMz0jd3F8K8MnhenxQ.accept(Unknown Source:2)at java.lang.Class.getDeclaredField(Native Method)at com.facebook.react.views.textinput.ReactTextInputManager.setCursorColor(ReactTextInputManager.java:402)at com.facebook.react.views.textinput.ReactTextInputManager.setSelectionColor(ReactTextInputManager.java:391)at java.lang.reflect.Method.invoke(Native Method)at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateViewProp(ViewManagersPropertyCache.java:83)at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackViewManagerSetter.setProperty(ViewManagerPropertyUpdater.java:134)at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:54)at com.facebook.react.uimanager.ViewManager.updateProperties(ViewManager.java:48)at com.facebook.react.uimanager.NativeViewHierarchyManager.createView(NativeViewHierarchyManager.java:278)at com.facebook.react.uimanager.UIViewOperationQueue$CreateViewOperation.execute(UIViewOperationQueue.java:179)at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:773)at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:888)at com.facebook.react.uimanager.UIViewOperationQueue.access$2200(UIViewOperationQueue.java:42)at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:948)at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:28)at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:174)at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:84)at android.view.Choreographer$CallbackRecord.run(Choreographer.java:965)at android.view.Choreographer.doCallbacks(Choreographer.java:791)at android.view.Choreographer.doFrame(Choreographer.java:722)at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:952)at android.os.Handler.handleCallback(Handler.java:883)at android.os.Handler.dispatchMessage(Handler.java:100)at androidx.test.espresso.base.Interrogator.a(Interrogator.java:31)at androidx.test.espresso.base.UiControllerImpl.a(UiControllerImpl.java:130)at androidx.test.espresso.base.UiControllerImpl.a(UiControllerImpl.java:124)at androidx.test.espresso.base.UiControllerImpl.a(UiControllerImpl.java:100)at androidx.test.espresso.action.Tap$1.sendTap(Tap.java:5)at androidx.test.espresso.action.GeneralClickAction.perform(GeneralClickAction.java:9)at androidx.test.espresso.ViewInteraction$SingleExecutionViewAction.perform(ViewInteraction.java:6)at androidx.test.espresso.ViewInteraction.a(Unknown Source:140)at androidx.test.espresso.ViewInteraction$1.call(Unknown Source:4)at java.util.concurrent.FutureTask.run(FutureTask.java:266)at android.os.Handler.handleCallback(Handler.java:883)at android.os.Handler.dispatchMessage(Handler.java:100)at android.os.Looper.loop(Looper.java:214)at android.app.ActivityThread.main(ActivityThread.java:7356)at java.lang.reflect.Method.invoke(Native Method)at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

thanks

Failed to install the app. Make sure you have the Android development environment set up

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?

Image not showing up in Build Apk in React-native

$
0
0

I have fetched image URL in my react-native app. The image is showing in locally ( Emulator , Phone) but it is not showing up in build apk.

Sample Image URL:https://www.hasbro.com/common/productimages/en_US/FF4E4CAD803A43EB8CF60C88DD60CAB9/cd5a2bbe53486fc24df21f8d5c039960d9f90401.jpg

Using React-native-paper card component : https://callstack.github.io/react-native-paper/card.html

Sample code:

<Card style={styles.Item}><Card.Content><Card.Cover    source={{ uri: row.imageUrl }}/></Card.Content></Card>

Emulator View
enter image description here




Installed APK View

enter image description here

Thanks.

After releasing react-native app on playstore how can use code to debug in local

$
0
0

I released a react native app to playstore now after publishing it I want to debug code in my local computer to add more fiture so that i can add more features in next update. But the problem is when i run code npx react-native run-android it does not work in local it give me some error.

How can fix this.

Cannot run android in react native due to "Could not find com.mg.RxCustomizedImagePicker:fileprovider:1.0.0"

$
0
0

This is my first time running react native Andriod code, IOS code runs fine, but when I try to run android code, I got this error, what do you suggest I should do?

$ react-native run-androidyarn run v1.22.4$ react-native run-androidwarn The following packages use deprecated "rnpm" config that will stop working from next release:  - native-base: https://github.com/GeekyAnts/NativeBase#readmePlease notify their maintainers about it. You can find more details at https://github.com/react-native-community/cli/blob/master/docs/configuration.md#migration-guide.info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.Jetifier found 1113 file(s) to forward-jetify. Using 12 workers...info JS server already running.info Installing the app...FAILURE: Build failed with an exception.* What went wrong:Could not determine the dependencies of task ':app:preDebugBuild'.> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.> Could not find com.mg.RxCustomizedImagePicker:fileprovider:1.0.0.     Searched in the following locations:       - file:/Users/XXXlaptop/.m2/repository/com/mg/RxCustomizedImagePicker/fileprovider/1.0.0/fileprovider-1.0.0.pom       - file:/Users/XXXlaptop/.m2/repository/com/mg/RxCustomizedImagePicker/fileprovider/1.0.0/fileprovider-1.0.0.jar       - file:/Users/XXXlaptop/Documents/Code/uf-mobile/node_modules/react-native/android/com/mg/RxCustomizedImagePicker/fileprovider/1.0.0/fileprovider-1.0.0.pom       - file:/Users/XXXlaptop/Documents/Code/uf-mobile/node_modules/react-native/android/com/mg/RxCustomizedImagePicker/fileprovider/1.0.0/fileprovider-1.0.0.jar       - file:/Users/XXXlaptop/Documents/Code/uf-mobile/node_modules/jsc-android/dist/com/mg/RxCustomizedImagePicker/fileprovider/1.0.0/fileprovider-1.0.0.pom       - file:/Users/XXXlaptop/Documents/Code/uf-mobile/node_modules/jsc-android/dist/com/mg/RxCustomizedImagePicker/fileprovider/1.0.0/fileprovider-1.0.0.jar

expo Linking from app to anther apps not working in build apk


React Native(Android) Scan QRCode

$
0
0

I wanna write a native module for to scan barcode but it too hard for me to figure out a way to handle the result without adding a method to the MainActivity. It's not a good idea to modify the MainActivity such heavily because it's no easy job for application developers who writes javascript to use the module. For example, if I use ZXing Android Embedded: https://github.com/journeyapps/zxing-android-embedded, I have to add a method to MainActivity to handle the result.

@Overrideprotected void onActivityResult(int requestCode, int resultCode, Intent data) {    IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);    if(result != null) {        if(result.getContents() == null) {            Toast.makeText(this, "Cancelled", Toast.LENGTH_LONG).show();        } else {            Toast.makeText(this, "Scanned: "+ result.getContents(), Toast.LENGTH_LONG).show();        }    } else {        // This is important, otherwise the result will not be passed to the fragment        super.onActivityResult(requestCode, resultCode, data);    }}

That makes an issue that any one who uses this module has to modify their MainActivity, which means the module is hard to use. So, any ideas to work it out?

How To Send & Receive Data Over Wifi Without Internet In React-Native

$
0
0

I am developing a game on React-Native that works completely offline without needing internet connection,

The game will be multiplayer 1vs1 game, and players will join via Wifi Hotspot (also known as wifi Direct) The game will also allow users to chat with eachother

and this all should be done without internet by just using the wifi..

I have tried "React-Native-Wifi-Hotspot" but there is no documentation about how to send and receive data

I want to send and receive objects/arrays over wifi hotspot between 2 connected devices. P2P

I have also readed about react-native-wifi-p2p library but it's documentation says that we need a local server or something i am really not sure about how to do that.

React Native Navigation (6.3.2) - How to hide top statusBar completely in Android (see screenshot)

$
0
0

I am trying to build a new react-native application using react-native-navigation. earlier we have an application which is using v2.x of react-native-navigation and I am able to work with the navigation properly, where the notch and statusBar was properly getting handled by the navigation. But with version 6.x i am not able to hide the statusBar, or you can say draw behind the statusBar. See the screenshot below with old and new app.

here is the code snippet from the MainActivity (same in both the applications (old and new)).

public class MainActivity extends NavigationActivity {    @Override    protected void onCreate(@Nullable Bundle savedInstanceState) {        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {            WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();            layoutParams.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;            getWindow().setAttributes(layoutParams);            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);            getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);        }        super.onCreate(savedInstanceState);    }}

index.js

/** * @format */import App from './App';

App.js

/** * Sample React Native App * https://github.com/facebook/react-native * * @format * @flow */import { Navigation } from 'react-native-navigation';import { WelcomePage } from './src/screens/welcome.page';import { StatusBar } from 'react-native';Navigation.registerComponent(`Pages.WelcomePage`, () => WelcomePage);StatusBar.setHidden(true);Navigation.events().registerAppLaunchedListener(async () => {  Navigation.setDefaultOptions({    popGesture: false,    topBar: {      topMargin: 0,      visible: false,      drawBehind: true,      animate: false,      height: 0    },    layout: {      orientation: 'portrait',      backgroundColor: 'white',      componentBackgroundColor: 'white',      fitSystemWindows: true,      topMargin: 0,    },    statusBar: {      drawBehind: true,      visible: false,      backgroundColor: 'transparent',      style: 'light'    },  });  return Navigation.setRoot({    root: {      component: {        name: 'Pages.WelcomePage',      },    },  });});

welcome.page.js

import React, { Component } from 'react';import { StatusBar, Text, View } from 'react-native';class WelcomePage extends Component {  constructor(props) {    super(props);  }  render() {    return (<><StatusBar hidden={true}/><View style={{backgroundColor: '#556677', justifyContent: 'center', alignItems: 'center', flex: 1}}><Text>Hello World</Text></View></>    );  }}export { WelcomePage };

Device with Notch (New Application) RNN v6.x

screen with notch

Device with Notch (Old Application) RNN v2.x

screen with notch old app

Device without Notch (New Application) RNN v6.x

enter image description here

Device without Notch (Old Application) RNN v6.x

enter image description here

please help me understand what is changed between these two versions in terms of layout handling and how I can achieve, what i was able to achieve with the older version of react-native-navigation.

How to remove black overlay on status bar on android with React Native

$
0
0

I'm learning React Native (without React knowledge), but my problem is the status bar always get a translucent black background and I can remove it. I tried every stackoverflow answer, and even React Native and Expo documentation. But nothing...

Here is my problem:enter image description here

The status bar has a white background supposedly, and get this grey overlay, that is what I want to remove.

Here is my code:

render() {    return (<View><StatusBar background="white" /><Button title="Sign in!" onPress={this._signInAsync} /></View>    );}

I even tried this, on app.js

"androidStatusBar": {"backgroundColor": "#C2185B"},

I'm starting to think, this is related to Expo.

How to set responsive logo in android splash screen in react-native-splash-screen?

$
0
0

I'm trying to make the logo in android splash screen scale correctly on different android devices.

I followed the instruction of npm react-native-splash-screen.

The splash screen logo scales well on iOS, but on Android it stretches out of screen like the following screenshot.

enter image description here

launch_screen.xml in layout folder:

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="vertical" android:layout_width="match_parent"    android:layout_height="match_parent"><ImageView android:layout_width="match_parent"        android:layout_height="match_parent"        android:src="@drawable/launch_screen"        android:scaleType="centerCrop" /></RelativeLayout>

Android filter:

enter image description here

Project filter:

enter image description here

I also tried to change to <FrameLayout> and add <ImageView> with a scaleType in the launch_screen.xml, but the logo still remain stretched.

<?xml version="1.0" encoding="utf-8"?><FrameLayout  xmlns:android="http://schemas.android.com/apk/res/android"  android:layout_width="match_parent"  android:layout_height="match_parent"  android:orientation="vertical"><ImageView     android:src="@drawable/launch_screen"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:scaleType="centerCrop"></ImageView></FrameLayout>
Viewing all 29579 articles
Browse latest View live