Ionic and google maps not compatable?


#1

just updated ionic via npm -g install ionic and google maps isn’t working for me anymore even after clean, removal, and reinstall. What’s going on here?

$ ionic build android
Running command: "/Users/MyUser/Sites/MyApp/hooks/after_prepare/010_add_platform_class.js" "/Users/MyUser/Sites/MyApp"
add to body class: platform-android
Running command: "/Users/MyUser/Sites/MyApp/platforms/android/cordova/build" 
ANDROID_HOME=/Users/MyUser/.android
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home
Running: /Users/MyUser/Sites/MyApp/platforms/android/gradlew cdvBuildDebug -b /Users/MyUser/Sites/MyApp/platforms/android/build.gradle -Dorg.gradle.daemon=true
:preBuild
:compileDebugNdk UP-TO-DATE
:preDebugBuild
:checkDebugManifest
:CordovaLib:compileLint
:CordovaLib:copyDebugLint UP-TO-DATE
:CordovaLib:mergeDebugProguardFiles UP-TO-DATE
:CordovaLib:preBuild
:CordovaLib:preDebugBuild
:CordovaLib:checkDebugManifest
:CordovaLib:prepareDebugDependencies
:CordovaLib:compileDebugAidl UP-TO-DATE
:CordovaLib:compileDebugRenderscript UP-TO-DATE
:CordovaLib:generateDebugBuildConfig UP-TO-DATE
:CordovaLib:generateDebugAssets UP-TO-DATE
:CordovaLib:mergeDebugAssets UP-TO-DATE
:CordovaLib:generateDebugResValues UP-TO-DATE
:CordovaLib:generateDebugResources UP-TO-DATE
:CordovaLib:packageDebugResources UP-TO-DATE
:CordovaLib:processDebugManifest UP-TO-DATE
:CordovaLib:processDebugResources UP-TO-DATE
:CordovaLib:generateDebugSources UP-TO-DATE
:CordovaLib:compileDebugJava UP-TO-DATE
:CordovaLib:processDebugJavaRes UP-TO-DATE
:CordovaLib:packageDebugJar UP-TO-DATE
:CordovaLib:compileDebugNdk UP-TO-DATE
:CordovaLib:packageDebugJniLibs UP-TO-DATE
:CordovaLib:packageDebugLocalJar UP-TO-DATE
:CordovaLib:packageDebugRenderscript UP-TO-DATE
:CordovaLib:bundleDebug UP-TO-DATE
:prepareAndroidCordovaLibUnspecifiedDebugLibrary UP-TO-DATE
:prepareDebugDependencies
:compileDebugAidl UP-TO-DATE
:compileDebugRenderscript UP-TO-DATE
:generateDebugBuildConfig UP-TO-DATE
:generateDebugAssets UP-TO-DATE
:mergeDebugAssets UP-TO-DATE
:generateDebugResValues UP-TO-DATE
:generateDebugResources UP-TO-DATE
:mergeDebugResources UP-TO-DATE
:processDebugManifest UP-TO-DATE
:processDebugResources UP-TO-DATE
:generateDebugSources UP-TO-DATE
:compileDebugJava/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/GoogleMaps.java:15: error: cannot find symbol
import org.apache.cordova.ScrollEvent;
                         ^
  symbol:   class ScrollEvent
  location: package org.apache.cordova
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/GoogleMaps.java:69: error: cannot find symbol
import com.google.android.gms.location.LocationSettingsRequest;
                                      ^
  symbol:   class LocationSettingsRequest
  location: package com.google.android.gms.location
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/GoogleMaps.java:70: error: cannot find symbol
import com.google.android.gms.location.LocationSettingsResult;
                                      ^
  symbol:   class LocationSettingsResult
  location: package com.google.android.gms.location
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/GoogleMaps.java:71: error: cannot find symbol
import com.google.android.gms.location.LocationSettingsStatusCodes;
                                      ^
  symbol:   class LocationSettingsStatusCodes
  location: package com.google.android.gms.location
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/GoogleMaps.java:86: error: cannot find symbol
import com.google.android.gms.maps.OnMapReadyCallback;
                                  ^
  symbol:   class OnMapReadyCallback
  location: package com.google.android.gms.maps
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/GoogleMaps.java:138: error: cannot find symbol
    root = (ViewGroup) webView.getParent();
                              ^
  symbol:   method getParent()
  location: variable webView of type CordovaWebView
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/GoogleMaps.java:197: error: cannot find symbol
          webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
                 ^
  symbol:   method setLayerType(int,<null>)
  location: variable webView of type CordovaWebView
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/GoogleMaps.java:206: error: cannot find symbol
          webView.setBackgroundColor(0);
                 ^
  symbol:   method setBackgroundColor(int)
  location: variable webView of type CordovaWebView
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/GoogleMaps.java:549: error: cannot find symbol
    mapView.getMapAsync(new OnMapReadyCallback() {
                            ^
  symbol:   class OnMapReadyCallback
  location: class GoogleMaps
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/GoogleMaps.java:663: error: cannot find symbol
      ScrollEvent scrollEvent = (ScrollEvent)data;
      ^
  symbol:   class ScrollEvent
  location: class GoogleMaps
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/GoogleMaps.java:663: error: cannot find symbol
      ScrollEvent scrollEvent = (ScrollEvent)data;
                                 ^
  symbol:   class ScrollEvent
  location: class GoogleMaps
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/GoogleMaps.java:789: error: cannot find symbol
    webView.setVisibility(View.GONE);
           ^
  symbol:   method setVisibility(int)
  location: variable webView of type CordovaWebView
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/GoogleMaps.java:807: error: cannot find symbol
        webView.setVisibility(View.VISIBLE);
               ^
  symbol:   method setVisibility(int)
  location: variable webView of type CordovaWebView
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/GoogleMaps.java:879: error: cannot find symbol
          divTop - webView.getScrollY(), 
                          ^
  symbol:   method getScrollY()
  location: variable webView of type CordovaWebView
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/GoogleMaps.java:881: error: cannot find symbol
          divTop + divH - webView.getScrollY());
                                 ^
  symbol:   method getScrollY()
  location: variable webView of type CordovaWebView
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/GoogleMaps.java:992: error: package LocationSettingsRequest does not exist
    LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder();
                           ^
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/GoogleMaps.java:992: error: package LocationSettingsRequest does not exist
    LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder();
                                                                         ^
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/GoogleMaps.java:1005: error: cannot find symbol
    PendingResult<LocationSettingsResult> locationSettingsResult =
                  ^
  symbol:   class LocationSettingsResult
  location: class GoogleMaps
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/GoogleMaps.java:1006: error: cannot find symbol
        LocationServices.SettingsApi.checkLocationSettings(googleApiClient, builder.build());
                        ^
  symbol:   variable SettingsApi
  location: class LocationServices
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/GoogleMaps.java:1008: error: cannot find symbol
    locationSettingsResult.setResultCallback(new ResultCallback<LocationSettingsResult>() {
                                                                ^
  symbol:   class LocationSettingsResult
  location: class GoogleMaps
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/GoogleMaps.java:1011: error: cannot find symbol
      public void onResult(LocationSettingsResult result) {
                           ^
  symbol: class LocationSettingsResult
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/GoogleMaps.java:1014: error: cannot find symbol
          case LocationSettingsStatusCodes.SUCCESS:
               ^
  symbol: variable LocationSettingsStatusCodes
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/GoogleMaps.java:1018: error: cannot find symbol
          case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
               ^
  symbol: variable LocationSettingsStatusCodes
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/GoogleMaps.java:1042: error: cannot find symbol
          case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
               ^
  symbol: variable LocationSettingsStatusCodes
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/MyPluginLayout.java:53: error: cannot find symbol
    this.root = (ViewGroup) webView.getParent();
                                   ^
  symbol:   method getParent()
  location: variable webView of type CordovaWebView
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/MyPluginLayout.java:55: error: cannot find symbol
    webView.setBackgroundColor(Color.TRANSPARENT);
           ^
  symbol:   method setBackgroundColor(int)
  location: variable webView of type CordovaWebView
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/MyPluginLayout.java:57: error: cannot find symbol
      webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
             ^
  symbol:   method setLayerType(int,<null>)
  location: variable webView of type CordovaWebView
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/MyPluginLayout.java:132: error: cannot find symbol
    int scrollY = webView.getScrollY();
                         ^
  symbol:   method getScrollY()
  location: variable webView of type CordovaWebView
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/MyPluginLayout.java:180: error: incompatible types: CordovaWebView cannot be converted to View
    frontLayer.removeView(webView);
                          ^
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/MyPluginLayout.java:191: error: incompatible types: CordovaWebView cannot be converted to View
    root.addView(webView);
                 ^
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/MyPluginLayout.java:200: error: cannot find symbol
    scrollView.scrollTo(webView.getScrollX(), webView.getScrollY());
                               ^
  symbol:   method getScrollX()
  location: variable webView of type CordovaWebView
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/MyPluginLayout.java:200: error: cannot find symbol
    scrollView.scrollTo(webView.getScrollX(), webView.getScrollY());
                                                     ^
  symbol:   method getScrollY()
  location: variable webView of type CordovaWebView
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/MyPluginLayout.java:214: error: no suitable method found for removeView(CordovaWebView)
    root.removeView(webView);
        ^
    method ViewManager.removeView(View) is not applicable
      (argument mismatch; CordovaWebView cannot be converted to View)
    method ViewGroup.removeView(View) is not applicable
      (argument mismatch; CordovaWebView cannot be converted to View)
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/MyPluginLayout.java:221: error: incompatible types: CordovaWebView cannot be converted to View
    frontLayer.addView(webView);
                       ^
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/MyPluginLayout.java:261: error: cannot find symbol
        webView.requestFocus(View.FOCUS_DOWN);
               ^
  symbol:   method requestFocus(int)
  location: variable webView of type CordovaWebView
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/MyPluginLayout.java:266: error: cannot find symbol
      int scrollY = webView.getScrollY();
                           ^
  symbol:   method getScrollY()
  location: variable webView of type CordovaWebView
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/MyPluginLayout.java:292: error: cannot find symbol
        webView.requestFocus(View.FOCUS_DOWN);
               ^
  symbol:   method requestFocus(int)
  location: variable webView of type CordovaWebView
/Users/MyUser/Sites/MyApp/platforms/android/src/plugin/google/maps/MyPluginLayout.java:303: error: cannot find symbol
      int scrollY = webView.getScrollY();
                           ^
  symbol:   method getScrollY()
  location: variable webView of type CordovaWebView
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
38 errors
 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileDebugJava'.
> 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.

BUILD FAILED

Total time: 4.921 secs

/Users/MyUser/Sites/MyApp/platforms/android/cordova/node_modules/q/q.js:126
                    throw e;
                          ^
Error code 1 for command: /Users/MyUser/Sites/MyApp/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/MyUser/Sites/MyApp/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/MyUser/Sites/MyApp/platforms/android/cordova/build: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: /Users/MyUser/Sites/MyApp/platforms/android/cordova/build: Command failed with exit code 1
    at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:134:23)
    at ChildProcess.emit (events.js:110:17)
    at maybeClose (child_process.js:1008:16)
    at Process.ChildProcess._handle.onexit (child_process.js:1080:5)

#2

Google maps web api shouldn’t cause issues with the android build. Are you trying to include the native java google maps sdk?


#3

It’s the oddest thing, this works fine with ios but not with android. Apparently this has been a big issue over at github as well: https://github.com/wf9a5m75/phonegap-googlemaps-plugin/issues/512

You’ll see the last reply in there is my coming up with a hack to get android to build.


#4

Ahh so this is including the native sdks. That explains why it fails building.


#5

Yes I managed to get it working in ios yesterday but no luck with Android.
One small note is that the native plugin is not supported in Cordova 5, so just double check your cordova -v
Also, make sure your API Key is correctly configured in your Android App.

Finally, if you really want to use Cordova 5, I’m not sure why would you at the moment :confounded:, you can refer to this fork by Nipher https://github.com/Nipher/phonegap-googlemaps-plugin


#6

Even web api has got some issues (user location was tracked on browser but failed in android device) and the following method solved it http://stackoverflow.com/questions/30723403/google-maps-on-ionic-framework-cordova-not-working-on-android-build But the permissions here are a nightmare for production use. Now though, I can see the maps I can’t get the geolocation on android.