Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CB-11875 added android.hardware.location.gps uses-feature. #81

Closed
wants to merge 1 commit into from

Conversation

audreyso
Copy link
Contributor

Platforms affected

Android

What does this PR do?

Fixes feature issue (geolocation)

What testing has been done on this change?

Tested that got added to Android manifest; Ran and tested that geolocation worked on Android device.

Checklist

  • ICLA has been signed and submitted to [email protected].
  • Reported an issue in the JIRA database
  • Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected.
  • Added automated test coverage as appropriate for this change.

Copy link
Contributor

@stevengill stevengill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks for sending it

@cordova-qa
Copy link

Cordova CI Build has completed successfully.

Commit - Link
Dashboard - Link

Builder Name Console Output Test Report Device Logs
Windows 8.1 Store Link Link Link
Windows 10 Store Link Link Link
Windows 8.1 Phone Link Link Link
iOS Link Link Link
Android Link Link Link

@asfgit asfgit closed this in 9f4d681 Sep 22, 2016
@mikepsinn
Copy link

mikepsinn commented Sep 29, 2016

@stevengill @asfgit @audreyso Just curious, are you sure we want to add this?

According to Google, it will "ensure that Google Play only distributes your app to devices with GPS sensors".

I'm very well missing something, but it seems like that would make it impossible to use this plugin in apps that also wish to be made available to non-GPS-containing devices (which would still be able to get Wi-Fi and Cell-ID based location data).

I'd love to know what you think! Thanks!

Here's the email I got:

Action required: If your app requires GPS hardware to operate properly, you will need to explicitly add the "android.hardware.location.gps" uses-feature to your manifest.

What’s changing

We’re making a change on October 15th, 2016 that will affect apps targeting API version 21 (Android 5.0, Lollipop) or higher that use ACCESS_FINE_LOCATION but don't explicitly have the "android.hardware.location.gps" uses-feature. Going forward, these apps will be available to install on devices that don't have GPS hardware. In most cases this won't be an issue since Wi-Fi and Cell-ID based location provides high enough fidelity for the typical operation of these apps. However, any apps that require GPS hardware, such as GPS navigators, should explicitly add the "android.hardware.location.gps" uses-feature to their manifest.

If your app requires GPS to function properly and you do not include android.hardware.location.gps in your manifest declaration, your users may have a poor app experience.

Also, if you’re using the fused location provider and wish to receive the most accurate location samples from GPS (i.e. with PRIORITY_HIGH_ACCURACY), you must include the "android.hardware.location.gps" feature in your app’s manifest to ensure that Google Play only distributes your app to devices with GPS sensors.

@stevengill
Copy link
Contributor

@mikepsinn pretty sure.

Currently, the geolocation plugin already adds the ACCESS_FINE_LOCATION permission. So assuming we aren't removing that, we need to add the "android.hardware.location.gps" uses-feature.

In this scenario, users have to remove the permission + uses feature to work with non-gps containing devices. If we decided to remove ACCESS_FINE_LOCATION permission and not add the uses-feature, then users would have to manually add those two (to their config.xml using config-file tag, or directly to their Android manifest).

Seeing how we mainly target mobile devices which have GPS, it seems like it makes more sense to add than remove.

@mikepsinn
Copy link

@stevengill Good points. Thanks for the explanation!

Do you think I should add something to the "Android Quirks" section of the README warning people that their app won't be available to non-GPS devices if they use this plugin unless they remove that line before building?

@stevengill
Copy link
Contributor

@mikepsinn it would be great to add a note in the readme!

We will see how this change affects users. If lots of people complain over time, we may end up going the other way with GPS not needed by default and users having to manually add the permission + uses-feature.

@Alexious-sh
Copy link

It's all ok, but why you declared it as required feature? In this way Google Play doesn't allow installing app with this plugin to devices without GPS. It can be fixed by adding android:required="false"

@dansterrett
Copy link

For anyone who wants GPS to NOT be required, you can add this to config.xml (inside <platform name="android">):

<edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/uses-feature[@android:name='android.hardware.location.gps']">
    <uses-feature android:name="android.hardware.location.gps" android:required="false" />
</edit-config>

And make sure to add xmlns:android="http://schemas.android.com/apk/res/android" to the <widget> tag at the top of the file or you will get errors.

When you build the project, platforms/android/app/src/main/AndroidManifest.xml will change from:

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

to

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

@BARNZ
Copy link

BARNZ commented Mar 23, 2020

Man this bites me every time I go to do a release build.

Thanks @dansterrett - that works, but only for the first time you build. On the 2nd time round it will try to add a duplicate line into the AndroidManifest.xml file and the build will fail:

image

Have to manually remove the line with android:required before it will work again.

@timbru31
Copy link
Member

timbru31 commented Mar 24, 2020

We've just merged PR #189 - so please try the current git master, the required variable is now configurable to support devices without GPS.

@BARNZ
Copy link

BARNZ commented Mar 25, 2020

Thanks @timbru31 - works great! 👍

@flyonthenet
Copy link

This seems introduces some incompatibility with other plugins.
With version 4.1.0 (latest) i get this error when building using https://volt.build :

> Task :app:processReleaseManifest FAILED
/platforms/android/app/src/main/AndroidManifest.xml:37:5-66 Error:
	Element uses-feature#android.hardware.location.gps at AndroidManifest.xml:37:5-66 duplicated with element declared at AndroidManifest.xml:32:5-91
/platforms/android/app/src/main/AndroidManifest.xml Error:
	Validation failed, exiting

In this case conflict is with cordova-plugin-googlemaps

Rolling back to 4.0.2 the build succeeded.

Any suggestion to use version 4.1.0?
Thanks

@stevebrowndotco
Copy link

Did some googling and I came across this issue. I also use cordova-plugin-googlemaps

With version 4.1.0 I get the error on build: Element uses-feature#android.hardware.location.gps at AndroidManifest.xml

Rolling back to 4.0.2 and it's working again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants