React-native-background-geolocation: Cannot do manual linking on Android

Created on 5 Aug 2019  路  13Comments  路  Source: mauron85/react-native-background-geolocation

Your Environment


Context

Fresh install of react-native init.
The react-native link command doesn't work, when I try to do manual linking I get the error below.

Native module BackgroundGeolocation tried to override BackgroundGeolocationModule. Check the getPackages() method in MainApplication.java, it might be that the module is being created twice.

This is my MainApplication.getPackages():

    @Override
    protected List<ReactPackage> getPackages() {
      @SuppressWarnings("UnnecessaryLocalVariable")
      List<ReactPackage> packages = new PackageList(this).getPackages();
      // Packages that cannot be autolinked yet can be added manually here, for example:
      // packages.add(new MyReactNativePackage());
      packages.add(new BackgroundGeolocationPackage());       
      return packages;
    }

Screen Shot 2019-08-05 at 20 40 43

stale

All 13 comments

It seems that you don't have to edit MainApplication.java in this newer React Native version. Can we update the README about this?

The plugin was not updated to RN 0.60.4 yet. Due changes in RN, there are multiple issues, that need to be resolved. But in your case, I would say that linker failed, but it managed to add package to MainApplication.java anyway.

@mauron85 is it possible to install this package from master branch directly?

Yeah, in package.json you can use a direct reference to github. https://docs.npmjs.com/files/package.json#github-urls

@WebMobi59

plugin was not updated to RN 0.60.4 yet. Due changes in RN, th

I used your plugin with RN 0.59.X.
Do you have a timeline about updating this plugin to work with RN 0.60.X ?

I'm using it in RN 0.60.4 without issue. Just had to manually setup the settings.gradle and build.gradle files.

I'm using it in RN 0.60.4 without issue. Just had to manually setup the settings.gradle and build.gradle files.

Thanks will try to play around and see if I can get it to work.

I'm using it in RN 0.60.4 without issue. Just had to manually setup the settings.gradle and build.gradle files.

Thanks will try to play around and see if I can get it to work.

did you get it to work yet?

I've removed all modifs in MainApplication.java, like this lines:

 import com.marianhello.bgloc.react.BackgroundGeolocationPackage;
...
           packages.add(new BackgroundGeolocationPackage());

and the bug is gone

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

I have same problem and don't understand it, when modify MainApplication.java and add this, i get the same error:

...
import com.marianhello.bgloc.react.BackgroundGeolocationPackage;
...

@Override
protected List getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List packages = new PackageList(this).getPackages();
packages.add(new BackgroundGeolocationPackage());
return packages;
}
`
But if you remove this lines so return other error "invariant violation: requirenativecomponent: "airmap" was not found in the uimanager"

This is my package.json

"dependencies": { "@mauron85/react-native-background-geolocation": "^0.6.3", "@react-native-community/cli-platform-android": "^4.8.0", "react": "16.11.0", "react-native": "0.62.2", "react-native-geolocation-service": "^5.0.0", "react-native-maps": "0.27.1", },

But if you remove this lines so return other error "invariant violation: requirenativecomponent: "airmap" was not found in the uimanager"

supouse that this is the best option to get location in background (free) but y i feel that be outdated. Shoulding take other way or focus for resolve this issue. helpme please.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This issue has been automatically closed, because it has not had recent activity. If you believe this issue shouldn't be closed, please reopen or write down a comment requesting issue reopening with explanation why you think it's important. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings