react-native-geolocation
react-native-geolocation copied to clipboard
Error + Warnings in permission phasis depending of Android 8.1 or 10
Environment
OS: Windows 10 10.0.19043 CPU: (4) x64 Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz Memory: 2.13 GB / 7.70 GB Binaries: Node: 16.14.1 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD npm: 8.13.1 - C:\Program Files\nodejs\npm.CMD Watchman: Not Found SDKs: Android SDK: Not Found Windows SDK: AllowDevelopmentWithoutDevLicense: Enabled AllowAllTrustedApps: Enabled IDEs: Android Studio: Not Found Visual Studio: Not Found Languages: Java: Not Found npmPackages: @react-native-community/cli: Not Found react: 18.1.0 => 18.1.0 react-native: 0.70.1 => 0.70.1 react-native-windows: Not Found npmGlobalPackages: react-native: Not Found
Platforms
Win 10 : no problem at build
Versions
1 on And 8.1: with error in metro 1 on And 10 ==API 29 without error
- react-native-geolocation:3.0.1
- react-native: see up
- react: see up
Description
I get in console for both :
WARN new NativeEventEmitter() was called with a non-null argument without the required addListener method.
WARN new NativeEventEmitter() was called with a non-null argument without the required removeListeners method.
on And 8.1 terminal ==API27 , I get in addition :
ERROR {"PERMISSION_DENIED": 1, "POSITION_UNAVAILABLE": 2, "TIMEOUT": 3, "code": 1, "message": "Location permission was not granted."}
and after in both cases the logs : LOG Running "test_rn_geoloc" with {"rootTag":11} LOG {"coords": {"accuracy": 20, "altitude": 453.8999938964844, "heading": 0, "latitude": 45.5563458, "longitude": 5.5240304, "speed": 0}, "extras": {}, "mocked": false, "timestamp": 1663772522458}
Reproducible Demo
code in App.js : `import Geolocation from '@react-native-community/geolocation';
const App = () => { const [hasPermission, setHasPermission] = useState(null);
//at start : get permissions geoloc useEffect(() => { Geolocation.requestAuthorization(); }, []);
Geolocation.getCurrentPosition(info => console.log(info));
return ( <SafeAreaView> <Text> depart </Text> </SafeAreaView> ); };` and in manifest .xml : uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /
Thanks for you ideas !
and on a another Android 10 , I have in console : BUNDLE ./index.js
ERROR Error: The package '@react-native-community/geolocation' doesn't seem to be linked. Make sure:
- You rebuilt the app after installing the package
- You are not using Expo managed workflow
WARN
new NativeEventEmitter()was called with a non-null argument without the requiredaddListenermethod. WARNnew NativeEventEmitter()was called with a non-null argument without the requiredremoveListenersmethod. LOG Running "test_rn_geoloc" with {"rootTag":1}
and after acceptation on the screen of the authorization :+1: ERROR Error: The package '@react-native-community/geolocation' doesn't seem to be linked. Make sure:
- You rebuilt the app after installing the package
- You are not using Expo managed workflow
, js engine: hermes
then a response:
LOG {"coords": {"accuracy": 18.87605857849121, "altitude": 0, "heading": 0, "latitude": 45.5865938, "longitude": 5.278462, "speed": 0}, "extras": {}, "mocked": false, "timestamp": 1663831981258}
Should be fixed in the latest release
ok , thanks ( I do not test)