Skip to content

Commit 72acc05

Browse files
chore: Update README.md for android setup running on React Native 0.65 and bellow (#259)
* Update README.md * Add new information as collapsible
1 parent 24a026e commit 72acc05

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,40 @@ Android API >= 18 Positions will also contain a `mocked` boolean to indicate if
7272
Failure to do so may result in a hard crash.
7373
</p>
7474

75+
<details>
76+
<summary><b>For React Native < 0.65 on Android we need to link manually</b></summary>
77+
78+
79+
- android/settings.gradle
80+
```
81+
include ':react-native-community-geolocation'
82+
project(':react-native-community-geolocation').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/geolocation/android')
83+
```
84+
- android/app/build.gradle
85+
```
86+
dependencies {
87+
...
88+
implementation project(':react-native-community-geolocation')
89+
}
90+
```
91+
- android/app/src/main/.../MainApplication.java
92+
On imports section:
93+
```java
94+
import com.reactnativecommunity.geolocation.GeolocationPackage;
95+
```
96+
In the class at `getPackages` method:
97+
```java
98+
@Override
99+
protected List<ReactPackage> getPackages() {
100+
@SuppressWarnings("UnnecessaryLocalVariable")
101+
List<ReactPackage> packages = new PackageList(this).getPackages();
102+
// Packages that cannot be autolinked yet can be added manually here, for example:
103+
packages.add(new GeolocationPackage()); // <== add this line
104+
return packages;
105+
}
106+
```
107+
</details>
108+
75109
## Migrating from the core `react-native` module
76110
This module was created when the Geolocation was split out from the core of React Native. As a browser polyfill, this API was available through the `navigator.geolocation` global - you didn't need to import it. To migrate to this module you need to follow the installation instructions above and change following code:
77111

0 commit comments

Comments
 (0)