Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70435

Trying to update AndroidManifest.xml to stop GPS being required

$
0
0

Currently, my App cannot be installed on Android devices that do not have GPS even though GPS is not actually required for the App to function properly. This is due to the following in the AndroidManfest.xml file:

<uses-feature android:name="android.hardware.location.gps"  />

I need to update the AndroidManifest.xml file during build to the following:

<uses-feature android:name="android.hardware.location.gps" android:required="false" />

I am trying to use “edit-config” options within my config.xml to achieve this as follows:

<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" android:required="false" />
</edit-config>

This works fine if the AndroidManifest.xml file already exists and contains the “uses-feature…” setting already, but this fails with the following error if the AndroidManifest.xml file doesn’t exist, this is a problem because I use Ionic AppFlow to build the app so the following error occurs when I try and do a build with AppFlow. I can also make the following error occur locally by removing the Android platform and then re-adding it:

Android project created with cordova-android@8.1.0
Error: Unable to graft xml at selector "/manifest/uses-feature[@android:name='android.hardware.location.gps']" from "C:\Projects\MyApp\platforms\android\app\src\main\AndroidManifest.xml" during config install

Does anyone have a solution to this?

I have also tried using the “custom-config” plugin but this seems to cause other issues such as duplicates of the relevant “uses-feature…” in the AndroidManifest.xml file.

I think part of the problem is that I have multiple plugins that are trying to apply this setting (i.e. “cordova.plugins.diagnostic.modules”, “cordova-plugin-geolocation”, possibly “cordova-plugin-googlemaps” as well?).

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 70435

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>