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

Geolocation 4.1.0: Illegal value $GPS_REQUIRED #3579

Closed
AE1NS opened this issue Nov 25, 2020 · 9 comments
Closed

Geolocation 4.1.0: Illegal value $GPS_REQUIRED #3579

AE1NS opened this issue Nov 25, 2020 · 9 comments

Comments

@AE1NS
Copy link

AE1NS commented Nov 25, 2020

The plugin cordova-plugin-geolocation added the variable $GPS_REQUIRED in the release 4.1.0.
apache/cordova-plugin-geolocation#189

Its added to the cordova plugin by the --variable parameter. Unfortunately we cant use this with capacitor. Now the android/capacitor-cordova-android-plugins/AndroidManifest.xml contains this line:
<uses-feature android:name="android.hardware.location.gps" android:required="$GPS_REQUIRED"/>
and outputs the error:

Attribute uses-feature#android.hardware.location.gps@required at AndroidManifest.xml:13:60-92 has an illegal value=($GPS_REQUIRED), expected 'true' or 'false' capacitor-cordova-android-plugins main manifest (this file), line 12

Setting this manually to true or false will set it back to '$GPS_REQUIRED' on the next cap sync. Is it possible to use this with capacitor this way?

@2manoj1
Copy link

2manoj1 commented Nov 27, 2020

same issue. build failed

@krabien
Copy link

krabien commented Nov 28, 2020

+1

2 similar comments
@sharmakshay
Copy link

+1

@martinsetup
Copy link

+1

@pete-mcwilliams
Copy link

PR has been merged ionic-team/capacitor#3863

@DanielOrtegaConesa
Copy link

DanielOrtegaConesa commented Dec 8, 2020

It is not ideal, but as a temporary "solution", I have added the following script to my npm commands
"android": "npx cap sync android && sed -i 's/$GPS_REQUIRED/true/' android/capacitor-cordova-android-plugins/src/main/AndroidManifest.xml
So instead of npx cap sync android im using npm run android

@jcesarmobile
Copy link
Contributor

update capacitor to 2.4.4

@tx-tim
Copy link

tx-tim commented Feb 18, 2021

Still seeing this issue in capacitor 2.4.6 - are there any other dependencies that need to be updated? @pete-mcwilliams

@pete-mcwilliams
Copy link

Still seeing this issue in capacitor 2.4.6 - are there any other dependencies that need to be updated? @pete-mcwilliams

Sorry, since I was poking around with the issue, I have switched to using capacitor Geolocation instead of the Cordova module.

I was just linking the pull request to this issue for anyone else that came past this thread.

something to get you started with capacitor geolocation

import { GeolocationOptions, GeolocationPosition, Plugins } from '@capacitor/core';

const { Geolocation } = Plugins;

<snip>
  options: GeolocationOptions;

  constructor(
    private platform: Platform,
  ) {
    this.options = {
      enableHighAccuracy: false,
      timeout: 10000
    };
  }

  async getLatestPosition(): Promise<GeolocationPosition> {
    try {
      return await Geolocation.getCurrentPosition(this.options);
    } catch (err) {
     console.error('Error getting location: ', err);
    }
  }

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

No branches or pull requests

9 participants