manu manu - 1 year ago 148
Android Question

Location request timed out on android emulator with React-Native

I'm building my first android app with react-native.
What I want to do is display my current location. But it doesn't seem to work on my emulator. Instead I get a "Location request timed out" error in the console. Here is a sample of code from my file:

initGeoloc() {
(position) => {

render() {
... some more code and the view

The code is very simple so I don't think the error comes from here.
I added these permission in my AndroidManifest.xml file (ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION):

<manifest xmlns:android=""
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<uses-library android:name="" />
<meta-data android:name="" android:value="mykey"/>

I don't see anything wrong here either, so I think the problem comes from the Android emulator. I use Android Virtual Device Manager to create a Nexus 5, Google APIs (Google Inc.) - API Level 23 virtual device. The geolocation is activated on the device but I did not see any geolocation tool in the developper tools or configuration. So probably the error comes from here. The virtual device does'nt return any location.

How can I fix this ?

Answer Source

This question is answered in this thread. How to emulate GPS location in the Android Emulator? Sorry for the duplicate. I fixed my problem using telnet.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download