mapsplugin/cordova-plugin-googlemaps

Issues when trying to build for android on MacOS Big Sur

kobrecht12 opened this issue · 6 comments

I am using the Ionic framework on a MacBook Pro running Big Sur, and I am trying to run "cordova build android" but I am getting a long list of 25 errors and don't even know where to start. The build runs fine when building for iOS but not Android.

I had a host of other problems stemming from duplicate declarations of uses-feature statements in the AndroidManifest.xml file but was able to resolve those over a few days and that brings me until now.

this may be the wrong place to put this question, but the first couple errors are all stemming from plugin/google/maps so it may be...

The errors looks as follows:

> Task :app:compileDebugJavaWithJavac FAILED
/Users/kobre/Desktop/HeadsUp/Heads-Up-/MapApp/platforms/android/app/src/main/java/plugin/google/maps/PluginLocationService.java:12: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
                                 ^
/Users/kobre/Desktop/HeadsUp/Heads-Up-/MapApp/platforms/android/app/src/main/java/plugin/google/maps/PluginLocationService.java:13: error: package android.support.v4.content does not exist
import android.support.v4.content.PermissionChecker;
                                 ^
/Users/kobre/Desktop/HeadsUp/Heads-Up-/MapApp/platforms/android/app/src/main/java/plugin/google/maps/PluginMap.java:19: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
                                 ^
/Users/kobre/Desktop/HeadsUp/Heads-Up-/MapApp/platforms/android/app/src/main/java/plugin/google/maps/PluginMap.java:20: error: package android.support.v4.content does not exist
import android.support.v4.content.PermissionChecker;
                                 ^
/Users/kobre/Desktop/HeadsUp/Heads-Up-/MapApp/platforms/android/app/src/main/java/com/ionicframework/cordova/webview/IonicWebViewEngine.java:11: error: package android.support.annotation does not exist
import android.support.annotation.RequiresApi;
                                 ^
/Users/kobre/Desktop/HeadsUp/Heads-Up-/MapApp/platforms/android/app/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
/Users/kobre/Desktop/HeadsUp/Heads-Up-/MapApp/platforms/android/app/src/main/java/com/ionicframework/cordova/webview/IonicWebViewEngine.java:137: error: cannot find symbol
    @RequiresApi(Build.VERSION_CODES.LOLLIPOP)
     ^
  symbol:   class RequiresApi
  location: class IonicWebViewEngine.ServerClient
/Users/kobre/Desktop/HeadsUp/Heads-Up-/MapApp/platforms/android/app/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
/Users/kobre/Desktop/HeadsUp/Heads-Up-/MapApp/platforms/android/app/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
/Users/kobre/Desktop/HeadsUp/Heads-Up-/MapApp/platforms/android/app/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
/Users/kobre/Desktop/HeadsUp/Heads-Up-/MapApp/platforms/android/app/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
/Users/kobre/Desktop/HeadsUp/Heads-Up-/MapApp/platforms/android/app/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
/Users/kobre/Desktop/HeadsUp/Heads-Up-/MapApp/platforms/android/app/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
/Users/kobre/Desktop/HeadsUp/Heads-Up-/MapApp/platforms/android/app/src/main/java/plugin/google/maps/PluginLocationService.java:260: error: cannot find symbol
          public void onConnectionFailed(@NonNull ConnectionResult result) {
                                          ^
  symbol: class NonNull
/Users/kobre/Desktop/HeadsUp/Heads-Up-/MapApp/platforms/android/app/src/main/java/plugin/google/maps/PluginLocationService.java:503: error: cannot find symbol
          public void onFailure(@NonNull Exception e) {
                                 ^
  symbol: class NonNull
/Users/kobre/Desktop/HeadsUp/Heads-Up-/MapApp/platforms/android/app/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
/Users/kobre/Desktop/HeadsUp/Heads-Up-/MapApp/platforms/android/app/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
/Users/kobre/Desktop/HeadsUp/Heads-Up-/MapApp/platforms/android/app/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
/Users/kobre/Desktop/HeadsUp/Heads-Up-/MapApp/platforms/android/app/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
/Users/kobre/Desktop/HeadsUp/Heads-Up-/MapApp/platforms/android/app/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
/Users/kobre/Desktop/HeadsUp/Heads-Up-/MapApp/platforms/android/app/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
/Users/kobre/Desktop/HeadsUp/Heads-Up-/MapApp/platforms/android/app/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
/Users/kobre/Desktop/HeadsUp/Heads-Up-/MapApp/platforms/android/app/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
/Users/kobre/Desktop/HeadsUp/Heads-Up-/MapApp/platforms/android/app/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
/Users/kobre/Desktop/HeadsUp/Heads-Up-/MapApp/platforms/android/app/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
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.
25 errors

Here are the following cordova plugins that I have installed:

MacBook-Pro-2:MapApp kobre$ cordova plugin ls
com.googlemaps.ios 3.9.0 "Google Maps SDK for iOS"
cordova-plugin-add-swift-support 2.0.2 "AddSwiftSupport"
cordova-plugin-androidx 3.0.0 "cordova-plugin-androidx"
cordova-plugin-ble-central 1.3.1 "BLE"
cordova-plugin-device-motion 2.0.1 "Device Motion"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-geolocation 4.0.2 "Geolocation"
cordova-plugin-googlemaps 2.7.1 "cordova-plugin-googlemaps"
cordova-plugin-health 2.0.0 "Cordova Health"
cordova-plugin-ionic-keyboard 2.2.0 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 4.2.1 "cordova-plugin-ionic-webview"
cordova-plugin-nativegeocoder 3.4.1 "NativeGeocoder"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"

I am not really sure what is causing all of these problems, so any help would be greatly appreciated! Thanks!

Which version of cordova-android are you using?

If you use a lower version than 9.0 then you could try adding the following plugin to your project:

cordova plugin add cordova-plugin-androidx-adapter

Explanations:

If your Cordova project contains plugins/libraries which reference both the Android Support Library and AndroidX, your Android build will fail because the two cannot live side-by-side in an Android build.

This plugin provides a shim to migrate references to the legacy Android Support Library to the new AndroidX mappings in a Cordova Android platform project.

This enables a Cordova project for which AndroidX has been enabled (e.g. using cordova-plugin-androidx) to successfully build even if it contains plugins which reference the legacy Support Library.

Source: https://github.com/dpa99c/cordova-plugin-androidx-adapter#readme

Which version of cordova-android are you using?

If you use a lower version than 9.0 then you could try adding the following plugin to your project:

cordova plugin add cordova-plugin-androidx-adapter

My cordova android is version 10.0.0

Sorry, I mixed up cordova-plugin-androidx and cordova-plugin-androidx-adapter when I asked for your current cordova-android version.

You should definitively try to install cordova-plugin-androidx-adapter because the Google Maps plugin is still using the (old) Android Support Library, which is not compatible with AndroidX.

Sorry, I mixed up cordova-plugin-androidx and cordova-plugin-androidx-adapter when I asked for your current cordova-android version.

You should definitively try to install cordova-plugin-androidx-adapter because the Google Maps plugin is still using the (old) Android Support Library, which is not compatible with AndroidX.

Just did and it built successfully, can't thank you enough!!

I have the same Issue. I also was able to fix it using cordova-plugin-androidx-adapter.
But there is another plugin called cordova-androidx-build which was built by @wf9a5m75 who also built cordova-plugin-googlemaps. The description of the plugin says the following:

However cordova-plugin-androidx-adapter works on only your PC, because it uses Cordova Hook Script mechanism. Because of this, cordova-plugin-androidx-adapter does NOT work on cloud build services, such as PhoneGap Build.

I'm using Ionic Appflow, so I can't use cordova-plugin-androidx-adapter. Thats the reason why I'm using the multiple_maps Branch, which comes with cordova-androidx-build and should work with cordova-plugin-googlemaps. But sadly I'm getting an error I've never seen before:

> Task :app:checkDebugDuplicateClasses FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> 1 exception was raised by workers:
  java.lang.RuntimeException: Duplicate class com.google.android.gms.common.api.internal.zza found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-17.3.0-runtime.jar (com.google.android.gms:play-services-basement:17.3.0)
  Duplicate class com.google.android.gms.common.api.internal.zzb found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-17.3.0-runtime.jar (com.google.android.gms:play-services-basement:17.3.0)
  Duplicate class com.google.android.gms.common.api.internal.zzc found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-17.3.0-runtime.jar (com.google.android.gms:play-services-basement:17.3.0)
  Duplicate class com.google.android.gms.common.api.internal.zzd found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-17.3.0-runtime.jar (com.google.android.gms:play-services-basement:17.3.0)
  Duplicate class com.google.android.gms.common.api.zza found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-17.3.0-runtime.jar (com.google.android.gms:play-services-basement:17.3.0)
  Duplicate class com.google.android.gms.common.api.zzb found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-17.3.0-runtime.jar (com.google.android.gms:play-services-basement:17.3.0)
  Duplicate class com.google.android.gms.common.internal.zzb found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-17.3.0-runtime.jar (com.google.android.gms:play-services-basement:17.3.0)
  Duplicate class com.google.android.gms.common.internal.zzc found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-17.3.0-runtime.jar (com.google.android.gms:play-services-basement:17.3.0)
  Duplicate class com.google.android.gms.common.internal.zzd found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-17.3.0-runtime.jar (com.google.android.gms:play-services-basement:17.3.0)
  Duplicate class com.google.android.gms.common.internal.zzf found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-17.3.0-runtime.jar (com.google.android.gms:play-services-basement:17.3.0)
  Duplicate class com.google.android.gms.common.internal.zzg found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-17.3.0-runtime.jar (com.google.android.gms:play-services-basement:17.3.0)
  Duplicate class com.google.android.gms.common.internal.zzk found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-17.3.0-runtime.jar (com.google.android.gms:play-services-basement:17.3.0)
  Duplicate class com.google.android.gms.common.internal.zzl found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-17.3.0-runtime.jar (com.google.android.gms:play-services-basement:17.3.0)
  Duplicate class com.google.android.gms.common.internal.zzm found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-17.3.0-runtime.jar (com.google.android.gms:play-services-basement:17.3.0)
  Duplicate class com.google.android.gms.common.internal.zzn found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-17.3.0-runtime.jar (com.google.android.gms:play-services-basement:17.3.0)
  Duplicate class com.google.android.gms.common.zza found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-17.3.0-runtime.jar (com.google.android.gms:play-services-basement:17.3.0)
  
  Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.

It seems to work if I remove cordova-plugin-purchases and cordova-admob-plus. I really don't know whats going on here.

I had the same error and I was able to fix it by switching to the multiple_maps branch.