Cordova-plugin-googlemaps: Not work for the last cordova version 8.0.0

Created on 1 Feb 2018  路  29Comments  路  Source: mapsplugin/cordova-plugin-googlemaps

Im trying a simple cordova project executing the next comands

cordova create map com.map.org Map
cordova platform add browser
cordova platform add android
cordova plugin add cordova-plugin-googlemaps \
    --variable API_KEY_FOR_ANDROID="..." 

i put my api key of course , then when i trie to build android

cordova build android

shows the next error

ap@debian:/opt/ap/www/mapapi$ cordova build android
cp: copyFileSync: could not write to dest file (code=ENOENT):/opt/ap/www/mapapi/platforms/android/res/xml/config.xml

Parsing /opt/ap/www/mapapi/platforms/android/res/xml/config.xml failed
(node:18725) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: ENOENT: no such file or directory, open '/opt/ap/www/mapapi/platforms/android/res/xml/config.xml'
wontfix

Most helpful comment

Hi,
Fixed mine with the same issue

in your platforms/android/build.gradle

add this maven { url "https://maven.google.com" }

allprojects {
repositories {
jcenter()
maven { url "https://maven.google.com" }
}
}

Also check your dependencies should be like this:

dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
// SUB-PROJECT DEPENDENCIES START
debugCompile(project(path: "CordovaLib", configuration: "debug"))
releaseCompile(project(path: "CordovaLib", configuration: "release"))
compile "com.google.android.gms:play-services-maps:11.8.0"
compile "com.google.android.gms:play-services-location:11.8.0"
// SUB-PROJECT DEPENDENCIES END
}

And in your platforms/android/project.properties
target=android-26
android.library.reference.1=CordovaLib
cordova.system.library.1=com.google.android.gms:play-services-maps:11.8.0
cordova.system.library.2=com.google.android.gms:play-services-location:11.8.0

followed this solution: https://stackoverflow.com/questions/47244237/gradle-failed-to-resolve-com-google-android-gmsplay-services-auth11-6-0?rq=1

All 29 comments

If you want to use cordova-android 7.0.0, you need to create an empty project with cordova 8.0.0

The project created with cordova 7.x and install cordova-android 7.0.0 fails for some reason.
This is not this plugin's problem, cordova engine's problem.

The current solution is ether:

  1. create an empty project with cordova 8.0.0 then install the maps plugin, or
  2. down grade the cordova-android from 7.0.0 to 6.x

Tanks wf9a5m75 i create an empty project with cordova 8.0.0 thats my version but still dont work

ap@debian:/opt/ap/www/mapapi$ cordova -v
8.0.0

It only seems to works when downgrade cordova android

cordova plugin save
cordova platform rm android
cordova plagrofm add [email protected]

but there is a problemen with PLAY_SERVICE_VERSION and still dont work.
I tried adding a removein this property from config.xml and the error still been

ANDROID_HOME=/home/ap/Android/Sdk
JAVA_HOME=/home/ap/Programas/jdk1.8.0_25/
Subproject Path: CordovaLib
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_8ykxc2olm6t1iexzydw6fygxq.run(/opt/ap/www/mapapi/platforms/android/build.gradle:137)

FAILURE: Build failed with an exception.

* Where:
Build file '/opt/ap/www/mapapi/platforms/android/build.gradle' line: 252

* What went wrong:
A problem occurred evaluating root project 'android'.
> Could not get unknown property 'PLAY_SERVICES_VERSION' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

* 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: 2.182 secs
(node:22410) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: /opt/ap/www/mapapi/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* Where:
Build file '/opt/ap/www/mapapi/platforms/android/build.gradle' line: 252

* What went wrong:
A problem occurred evaluating root project 'android'.
> Could not get unknown property 'PLAY_SERVICES_VERSION' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

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

I trie resolvin this issue change platform/android/project.properties and put

cordova.system.library.1=com.google.android.gms:play-services-maps:+
cordova.system.library.2=com.google.android.gms:play-services-location:+

With this ther error of play_service_version is fixed but now is a problem in the googlmaps plugin here is the error code.

/opt/ap/www/mapa/cordova/mapa/platforms/android/src/plugin/google/maps/PluginMap.java:84: error: cannot find symbol
    GoogleMap.OnInfoWindowLongClickListener, GoogleMap.OnInfoWindowCloseListener, GoogleMap.OnMyLocationClickListener, GoogleMap.OnPoiClickListener {
                                                                                           ^
  symbol:   class OnMyLocationClickListener
  location: class GoogleMap
/opt/ap/www/mapa/cordova/mapa/platforms/android/src/plugin/google/maps/PluginMap.java:335: error: cannot find symbol
              map.setOnMyLocationClickListener(PluginMap.this);
                 ^
  symbol:   method setOnMyLocationClickListener(PluginMap)
  location: variable map of type GoogleMap
/opt/ap/www/mapa/cordova/mapa/platforms/android/src/plugin/google/maps/PluginMap.java:763: error: cannot find symbol
                  map.setOnMyLocationClickListener(null);
                     ^
  symbol:   method setOnMyLocationClickListener(<null>)
  location: variable map of type GoogleMap
/opt/ap/www/mapa/cordova/mapa/platforms/android/src/plugin/google/maps/PluginMap.java:2490: error: method does not override or implement a method from a supertype
  @Override
  ^
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.
4 errors
:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

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

BUILD FAILED

Total time: 46.001 secs
(node:24680) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: /opt/ap/www/mapa/cordova/mapa/platforms/android/gradlew: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
/opt/ap/www/mapa/cordova/mapa/platforms/android/src/plugin/google/maps/PluginMap.java:84: error: cannot find symbol
    GoogleMap.OnInfoWindowLongClickListener, GoogleMap.OnInfoWindowCloseListener, GoogleMap.OnMyLocationClickListener, GoogleMap.OnPoiClickListener {
                                                                                           ^
  symbol:   class OnMyLocationClickListener
  location: class GoogleMap
/opt/ap/www/mapa/cordova/mapa/platforms/android/src/plugin/google/maps/PluginMap.java:335: error: cannot find symbol
              map.setOnMyLocationClickListener(PluginMap.this);
                 ^
  symbol:   method setOnMyLocationClickListener(PluginMap)
  location: variable map of type GoogleMap
/opt/ap/www/mapa/cordova/mapa/platforms/android/src/plugin/google/maps/PluginMap.java:763: error: cannot find symbol
                  map.setOnMyLocationClickListener(null);
                     ^
  symbol:   method setOnMyLocationClickListener(<null>)
  location: variable map of type GoogleMap
/opt/ap/www/mapa/cordova/mapa/platforms/android/src/plugin/google/maps/PluginMap.java:2490: error: method does not override or implement a method from a supertype
  @Override
  ^
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.
4 errors

FAILURE: Build failed with an exception.

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

* Try:

You need to use the google play services sdk 11.8.0

I have the same problem, downgraded cordova to 7.0.0 and cordova-android to 6.2.3.
The PLAY_SERVICES_VERSION variable is not recognized, so I just wrote:

compile "com.google.android.gms:play-services-maps:11.8.0"
compile "com.google.android.gms:play-services-location:11.8.0"

but it gives me this:

Error:Failed to resolve: com.google.android.gms:play-services-maps:11.8.0
Install Repository and sync project
Open File
Show in Project Structure dialog

Clicking on "Install Repository and sync project" does nothing

The build.gradle file should be like this:

dependencies {
    implementation fileTree(dir: 'libs', include: '*.jar')
    // SUB-PROJECT DEPENDENCIES START
    implementation(project(path: "CordovaLib"))
    compile "com.google.android.gms:play-services-maps:11.8.+"
    compile "com.google.android.gms:play-services-location:11.8.+"
    // SUB-PROJECT DEPENDENCIES END
}

and the project.properties file should be like this:

target=android-26
android.library.reference.1=CordovaLib
cordova.system.library.1=com.google.android.gms:play-services-maps:11.8.+
cordova.system.library.2=com.google.android.gms:play-services-location:11.8.+

Please confirm both files.

play-services-maps:+ is not enough.

This is my dependencies in build.grade:

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    // SUB-PROJECT DEPENDENCIES START
    debugCompile(project(path: "CordovaLib", configuration: "debug"))
    releaseCompile(project(path: "CordovaLib", configuration: "release"))
    compile "com.google.android.gms:play-services:+"
    compile "com.android.support:support-v4:24.1.1+"
    compile "com.facebook.android:facebook-android-sdk:4.14.+"
    compile "com.google.android.gms:play-services-analytics:+"
    compile "com.android.support:support-v4:+"
    compile "com.android.support:appcompat-v7:+"
    compile "com.google.android.gms:play-services-maps:11.8.+"
    compile "com.google.android.gms:play-services-location:11.8.+"
    // SUB-PROJECT DEPENDENCIES END
}

And this is my project.properties:

target=android-26
cordova.system.library.1=com.google.android.gms:play-services:+
cordova.system.library.2=com.android.support:support-v4:24.1.1+
cordova.system.library.3=com.facebook.android:facebook-android-sdk:4.14.+
cordova.system.library.4=com.google.android.gms:play-services-analytics:+
cordova.system.library.5=com.android.support:support-v4:24.1.1+
cordova.system.library.6=com.android.support:support-v4:+
cordova.system.library.7=com.android.support:appcompat-v7:+
android.library.reference.1=CordovaLib
cordova.system.library.8=com.google.android.gms:play-services-maps:11.8.+
cordova.system.library.9=com.google.android.gms:play-services-location:11.8.+

But the same error keep appearing:
Error:Failed to resolve: com.google.android.gms:play-services-maps:11.8.0

I tried to set play-services to 11.8.+ instead of + but it gives me
Error:Failed to resolve: com.google.android.gms:play-services:11.8.+

Specify 11.8.0 instead of +

It changed nothing, same error.

Try to remove other plugins. This plugin requires 11.8.0 but your project does not contain 11.8.0. I can say that is all.

@danieleLewis

cordova.system.library.1=com.google.android.gms:play-services-maps:11.8.0
cordova.system.library.2=com.google.android.gms:play-services-location:11.8.0
cordova.system.library.3=com.android.support:support-v4:24.1.1+
cordova.system.library.4=com.facebook.android:facebook-android-sdk:4.14.+
cordova.system.library.5=com.google.android.gms:play-services-analytics:11.8.0
cordova.system.library.6=com.android.support:appcompat-v7:+
android.library.reference.1=CordovaLib

Hi,
Fixed mine with the same issue

in your platforms/android/build.gradle

add this maven { url "https://maven.google.com" }

allprojects {
repositories {
jcenter()
maven { url "https://maven.google.com" }
}
}

Also check your dependencies should be like this:

dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
// SUB-PROJECT DEPENDENCIES START
debugCompile(project(path: "CordovaLib", configuration: "debug"))
releaseCompile(project(path: "CordovaLib", configuration: "release"))
compile "com.google.android.gms:play-services-maps:11.8.0"
compile "com.google.android.gms:play-services-location:11.8.0"
// SUB-PROJECT DEPENDENCIES END
}

And in your platforms/android/project.properties
target=android-26
android.library.reference.1=CordovaLib
cordova.system.library.1=com.google.android.gms:play-services-maps:11.8.0
cordova.system.library.2=com.google.android.gms:play-services-location:11.8.0

followed this solution: https://stackoverflow.com/questions/47244237/gradle-failed-to-resolve-com-google-android-gmsplay-services-auth11-6-0?rq=1

Hi, I face the same issue.
My cordova version is 7.1.0.

In the Project.properties file
target=android-26
android.library.reference.1=CordovaLib
cordova.system.library.1=com.google.android.gms:play-services-base:11.8.0
cordova.system.library.2=com.android.support:support-v13:26.+
cordova.system.library.3=me.leolin:ShortcutBadger:1.1.17@aar
cordova.system.library.4=com.google.firebase:firebase-messaging:11.0.1
cordova.gradle.include.1=phonegap-plugin-push/abdul_v1-push.gradle
cordova.system.library.5=com.google.android.gms:play-services-maps:11.8.0
cordova.system.library.6=com.google.android.gms:play-services-location:11.8.0

My dependencies are
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
// SUB-PROJECT DEPENDENCIES START
debugCompile(project(path: "CordovaLib", configuration: "debug"))
releaseCompile(project(path: "CordovaLib", configuration: "release"))
compile "com.google.android.gms:play-services-base:11.8.0"
compile "com.android.support:support-v13:26.+"
compile "me.leolin:ShortcutBadger:1.1.17@aar"
compile "com.google.firebase:firebase-messaging:11.0.1"
compile "com.google.android.gms:play-services-maps:11.8.0"
compile "com.google.android.gms:play-services-location:11.8.0"
// SUB-PROJECT DEPENDENCIES END
}

Build Failed:
BUILD FAILED

Total time: 0.692 secs
Error: /gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

  • Where:
    Build file '/build.gradle' line: 252

  • What went wrong:
    A problem occurred evaluating root project 'www_android'.

    Could not get unknown property 'PLAY_SERVICES_VERSION' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Hi @testaccnt0435 ,

have you tried building with sudo ?

@GregFuntera I tried with your solution, now it builds but the application crashes on start.
The log says

E/GoogleMapsPlugin: ---Google Play Services is not available: SERVICE_VERSION_UPDATE_REQUIRED
E/GoogleMapsPlugin: Google Play Services is not available.

It means your phone doesn't have the Google play services framework.

ping

I updated google apis on the emulator and now it works.
Map is giving me other problems but I don't think it's related to this.

Hi, i have the same problem as stated here initially:

cp: copyFileSync: could not write to dest file code=ENOENT):/testProject/platforms/android/res/xml/config.xml

For testing i created a complete new project with cordova 8.0.0 and just added the platform android 7.0.0 and the plugin.
The installation itself seems to work but as soon as i build the error appears.
In this new created project the folder platforms/android/res does not exists at all.

Any suggestions what i can do?

@jtheiss That's cordova-android@7 problem, not this plugin. You try to install cordova-android@7 for the cordova@7 project. That has the bug.
You need to downgrade to cordova-android@6 or you need to create an empty project with cordova@8.
Installation problem is not this plugin's problem.

at first: thanks for your fast response!

As is said i tried an empty project (created with cordova@8) with the same error. (node v9.5.0)

works - thank you!

I'm facing this same issue 馃槩

Total time: 2.565 secs

Error: /mobile/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* Where:
Build file '/mobile/platforms/android/build.gradle' line: 259

* What went wrong:
A problem occurred evaluating root project 'android'.
> Could not get unknown property 'PLAY_SERVICES_VERSION' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

* 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).

build.gradle

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    // SUB-PROJECT DEPENDENCIES START
    debugCompile(project(path: "CordovaLib", configuration: "debug"))
    releaseCompile(project(path: "CordovaLib", configuration: "release"))
    compile "com.android.support:support-v4:24.1.1+"
    compile "com.squareup.okhttp3:okhttp:3+"
    compile "com.android.support:support-core-utils:24.1.0"
    compile "com.google.android.gms:play-services-maps:$PLAY_SERVICES_VERSION"
    compile "com.google.android.gms:play-services-location:$PLAY_SERVICES_VERSION"
    // SUB-PROJECT DEPENDENCIES END
}

project.properties

target=android-25
android.library.reference.1=CordovaLib
cordova.system.library.1=com.android.support:support-v4:24.1.1+
cordova.system.library.2=com.android.support:support-v4:24.1.1+
cordova.system.library.3=com.squareup.okhttp3:okhttp:3+
cordova.system.library.6=com.android.support:support-core-utils:24.1.0
cordova.gradle.include.1=cordova-plugin-googlemaps/www-build-extras.gradle
cordova.gradle.include.2=cordova-plugin-googlemaps/www-tbxml-android.gradle
cordova.system.library.7=com.google.android.gms:play-services-maps:$PLAY_SERVICES_VERSION
cordova.system.library.8=com.google.android.gms:play-services-location:$PLAY_SERVICES_VERSION

I tried removing the $PLAY_SERVICES_VERSION flag and just hardcoding in 11.8.0 for the version but am now presented with this error @wf9a5m75:

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 find com.android.support:support-core-utils:24.1.0.
    Searched in the following locations:
        file:/Users/seanhill/Library/Android/sdk/extras/google/m2repository/com/android/support/support-core-utils/24.1.0/support-core-utils-24.1.0.pom
        file:/Users/seanhill/Library/Android/sdk/extras/google/m2repository/com/android/support/support-core-utils/24.1.0/support-core-utils-24.1.0.jar
        file:/Users/seanhill/Development/Freelance/BikerBuddy/mobile/platforms/android/sdk-manager/com/android/support/support-core-utils/24.1.0/support-core-utils-24.1.0.jar
        file:/Users/seanhill/Library/Android/sdk/extras/android/m2repository/com/android/support/support-core-utils/24.1.0/support-core-utils-24.1.0.pom
        file:/Users/seanhill/Library/Android/sdk/extras/android/m2repository/com/android/support/support-core-utils/24.1.0/support-core-utils-24.1.0.jar
        file:/Users/seanhill/Development/Freelance/BikerBuddy/mobile/platforms/android/sdk-manager/com/android/support/support-core-utils/24.1.0/support-core-utils-24.1.0.jar
    Required by:
        project :
  > Could not find com.google.android.gms:play-services-maps:11.8.0.
    Searched in the following locations:
        file:/Users/seanhill/Library/Android/sdk/extras/google/m2repository/com/google/android/gms/play-services-maps/11.8.0/play-services-maps-11.8.0.pom
        file:/Users/seanhill/Library/Android/sdk/extras/google/m2repository/com/google/android/gms/play-services-maps/11.8.0/play-services-maps-11.8.0.jar
        file:/Users/seanhill/Development/Freelance/BikerBuddy/mobile/platforms/android/sdk-manager/com/google/android/gms/play-services-maps/11.8.0/play-services-maps-11.8.0.jar
        file:/Users/seanhill/Library/Android/sdk/extras/android/m2repository/com/google/android/gms/play-services-maps/11.8.0/play-services-maps-11.8.0.pom
        file:/Users/seanhill/Library/Android/sdk/extras/android/m2repository/com/google/android/gms/play-services-maps/11.8.0/play-services-maps-11.8.0.jar
        file:/Users/seanhill/Development/Freelance/BikerBuddy/mobile/platforms/android/sdk-manager/com/google/android/gms/play-services-maps/11.8.0/play-services-maps-11.8.0.jar
    Required by:
        project :
  > Could not find com.google.android.gms:play-services-location:11.8.0.
    Searched in the following locations:
        file:/Users/seanhill/Library/Android/sdk/extras/google/m2repository/com/google/android/gms/play-services-location/11.8.0/play-services-location-11.8.0.pom
        file:/Users/seanhill/Library/Android/sdk/extras/google/m2repository/com/google/android/gms/play-services-location/11.8.0/play-services-location-11.8.0.jar
        file:/Users/seanhill/Development/Freelance/BikerBuddy/mobile/platforms/android/sdk-manager/com/google/android/gms/play-services-location/11.8.0/play-services-location-11.8.0.jar
        file:/Users/seanhill/Library/Android/sdk/extras/android/m2repository/com/google/android/gms/play-services-location/11.8.0/play-services-location-11.8.0.pom
        file:/Users/seanhill/Library/Android/sdk/extras/android/m2repository/com/google/android/gms/play-services-location/11.8.0/play-services-location-11.8.0.jar
        file:/Users/seanhill/Development/Freelance/BikerBuddy/mobile/platforms/android/sdk-manager/com/google/android/gms/play-services-location/11.8.0/play-services-location-11.8.0.jar
    Required by:
        project :

* 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).

It appears I don't have the google play services version?

screen shot 2018-02-18 at 10 54 08 pm

This is what I have installed:

screen shot 2018-02-18 at 10 55 06 pm

So I fixed this by replacing these lines in my build.gradle file:

// Allow plugins to declare Maven dependencies via build-extras.gradle.
allprojects {
    repositories {
        mavenCentral();
        jcenter()
    }
}

With

// Allow plugins to declare Maven dependencies via build-extras.gradle.
allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

Now I'm presented with another problem, and I'm working on that.

@sean-hill did you do anything before the build to fix? What is the other issue, is it pre-build?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nakulkundaliya picture nakulkundaliya  路  5Comments

cedrickbae picture cedrickbae  路  4Comments

bigbossmaher picture bigbossmaher  路  3Comments

battika picture battika  路  4Comments

wf9a5m75 picture wf9a5m75  路  3Comments