ionic-team / capacitor

Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚡️
https://capacitorjs.com
MIT License
12.08k stars 1k forks source link

bug: Error: "Geolocation" plugin is not implemented on android at createPluginMethod #6632

Closed areeb-gsoftconsulting closed 1 year ago

areeb-gsoftconsulting commented 1 year ago

Bug Report

I have created ionic react boilerplate, added toast from ionic capacitor which is working fine, but now when i am adding geolocation, i am getting this error.

Capacitor Version

"@capacitor/android": "^4.0.0", "@capacitor/camera": "^4.0.0", "@capacitor/core": "^4.8.0", "@capacitor/filesystem": "^4.0.0", "@capacitor/geolocation": "^5.0.2", "@capacitor/ios": "^4.0.0", "@capacitor/preferences": "^4.0.1", "@capacitor/toast": "^5.0.2",

 Capacitor Doctor  💊 

Latest Dependencies:

  @capacitor/cli: 5.0.4
  @capacitor/core: 5.0.4
  @capacitor/android: 5.0.4
  @capacitor/ios: 5.0.4

Installed Dependencies:

  @capacitor/cli: 4.8.0
  @capacitor/core: 4.8.0
  @capacitor/android: 4.8.0
  @capacitor/ios: 4.8.0

Platform(s)

Current Behavior

Expected Behavior

Code Reproduction

Other Technical Details

npm --version output: 9.6.6 node --version output: v20.2.0

Additional Context

Ionitron commented 1 year ago

This issue may need more information before it can be addressed. In particular, it will need a reliable Code Reproduction that demonstrates the issue.

Please see the Contributing Guide for how to create a Code Reproduction.

Thanks! Ionitron 💙

areeb-gsoftconsulting commented 1 year ago

This issue may need more information before it can be addressed. In particular, it will need a reliable Code Reproduction that demonstrates the issue.

Please see the Contributing Guide for how to create a Code Reproduction.

Thanks! Ionitron 💙

here is repo to reproduce.

https://github.com/areeb-gsoftconsulting/ionic-learn

checkout to >>[geolocation]

jcesarmobile commented 1 year ago

The provided app has several issues. You are using some Capacitor 5 plugins but using Capacitor 4, that makes npm install fail because of peer dependency issues. Can be workaround by using npm install --force or yarn install. Then the native app doesn't build because the geolocation plugin requires latest google services version. Can be workaround by removing playServicesLocationVersion = '20.0.0' from android/variables.gradle so it uses the default value.

Once I did that, the app builds and I get the location properly.

Looks like you forgot to run npx cap sync after installing the plugin and that's why it's not finding it.

ionitron-bot[bot] commented 1 year ago

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.