cordova-plugin-geolocation icon indicating copy to clipboard operation
cordova-plugin-geolocation copied to clipboard

android.hardware.location.gps added twice in androidManifest

Open piernik opened this issue 4 years ago • 2 comments

I have two plugins that uses location. Yours and Google Maps: https://github.com/mapsplugin/cordova-plugin-googlemaps

This way there are two tags <uses-feature android:name="android.hardware.location.gps" /> in AndroidManifest.xml file :/

Tried adding

<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/uses-feature[@android:name='android.hardware.location.gps']" xmlns:android="http://schemas.android.com/apk/res/android">
            <uses-feature android:name="android.hardware.location.gps" />
        </edit-config>

to config.xml file but it is not helping. How to solve it?

piernik avatar Mar 23 '21 11:03 piernik

I also have the same problem. build error. any solutions?

apri23 avatar Mar 31 '21 09:03 apri23

i have fixed this error by open this project from platform folder with android studio. 1)open search file window by double press shift button 2) find "android.json" file and open it 3) find word "gps" and remove duplicate entry 4) try ionic cordova build android now 5) open android manifest file and remove duplicate entry for gps. again can take build in either android studio or ionic cordova build android will solve this issue.

Happy coding. cheers

vnrdroidfreak avatar Aug 26 '21 13:08 vnrdroidfreak

Unfortunately the two plugins conflicts because they and this plugin boht uses <config-file> directive which always inserts the contents into the target which obviously leads into duplicates.

In order to use this plugin alongside with google maps plugin, a hook will probably have to be made to dedupe the android manifest entry.

And after_prepare hook to scan and remove one occurence <uses-feature android:name="android.hardware.location.gps" /> should do it (along with any other duplicates caused by the same issue).

Manually modifying the project will work, but there are many actions that may cause the project to be re-prepared/reconstructed and you'll have to remember to manually fix it each time that happens, whereas the hook can automate that for you.

Closing because it's not really a bug with this plugin or cordova in general. But we are aware of problems with the config-file/edit-config directives.

breautek avatar Jun 05 '23 01:06 breautek