react native can't connect to android device - javascript

I'm just start learning react native and I'm trying to use expo,
after I created my app using expo and try to connect it to expo app on android device
I got this error
Uncaught Error:java.net.socketTimeoutException: failed to connect to /172.28.118.45 (port 19000) from /192.168.1.3 (port 38238) after 10000ms
I'm using wsl2 on windows and I think the problem could be, there's no bridge between wsl2 ip and windows ip but I couldn't find solution for this issue

This happend me before, but using only react native in WSL (not with expo) and you're right, the WSL cannot reach your android device.
I find some solutions but none of this work for me, you can try it maybe with expo is different.
Check https://localcoder.org/running-react-native-in-wsl-with-the-emulator-running-directly-in-windows

Related

Expo MediaLibrary.getAssetsAsync() crashes the app on android

I'm using expo managed flow to develop my app and I'm trying to use camera roll in order to show some images.
I'm using expo's MediaLibrary and once I grant access to the camera roll via MediaLibrary.getPermissionsAsync() then, I try to call MediaLibrary.getAssetsAsync() but my android crashes. Everything works on IOS.
Note: when I add MediaLibrary.getAssetsAsync({ after: "" }) it does not crash but I've got an error where it says that "after key should be valid ID"...
Anyone knows what's the issue here?
I had the same inssue, I solved by doing this:
=>Run expo upgrade in your project directory (requires the latest version of expo-cli, you can update with npm i -g expo-cli).
They corrected in Expo SDK 39~40, mine was 38

Network connection problem in react native

I am trying to run react native app on android using expo cli. But getting this network connection error.network connection problem
Image is available on the above link.
in expo, if you are in development mode, both mobile and computer should be connected to the same wifi. so it can connect to your localhost.

Send get request to local api from react native mobile project

I am developing a mobile app using react native, SQL Server and NodeJS.
I got an API in my localhost. I run my application on an emulator and try to get request from API. But I got this message in catch(error):
[Error:Network Error].
Can somebody help me please.
Actually you are unable to access the local development server because port hasn't been forwarded by ADB yet. Try to replace the "localhost" with your machine IPv4 address and check else you can also try map your local server port just like React Native does.
To forward a port using ADB run the following command in your terminal
adb reverse tcp:8163 tcp:8163 remember this only works if you are using Android 6.0+.

Why can't I get my android emulator to connect to my local server?

I am developing an app using React Native and made my server with node.js. For websocket connections I use socket.io
The thing is if I install the app to my android device and my android emulator, only my android device can connect to my local server. They both run the same code. I checked and the emulator has an active internet connection. Weird thing is I have an other app inside the emulator that connects to the same server without any problems using the same connection methods.
Do you guys have any idea why there is a problem like this?
Android emulators have a built in IP to use when connecting to something on your local machine.
If the socket is running on localhost, you want to connect to using the IP address 10.0.2.2 in the emulator.

Running Meteor mobile app on physical Android device

I'm having an hard time trying to run my Meteor app on my Android device (LG G2).
I googled for answer and didn't find anything like what I encounter. I followed the instuction and everything went fine, added the Android platform to my project and ran it with meteor run android-device. The device LG G2 is plugged with a USB cable to the machine I'm building and running the app with, and the device has USB debugging enabled. Everything seem to be fine, my terminal indicates:
Started proxy.
Started app on Android Device.
I20150530-16:38:11.280(3)? - waiting for device -
Started MongoDB.
Started your app.
App running at: http://localhost:3000/
No error indication, nothing suspicous, but the app doesn't come up on the device. Nothing happens. Anyone has a clue? I tried to give my own IP and port to the command without a change.
You need to set the USB connexion on your android device as "camera". Whith my s4 mini I had the same symptoms and that was the solution.
I'll list what I've done to solve it, because it's a mix of all the solutions I got here.
I'm using Ubuntu, and LG G2 as device.
I created the /etc/udev/rules.d/51-android.rules. file with
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="1004", GROUP="plugdev" inside. (Detailed instructions here on step 3: http://developer.android.com/tools/device.html#setting-up, thank you #ChristianFritz). Pay attention that "1004" is the vendor
ID of LG.
I realised that for some reason I didn't have the ADB on my machine so I couldn't use adb devices and connect with my device. I followed this guide:
http://lifehacker.com/the-easiest-way-to-install-androids-adb-and-fastboot-to-1586992378 to install the missing ADB (linux section).
I got an error: adb server is out of date. killing... which terminated connection between the device to the machine, but after following #yoh advice, I changed my USB connection from MTP to PTP and tried again. This time worked.
Managed to run my app successfully on physical LG G2 after those steps using Ubuntu.

Categories