Ionic cordova run android build failed, when I add cordova-plugin-googlemaps

Hi all,
my App work fine in browser except google maps and it’s because of running an browser, when I try to execute “ionic cordova run android” there are some errors, I googled for a few days but unfortunately have no result to solve my issue.
Here are some results:

  • in response of “ionic serve” command:
$ ionic serve -c
Starting app-scripts server: --address 0.0.0.0 --port 8100 --livereload-port 35729 --dev-logger-port 53703 --consolelogs
--nobrowser - Ctrl+C to cancel
[11:07:29]  watch started ...
[11:07:29]  build dev started ...
[11:07:29]  Proxy added:/InterfaceService => http://192.168.252.29:8000/
[11:07:29]  clean started ...
[11:07:29]  clean finished in less than 1 ms
[11:07:29]  copy started ...
[11:07:29]  deeplinks started ...
[11:07:29]  deeplinks finished in 125 ms
[11:07:29]  transpile started ...
[11:07:35]  transpile finished in 6.06 s
[11:07:35]  preprocess started ...
[11:07:35]  preprocess finished in 16 ms
[11:07:35]  webpack started ...
[11:07:36]  copy finished in 6.91 s
[11:07:47]  webpack finished in 11.41 s
[11:07:47]  sass started ...
Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.
[11:07:48]  sass finished in 1.19 s
[11:07:48]  postprocess started ...
[11:07:48]  postprocess finished in less than 1 ms
[11:07:48]  lint started ...
[11:07:48]  build dev finished in 19.47 s
[11:07:48]  watch ready in 19.65 s
[11:07:48]  dev server running: http://localhost:8100/

[OK] Development server running!
     Local: http://localhost:8100
     External: http://172.19.180.17:8100, http://192.168.252.25:8100
     DevApp: Symban@8100 on Shokoienia-PC

[11:07:51]  console.log: Angular is running in the development mode. Call enableProdMode() to enable the production
            mode.
[11:07:51]  console.warn: Native: tried calling StatusBar.styleDefault, but Cordova is not available. Make sure to
            include cordova.js or run in a device/simulator
[11:07:51]  console.warn: Native: tried calling SplashScreen.hide, but Cordova is not available. Make sure to include
            cordova.js or run in a device/simulator
[11:07:54]  lint finished in 5.55 s

but response of “ionic cordova run android”

$ ionic cordova run android --verbose
[DEBUG] Reason for not using local CLI: LOCAL_CLI_NOT_FOUND
[DEBUG] CLI flags: { interactive: true, confirm: false }
[DEBUG] { cwd: 'E:\\projects\\MobileApp\\ionic\\projects\\Symban117\\Symban', local: false, binPath:
        'C:\\Users\\shokoienia\\AppData\\Roaming\\npm\\node_modules\\ionic\\bin\\ionic', libPath:
        'C:\\Users\\shokoienia\\AppData\\Roaming\\npm\\node_modules\\ionic\\dist\\index.js' }
[DEBUG] New daemon pid: 13240
Running app-scripts build: --platform android --target cordova
[11:08:34]  build dev started ...
[11:08:34]  clean started ...
[11:08:34]  clean finished in less than 1 ms
[11:08:34]  copy started ...
[11:08:35]  deeplinks started ...
[11:08:35]  deeplinks finished in 156 ms
[11:08:35]  transpile started ...
[11:08:41]  transpile finished in 6.03 s
[11:08:41]  preprocess started ...
[11:08:41]  preprocess finished in less than 1 ms
[11:08:41]  webpack started ...
[11:08:41]  copy finished in 7.09 s
[11:08:53]  webpack finished in 12.61 s
[11:08:53]  sass started ...
Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.
[11:08:55]  sass finished in 1.25 s
[11:08:55]  postprocess started ...
[11:08:55]  postprocess finished in less than 1 ms
[11:08:55]  lint started ...
[11:08:55]  build dev finished in 20.77 s
> cordova run android
ANDROID_HOME=C:\Users\shokoienia\AppData\Local\Android\Sdk
JAVA_HOME=C:\Program Files\java\jdk1.8.0_151
Subproject Path: CordovaLib
[11:09:01]  lint finished in 6.07 s
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.

        at build_cqdjzt71hh84h9y9l3p3gvkea.run(E:\Projects\MobileApp\ionic\projects\Symban117\Symban\platforms\android\build.gradle:143)
The JavaCompile.setDependencyCacheDir() method has been deprecated and is scheduled to be removed in Gradle 4.0.

Incremental java compilation is an incubating feature.
The TaskInputs.source(Object) method has been deprecated and is scheduled to be removed in Gradle 4.0. Please use TaskInputs.file(Object).skipWhenEmpty() instead.
[Fatal Error] tbxml-android-.pom:2:10: Already seen doctype.

[Fatal Error] play-services-maps-11.8.0.pom:2:10: Already seen doctype.
[Fatal Error] play-services-location-11.8.0.pom:2:10: Already seen doctype.
[Fatal Error] support-core-utils-24.1.0.pom:2:10: Already seen doctype.

Errors during XML parse:
White spaces are required between publicId and systemId.
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 62; White spaces are required between publicId and systemId.
javax.xml.bind.UnmarshalException
 - with linked exception:
[org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 62; White spaces are required between publicId and systemId.]
Additionally, the fallback loader failed to parse the XML.
[Fatal Error] tbxml-android-.pom:2:10: Already seen doctype.

[Fatal Error] play-services-maps-11.8.0.pom:2:10: Already seen doctype.

[Fatal Error] play-services-location-11.8.0.pom:2:10: Already seen doctype.

[Fatal Error] support-core-utils-24.1.0.pom:2:10: Already seen doctype.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':_debugApkCopy'.
   > Could not resolve com.google.android.gms:play-services-maps:11.8.0.
     Required by:
         project :
      > Could not resolve com.google.android.gms:play-services-maps:11.8.0.
         > Could not parse POM https://maven.google.com/com/google/android/gms/play-services-maps/11.8.0/play-services-maps-11.8.0.pom

            > Already seen doctype.
   > Could not resolve com.google.android.gms:play-services-location:11.8.0.
     Required by:
         project :
      > Could not resolve com.google.android.gms:play-services-location:11.8.0.
         > Could not parse POM https://maven.google.com/com/google/android/gms/play-services-location/11.8.0/play-services-location-11.8.0.pom
            >

BUILD FAILED

Total time: 1 mins 29.142 secs
Already seen doctype.
   > Could not resolve com.android.support:support-core-utils:24.1.0.
     Required by:
         project :
      > Could not resolve com.android.support:support-core-utils:24.1.0.
         > Could not parse POM https://maven.google.com/com/android/support/support-core-utils/24.1.0/support-core-utils-24.1.0.pom
            > Already seen doctype.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Error: cmd: Command failed with exit code 1 Error output:
[Fatal Error] tbxml-android-.pom:2:10: Already seen doctype.
[Fatal Error] play-services-maps-11.8.0.pom:2:10: Already seen doctype.
[Fatal Error] play-services-location-11.8.0.pom:2:10: Already seen doctype.
[Fatal Error] support-core-utils-24.1.0.pom:2:10: Already seen doctype.
[Fatal Error] tbxml-android-.pom:2:10: Already seen doctype.
[Fatal Error] play-services-maps-11.8.0.pom:2:10: Already seen doctype.
[Fatal Error] play-services-location-11.8.0.pom:2:10: Already seen doctype.
[Fatal Error] support-core-utils-24.1.0.pom:2:10: Already seen doctype.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':_debugApkCopy'.
   > Could not resolve com.google.android.gms:play-services-maps:11.8.0.
     Required by:
         project :
      > Could not resolve com.google.android.gms:play-services-maps:11.8.0.
         > Could not parse POM https://maven.google.com/com/google/android/gms/play-services-maps/11.8.0/play-services-maps-11.8.0.pom
            > Already seen doctype.
   > Could not resolve com.google.android.gms:play-services-location:11.8.0.
     Required by:
         project :
      > Could not resolve com.google.android.gms:play-services-location:11.8.0.
         > Could not parse POM https://maven.google.com/com/google/android/gms/play-services-location/11.8.0/play-services-location-11.8.0.pom
            > Already seen doctype.
   > Could not resolve com.android.support:support-core-utils:24.1.0.
     Required by:
         project :
      > Could not resolve com.android.support:support-core-utils:24.1.0.
         > Could not parse POM https://maven.google.com/com/android/support/support-core-utils/24.1.0/support-core-utils-24.1.0.pom
            > Already seen doctype.

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

[ERROR] An error occurred while running cordova run android (exit code 1).

[DEBUG] registerShutdownFunction process.exit/normal shutdown

After a week I’m confused and don’t know how can I solve this problem.
Any Ideas?
Thanks in advanced

Actually I tried to update ionic CLI, remove and add android platform, update android SDK and so on but there were no success in the way. :sleepy::sleepy:

@alishokoie

could you print your ionic info here

thanks

Hi addwebsolution, Thank you for your attention, here is my ionic info

$ ionic info

cli packages: (C:\Users\shokoienia\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.19.1
    ionic (Ionic CLI) : 3.19.1

global packages:

    cordova (Cordova CLI) : 7.1.0

local packages:

    @ionic/app-scripts : 3.1.7
    Cordova Platforms  : android 6.3.0
    Ionic Framework    : ionic-angular 3.6.0

System:

    Android SDK Tools : 26.1.1
    Node              : v8.9.4
    npm               : 4.6.1
    OS                : Windows 10

Environment Variables:

    ANDROID_HOME : C:\Users\shokoienia\AppData\Local\Android\Sdk

Misc:

    backend : pro

r u using location plugin or push notification plugin ??

I don’t understand what r u mean, but here is my package.json

{
  "name": "Symban",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "4.1.3",
    "@angular/compiler": "4.1.3",
    "@angular/compiler-cli": "4.1.3",
    "@angular/core": "4.1.3",
    "@angular/forms": "4.1.3",
    "@angular/http": "4.1.3",
    "@angular/platform-browser": "4.1.3",
    "@angular/platform-browser-dynamic": "4.1.3",
    "@ionic-native/core": "3.12.1",
    "@ionic-native/google-maps": "^4.5.3",
    "@ionic-native/splash-screen": "3.12.1",
    "@ionic-native/status-bar": "3.12.1",
    "@ionic/storage": "^2.0.1",
    "cordova-plugin-add-swift-support": "^1.7.1",
    "cordova-plugin-compat": "^1.0.0",
    "cordova-plugin-console": "^1.0.5",
    "cordova-plugin-device": "^1.1.4",
    "cordova-plugin-geolocation": "^2.4.3",
    "cordova-plugin-googlemaps": "^2.2.5",
    "cordova-plugin-ionic": "^2.0.4",
    "cordova-plugin-splashscreen": "^4.0.3",
    "cordova-plugin-statusbar": "^2.2.2",
    "cordova-plugin-whitelist": "^1.3.1",
    "cordova-sqlite-storage": "^2.0.4",
    "ionic-angular": "3.6.0",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionicons": "3.0.0",
    "jalali-moment": "^3.0.6",
    "rxjs": "5.4.0",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.12",
    "cordova-android": "~6.3.0"
  },
  "devDependencies": {
    "@ionic/app-scripts": "^3.1.7",
    "css-loader": "^0.28.7",
    "file-loader": "^1.1.5",
    "style-loader": "^0.19.0",
    "typescript": "2.3.4"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-sqlite-storage": {},
      "cordova-plugin-console": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-whitelist": {},
      "ionic-plugin-keyboard": {},
      "cordova-plugin-geolocation": {},
      "cordova-plugin-ionic": {
        "APP_ID": "e74c0be0",
        "CHANNEL_NAME": "Master",
        "UPDATE_METHOD": "background",
        "UPDATE_API": "https://api.ionicjs.com",
        "MAX_STORE": "2"
      },
      "cordova-plugin-googlemaps": {
        "API_KEY_FOR_ANDROID": "MY_API_KEY",
        "PLAY_SERVICES_VERSION": "11.8.0",
        "ANDROID_SUPPORT_V4_VERSION": "24.1.0"
      }
    },
    "platforms": [
      "android"
    ]
  }
}

@alishokoie

try below command

$ npm install -g ionic@3.19.0

thanks

You probably need to install a few more SDK parts.
Open Android Studio SDK manager:

  • in SDK platforms tab check “show package details”, make sure Google APIs are installed for Android 6.0 (or whichever is your target)
  • in SDK tools tab check “show package details”, make sure Google play services is installed
1 Like

Hi all,
In last few days I tried all suggestions, and so forth tried to create again the project from scratch and added all pages and plugins one by one. Everything was okay and my app worked fine on browser, emulator and also on device but as I added cordova-plugin-googlemaps and ionic-native without any usage code same error has been occured only for emulator and device. that means when I execute “ionic serve” command, app works as expected.
Anyone can help me to solve this issue ?
Thanks in advanced

In new project creation the information as follows:

$ ionic info

cli packages: (C:\Users\shokoienia\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.19.0
    ionic (Ionic CLI) : 3.19.0

global packages:

    cordova (Cordova CLI) : 7.1.0

local packages:

    @ionic/app-scripts : 3.1.8
    Cordova Platforms  : android 6.3.0
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 26.1.1
    Node              : v8.9.4
    npm               : 4.6.1
    OS                : Windows 10

Environment Variables:

    ANDROID_HOME : C:\Users\shokoienia\AppData\Local\Android\Sdk

Misc:

    backend : pro


$ cordova plugin list
cordova-plugin-device 2.0.1 "Device"
cordova-plugin-googlemaps 2.2.5 "cordova-plugin-googlemaps"
cordova-plugin-ionic-keyboard 2.0.5 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 1.1.16 "cordova-plugin-ionic-webview"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.1 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova-sqlite-storage 2.2.1 "Cordova sqlite storage plugin"

have anyone an idea in this issue?

Hey @alishokoie
I think You did not installed the google map plugin in right way.
Because your package.json does not have a proper API KEY.
So try to install the plugin correctly.
Please let me know if it works

 "cordova-plugin-googlemaps": {
        "API_KEY_FOR_ANDROID": "MY_API_KEY",
        "PLAY_SERVICES_VERSION": "11.8.0",
        "ANDROID_SUPPORT_V4_VERSION": "24.1.0"
      }
Add the Api key while you install the plugin
$ ionic cordova plugin add cordova-plugin-googlemaps --variable API_KEY_FOR_ANDROID="YOUR_ANDROID_API_KEY_IS_HERE" --variable API_KEY_FOR_IOS="YOUR_IOS_API_KEY_IS_HERE"
$ npm install --save @ionic-native/google-maps

Check out this thread.

This might help to solve the problem.

Hi @vibinflogesoft,
MY_API_KEY is my GOOGLE_API_KEY_FOR_ANDROID and I wanted to secure my real key

@alishokoie thats Ok.Did you install the plugin correctly?

Thank you @vibinflogesoft for your replay.
Yes it installed without any problem or error, but after installation of plugin, i encounter with this error

Thank you @wf9a5m75 for your answer, but I don’t understand what do you mean, because I don’t used
cordova-android-play-services-gradle-release and it isn’t in my cordova plugin list and in addition the point of defaultBuildToolsVersion . Can you please describe a little deeper what do you mean.
regards

@alishokoie
Try this too.This may help you

1.rm -rf node_modules
2.npm install

Thanks @vibinflogesoft, I try this and will be share the result

Hi @vibinflogesoft, I tried

1.rm -rf node_modules
2.npm install

successfully, but unfortunately errors still, exactly same errors!