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

Using plugin with capacitor (android)

Open piernik opened this issue 5 years ago • 12 comments

I want to use Your plugin with ionic and capacitor (fresh install). I know that there is problem with iOS but I care only about Android.

Is it possible to use Your plugin only with capacitor? If Yes - how?

Tried npm install cordova-plugin-googlemaps but then in Android Studio I have error C:\ (Bad filepath)

Is there any kind of tutorial to use Your plugin with capacitor?

piernik avatar Aug 05 '20 11:08 piernik

You need to install @ionic-native/google-maps and this plugin.

wf9a5m75 avatar Aug 05 '20 18:08 wf9a5m75

I did that "@ionic-native/google-maps": "^5.27.0-beta-20200630",.

Do I have to pass API_KEY_FOR_ANDROID to capacitor ? How?

piernik avatar Aug 05 '20 18:08 piernik

You need to create a config.xml file.

wf9a5m75 avatar Aug 05 '20 18:08 wf9a5m75

You can add Preferences in capacitor in the capacitor.config.json like:

"cordova": { 
  "preferences": { 
    "API_KEY_FOR_ANDROID": "YOUR_KEY_HERE" 
  } 
}

Try this out

EinfachHans avatar Aug 06 '20 08:08 EinfachHans

@HansKrywaa didn't help. @wf9a5m75 Where to add this file and with what content?

I'm adding npm i @ionic-native/google-maps and npm i cordova-plugin-googlemaps, then I sync files npx cap sync and then open android studio with npx cap open android. Android Studio has phase Sync project with Gradle Files which throws error c:\ (Bad filepath).

@wf9a5m75 Can You make a fresh ionic+capacitor project from scratch? I know that time is limited, but I'm stuck :/

piernik avatar Aug 06 '20 11:08 piernik

You need to create a config.xml file at (project dir)/config.xml before using npx cap sync

wf9a5m75 avatar Aug 06 '20 14:08 wf9a5m75

Can You make a fresh ionic+capacitor project from scratch? I know that time is limited, but I'm stuck :/

Sorry. I'm super busy.

wf9a5m75 avatar Aug 06 '20 14:08 wf9a5m75

@HansKrywaa That works for older versions. This plugin does not use --variable parameters anymore. Instead of that, this plugin finds the config.xml file, and parse it using gradle script.

wf9a5m75 avatar Aug 06 '20 17:08 wf9a5m75

@wf9a5m75 I did a fresh project with ionic using ionic start myApp tabs --capacitor. Then I updated angular using ng update @angular/core @angular/cli App was compiling to this step.

Then I installed Your plugin using npm i @ionic-native/google-maps and npm i cordova-plugin-googlemaps. I created config.xml file in root folder:

<?xml version='1.0' encoding='utf-8'?>
<widget>
    <preference name="GOOGLE_MAPS_ANDROID_API_KEY" value="AIzaSyBINjjNZBV2_yrk_**********" />
</widget>

Then sync with npx cap sync.

In Android Studio I managed to sync with gradle Files. But when I run app on my device I have that errors:

Executing tasks: [:app:assembleDebug] in project C:\strony\www\_del\myApp\android


> Configure project :app
config.xml
../config.xml
../../config.xml
preference = 1
name = GOOGLE_MAPS_ANDROID_API_KEY
---->PLAY_SERVICES_VERSION = 16.0.0
---->ANDROID_SUPPORT_V4_VERSION = 27.1.1
google-services.json not found, google-services plugin not applied. Push Notifications won't work

> Configure project :capacitor-cordova-android-plugins
config.xml
../config.xml
../../config.xml
preference = 1
name = GOOGLE_MAPS_ANDROID_API_KEY
---->PLAY_SERVICES_VERSION = 16.0.0
---->ANDROID_SUPPORT_V4_VERSION = 27.1.1

> Task :app:preBuild UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :capacitor-android:preBuild UP-TO-DATE
> Task :capacitor-android:preDebugBuild UP-TO-DATE
> Task :capacitor-android:compileDebugAidl NO-SOURCE
> Task :capacitor-cordova-android-plugins:preBuild UP-TO-DATE
> Task :capacitor-cordova-android-plugins:preDebugBuild UP-TO-DATE
> Task :capacitor-android:packageDebugRenderscript NO-SOURCE
> Task :capacitor-cordova-android-plugins:compileDebugAidl NO-SOURCE
> Task :app:compileDebugAidl NO-SOURCE
> Task :capacitor-cordova-android-plugins:packageDebugRenderscript NO-SOURCE
> Task :app:compileDebugRenderscript NO-SOURCE
> Task :app:generateDebugBuildConfig UP-TO-DATE
> Task :capacitor-android:generateDebugBuildConfig UP-TO-DATE
> Task :capacitor-android:compileDebugRenderscript NO-SOURCE
> Task :capacitor-android:generateDebugResValues UP-TO-DATE
> Task :capacitor-android:generateDebugResources UP-TO-DATE
> Task :capacitor-android:packageDebugResources UP-TO-DATE
> Task :capacitor-android:parseDebugLocalResources UP-TO-DATE
> Task :capacitor-android:processDebugManifest UP-TO-DATE
> Task :capacitor-android:generateDebugRFile UP-TO-DATE
> Task :capacitor-android:javaPreCompileDebug UP-TO-DATE
> Task :capacitor-android:compileDebugJavaWithJavac UP-TO-DATE
> Task :capacitor-android:bundleLibCompileDebug UP-TO-DATE
> Task :capacitor-cordova-android-plugins:generateDebugBuildConfig
> Task :capacitor-cordova-android-plugins:compileDebugRenderscript NO-SOURCE
> Task :capacitor-cordova-android-plugins:generateDebugResValues
> Task :capacitor-cordova-android-plugins:generateDebugResources
> Task :capacitor-cordova-android-plugins:packageDebugResources
> Task :capacitor-cordova-android-plugins:parseDebugLocalResources
> Task :capacitor-cordova-android-plugins:javaPreCompileDebug
> Task :app:mainApkListPersistenceDebug UP-TO-DATE
> Task :app:generateDebugResValues UP-TO-DATE
> Task :app:generateDebugResources UP-TO-DATE
> Task :app:mergeDebugResources UP-TO-DATE
> Task :capacitor-cordova-android-plugins:processDebugManifest
> Task :app:createDebugCompatibleScreenManifests UP-TO-DATE
> Task :app:extractDeepLinksDebug UP-TO-DATE
> Task :capacitor-android:extractDeepLinksDebug UP-TO-DATE
> Task :capacitor-cordova-android-plugins:extractDeepLinksDebug
> Task :app:processDebugManifest UP-TO-DATE
> Task :capacitor-android:compileDebugLibraryResources UP-TO-DATE
> Task :capacitor-cordova-android-plugins:generateDebugRFile

> Task :capacitor-cordova-android-plugins:compileDebugJavaWithJavac FAILED
C:\strony\www\_del\myApp\android\capacitor-cordova-android-plugins\src\main\java\plugin\google\maps\PluginMap.java:19: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
                                 ^
C:\strony\www\_del\myApp\android\capacitor-cordova-android-plugins\src\main\java\plugin\google\maps\PluginMap.java:20: error: package android.support.v4.content does not exist
import android.support.v4.content.PermissionChecker;
                                 ^
C:\strony\www\_del\myApp\android\capacitor-cordova-android-plugins\src\main\java\plugin\google\maps\PluginLocationService.java:12: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
                                 ^
C:\strony\www\_del\myApp\android\capacitor-cordova-android-plugins\src\main\java\plugin\google\maps\PluginLocationService.java:13: error: package android.support.v4.content does not exist
import android.support.v4.content.PermissionChecker;
                                 ^
C:\strony\www\_del\myApp\android\capacitor-cordova-android-plugins\src\main\java\plugin\google\maps\PluginMap.java:2783: error: cannot find symbol
  public void onMyLocationClick(@NonNull Location location) {
                                 ^
  symbol:   class NonNull
  location: class PluginMap
C:\strony\www\_del\myApp\android\capacitor-cordova-android-plugins\src\main\java\plugin\google\maps\PluginMap.java:192: error: cannot find symbol
        boolean locationPermission = PermissionChecker.checkSelfPermission(cordova.getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) == PermissionChecker.PERMISSION_GRANTED;
                                     ^
  symbol:   variable PermissionChecker
  location: class PluginMap
C:\strony\www\_del\myApp\android\capacitor-cordova-android-plugins\src\main\java\plugin\google\maps\PluginMap.java:192: error: cannot find symbol
        boolean locationPermission = PermissionChecker.checkSelfPermission(cordova.getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) == PermissionChecker.PERMISSION_GRANTED;
                                                                                                                                                 ^
  symbol:   variable PermissionChecker
  location: class PluginMap
C:\strony\www\_del\myApp\android\capacitor-cordova-android-plugins\src\main\java\plugin\google\maps\PluginMap.java:208: error: cannot find symbol
          locationPermission = PermissionChecker.checkSelfPermission(cordova.getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) == PermissionChecker.PERMISSION_GRANTED;
                               ^
  symbol:   variable PermissionChecker
  location: class PluginMap
C:\strony\www\_del\myApp\android\capacitor-cordova-android-plugins\src\main\java\plugin\google\maps\PluginMap.java:208: error: cannot find symbol
          locationPermission = PermissionChecker.checkSelfPermission(cordova.getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) == PermissionChecker.PERMISSION_GRANTED;
                                                                                                                                         ^
  symbol:   variable PermissionChecker
  location: class PluginMap
C:\strony\www\_del\myApp\android\capacitor-cordova-android-plugins\src\main\java\plugin\google\maps\PluginMap.java:339: error: cannot find symbol
                  boolean locationPermission = PermissionChecker.checkSelfPermission(cordova.getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) == PermissionChecker.PERMISSION_GRANTED;
                                               ^
  symbol: variable PermissionChecker
C:\strony\www\_del\myApp\android\capacitor-cordova-android-plugins\src\main\java\plugin\google\maps\PluginMap.java:339: error: cannot find symbol
                  boolean locationPermission = PermissionChecker.checkSelfPermission(cordova.getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) == PermissionChecker.PERMISSION_GRANTED;
                                                                                                                                                           ^
  symbol: variable PermissionChecker
C:\strony\www\_del\myApp\android\capacitor-cordova-android-plugins\src\main\java\plugin\google\maps\PluginMap.java:1837: error: cannot find symbol
    boolean locationPermission = PermissionChecker.checkSelfPermission(cordova.getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) == PermissionChecker.PERMISSION_GRANTED;
                                 ^
  symbol:   variable PermissionChecker
  location: class PluginMap
C:\strony\www\_del\myApp\android\capacitor-cordova-android-plugins\src\main\java\plugin\google\maps\PluginMap.java:1837: error: cannot find symbol
    boolean locationPermission = PermissionChecker.checkSelfPermission(cordova.getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) == PermissionChecker.PERMISSION_GRANTED;
                                                                                                                                             ^
  symbol:   variable PermissionChecker
  location: class PluginMap
C:\strony\www\_del\myApp\android\capacitor-cordova-android-plugins\src\main\java\plugin\google\maps\PluginMap.java:1853: error: cannot find symbol
      locationPermission = PermissionChecker.checkSelfPermission(cordova.getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) == PermissionChecker.PERMISSION_GRANTED;
                           ^
  symbol:   variable PermissionChecker
  location: class PluginMap
C:\strony\www\_del\myApp\android\capacitor-cordova-android-plugins\src\main\java\plugin\google\maps\PluginMap.java:1853: error: cannot find symbol
      locationPermission = PermissionChecker.checkSelfPermission(cordova.getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) == PermissionChecker.PERMISSION_GRANTED;
                                                                                                                                     ^
  symbol:   variable PermissionChecker
  location: class PluginMap
C:\strony\www\_del\myApp\android\capacitor-cordova-android-plugins\src\main\java\plugin\google\maps\PluginLocationService.java:93: error: cannot find symbol
      boolean locationPermission = PermissionChecker.checkSelfPermission(cordova.getActivity().getApplicationContext(), Manifest.permission.ACCESS_COARSE_LOCATION) == PermissionChecker.PERMISSION_GRANTED;
                                   ^
  symbol:   variable PermissionChecker
  location: class PluginLocationService
C:\strony\www\_del\myApp\android\capacitor-cordova-android-plugins\src\main\java\plugin\google\maps\PluginLocationService.java:93: error: cannot find symbol
      boolean locationPermission = PermissionChecker.checkSelfPermission(cordova.getActivity().getApplicationContext(), Manifest.permission.ACCESS_COARSE_LOCATION) == PermissionChecker.PERMISSION_GRANTED;
                                                                                                                                                                       ^
  symbol:   variable PermissionChecker
  location: class PluginLocationService
C:\strony\www\_del\myApp\android\capacitor-cordova-android-plugins\src\main\java\plugin\google\maps\PluginLocationService.java:176: error: cannot find symbol
    boolean locationPermission = PermissionChecker.checkSelfPermission(cordova.getActivity().getApplicationContext(), Manifest.permission.ACCESS_COARSE_LOCATION) == PermissionChecker.PERMISSION_GRANTED;
                                 ^
  symbol:   variable PermissionChecker
  location: class PluginLocationService
C:\strony\www\_del\myApp\android\capacitor-cordova-android-plugins\src\main\java\plugin\google\maps\PluginLocationService.java:176: error: cannot find symbol
    boolean locationPermission = PermissionChecker.checkSelfPermission(cordova.getActivity().getApplicationContext(), Manifest.permission.ACCESS_COARSE_LOCATION) == PermissionChecker.PERMISSION_GRANTED;
                                                                                                                                                                     ^
  symbol:   variable PermissionChecker
  location: class PluginLocationService
C:\strony\www\_del\myApp\android\capacitor-cordova-android-plugins\src\main\java\plugin\google\maps\PluginLocationService.java:191: error: cannot find symbol
      locationPermission = PermissionChecker.checkSelfPermission(cordova.getActivity().getApplicationContext(), Manifest.permission.ACCESS_COARSE_LOCATION) == PermissionChecker.PERMISSION_GRANTED;
                           ^
  symbol:   variable PermissionChecker
  location: class PluginLocationService
C:\strony\www\_del\myApp\android\capacitor-cordova-android-plugins\src\main\java\plugin\google\maps\PluginLocationService.java:191: error: cannot find symbol
      locationPermission = PermissionChecker.checkSelfPermission(cordova.getActivity().getApplicationContext(), Manifest.permission.ACCESS_COARSE_LOCATION) == PermissionChecker.PERMISSION_GRANTED;
                                                                                                                                                               ^
  symbol:   variable PermissionChecker
  location: class PluginLocationService
C:\strony\www\_del\myApp\android\capacitor-cordova-android-plugins\src\main\java\plugin\google\maps\PluginLocationService.java:260: error: cannot find symbol
          public void onConnectionFailed(@NonNull ConnectionResult result) {
                                          ^
  symbol: class NonNull
C:\strony\www\_del\myApp\android\capacitor-cordova-android-plugins\src\main\java\plugin\google\maps\PluginLocationService.java:503: error: cannot find symbol
          public void onFailure(@NonNull Exception e) {
                                 ^
  symbol: class NonNull
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
23 errors

> Task :capacitor-cordova-android-plugins:compileDebugLibraryResources

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':capacitor-cordova-android-plugins:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s
28 actionable tasks: 10 executed, 18 up-to-date

piernik avatar Aug 10 '20 08:08 piernik

You need to install the multiple_maps branch version instead of released version

wf9a5m75 avatar Aug 10 '20 14:08 wf9a5m75

Ok - now it is working 👍 Command to install Your plugin npm install --save git://github.com/mapsplugin/cordova-plugin-googlemaps.git#multiple_maps

When Do You plan to release this version as official?

piernik avatar Aug 12 '20 07:08 piernik

@wf9a5m75 Did You released it as official?

piernik avatar Oct 30 '20 11:10 piernik