Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please fix the version conflict either by updating the version of the google-services plugin #21

Closed
dsmatana opened this issue Oct 7, 2016 · 16 comments

Comments

@dsmatana
Copy link

dsmatana commented Oct 7, 2016

Hello

This happened after installation of plugin and running :

Any clues what to do ?
I have Cordova version 6.3.1
Thanks

Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

@dpa99c
Copy link
Owner

dpa99c commented Oct 7, 2016

This most likely cause it that another plugin in your project has specified a specific version of the Google Play Services library (similar to #8). Plugins that do so will cause errors to be raised when another plugin specifies a different version of the library. For that reason, this plugin specifies the latest version of the Google Play Services library. If all plugins did this, there would be no conflict.

I suggest looking at plugin.xml files in the other plugins in your project and figuring out which one is pinning the version of Google Play Services. Then you can work around by, for example, forking that plugin to unpin the library version.

@dsmatana
Copy link
Author

dsmatana commented Oct 7, 2016

I am complete noob about how plugins work in cordova.

This is my plugin list:
cordova-plugin-compat 1.0.0 "Compat"
cordova-plugin-device 1.1.3 "Device"
cordova-plugin-fcm 1.1.4 "FCMPlugin"
cordova-plugin-geolocation 2.2.0 "Geolocation"
cordova-plugin-inappbrowser 1.4.0 "InAppBrowser"
cordova-plugin-request-location-accuracy 2.1.1 "Request Location Accuracy"
cordova-plugin-splashscreen 4.0.0 "Splashscreen"
cordova-plugin-whitelist 1.2.2 "Whitelist"

I think possible problem is in FCMPlugin but its plugin.xml does not contain any "com.google.android.gms" phrases.

@dpa99c
Copy link
Owner

dpa99c commented Oct 7, 2016

The FCMPlugin uses a gradle file to specify v9.2.0 of firebase library which in turn specifies v9.2.0 of Google Play Services.

In this case, your quickest fix might be to hack (fork) this plugin to to specify in v9.2.0 the plugin.xml, which would resolve the conflict. You'd then need to remove the existing plugin from the project and re-add this modified version:

<framework src="com.google.android.gms:play-services-location:9.2.0" />

Or you could manually fix it in the Android project by editing platforms/android/build.gradle:

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

@dsmatana
Copy link
Author

dsmatana commented Oct 7, 2016

I changed line in build.gradle from
compile "com.google.android.gms:play-services-location:+"
to
compile "com.google.android.gms:play-services-location:9.2.0"

Cordova before build keeps changing it to previous state with + char
Result is the same.

Also tried first solution, nothing happened again.

Here is mine build.gradle: build.gradle.zip

@dpa99c
Copy link
Owner

dpa99c commented Oct 7, 2016

Just to clarify, editing 'plugins/cordova-plugin-request-location-accuracy/plugin.xml` will do no good. You need to either:

  • make a local copy of 'plugins/cordova-plugin-request-location-accuracy`
  • edit the plugin.xml of the local copy
  • remove the plugin from the project: cordova plugin rm cordova-plugin-request-location-accuracy
  • remove & re-add the Android platform: cordova platform rm android && cordova platform add android
  • then install the local copy of your plugin: cordova plugin add /path/to/local/cordova-plugin-request-location-accuracy

OR

  • fork https://github.com/dpa99c/cordova-plugin-request-location-accuracy
  • clone your copy: git clone https://github.com/yourUserName/cordova-plugin-request-location-accuracy
  • edit the plugin.xml of the checkout repo
  • commit and push the changes to github
  • remove the plugin from the project: cordova plugin rm cordova-plugin-request-location-accuracy
  • remove & re-add the Android platform: cordova platform rm android && cordova platform add android
  • then install your forked version plugin: cordova plugin add https://github.com/yourUserName/cordova-plugin-request-location-accuracy

@dsmatana
Copy link
Author

dsmatana commented Oct 7, 2016

Ok, tried your first solution.
Removed and readded android platform, edited and installed local plugin
Line in build.gradle is compile "com.google.android.gms:play-services-location:9.2.0"
That's what we wanted

But cordova can't resolve dependencies. Do I have to install it manually ?
BTW this happened to me with other plugins. What's general solution for this ?

image

@dpa99c
Copy link
Owner

dpa99c commented Oct 7, 2016

You'll have to remove/re-add the FCM plugin as well to get it to re-add it's gradle stuff

@dsmatana
Copy link
Author

dsmatana commented Oct 7, 2016

Removal and reinstall of cordova-plugin-fcm plugin not helped.

I tried to install clean version of your plugin
cordova plugin add https://github.com/dpa99c/cordova-plugin-request-location-accuracy.git
with + at dependency line on a clean android platform without cordova-plugin-fcm plugin

At least error is changed :D
image

@dpa99c
Copy link
Owner

dpa99c commented Oct 10, 2016

Try cloning and building the example project to verify your build environment has the necessary prerequisites installed and configured.

@dpa99c
Copy link
Owner

dpa99c commented Oct 16, 2016

Reopen if still an issue

@dpa99c dpa99c closed this as completed Oct 16, 2016
@lalitbadule
Copy link

Hi,
I am facing below issue in android version 2.3.1. Instant run enable or disable same error throw.
Plz, Guys solution for this issue.

Error:Execution failed for task ':app:transformClassesWithJarMergingForB2bpratapefoodsDebug'.

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/location/places/PlaceReport.class

@lalitbadule
Copy link

Any solution plz notify on my mail
lalitbadule@gmail.com
I m so tired.

@yellaiahd
Copy link

you might have phonegap-plugin-push and cordova-plugin-fcm and both are using different verison.
remove phonegap-plugin-push and check it. anyway phonegap-plugin-push does not required after fcm

@dpa99c
Copy link
Owner

dpa99c commented Jun 21, 2017

As a workaround for build issues caused by different versions of the Play Services library specified by different plugins, you can install cordova-android-play-services-gradle-release into the project. This will override any versions set by other plugins and align them to be the same.

The published master branch defaults to the latest release (currently v11):

cordova plugin add cordova-android-play-services-gradle-release

If you need another version (e.g v9), install from the relevant git branch:

cordova plugin add https://github.com/dpa99c/cordova-android-play-services-gradle-release#v9

@NileshSystematix
Copy link

NileshSystematix commented Aug 29, 2017

I am also getting below issue.

Error:Execution failed for task ':processDebugGoogleServices'.

Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 9.0.0.

I have also done the changes in plugin.xml. In my project I have to use 2 plugins fcm and location accuracy.

Below is my gradle file:

/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.

*/

apply plugin: 'com.android.application'

buildscript {
repositories {
mavenCentral()
jcenter()
}

// Switch the Android Gradle plugin version requirement depending on the
// installed version of Gradle. This dependency is documented at
// http://tools.android.com/tech-docs/new-build-system/version-compatibility
// and https://issues.apache.org/jira/browse/CB-8143
dependencies {
    classpath 'com.android.tools.build:gradle:2.2.3'
}

}

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

task wrapper(type: Wrapper) {
gradleVersion = '2.14.1'
}

// Configuration properties. Set these via environment variables, build-extras.gradle, or gradle.properties.
// Refer to: http://www.gradle.org/docs/current/userguide/tutorial_this_and_that.html
ext {
apply from: 'CordovaLib/cordova.gradle'
// The value for android.compileSdkVersion.
if (!project.hasProperty('cdvCompileSdkVersion')) {
cdvCompileSdkVersion = null;
}
// The value for android.buildToolsVersion.
if (!project.hasProperty('cdvBuildToolsVersion')) {
cdvBuildToolsVersion = null;
}
// Sets the versionCode to the given value.
if (!project.hasProperty('cdvVersionCode')) {
cdvVersionCode = null
}
// Sets the minSdkVersion to the given value.
if (!project.hasProperty('cdvMinSdkVersion')) {
cdvMinSdkVersion = null
}
// Whether to build architecture-specific APKs.
if (!project.hasProperty('cdvBuildMultipleApks')) {
cdvBuildMultipleApks = null
}
// .properties files to use for release signing.
if (!project.hasProperty('cdvReleaseSigningPropertiesFile')) {
cdvReleaseSigningPropertiesFile = null
}
// .properties files to use for debug signing.
if (!project.hasProperty('cdvDebugSigningPropertiesFile')) {
cdvDebugSigningPropertiesFile = null
}
// Set by build.js script.
if (!project.hasProperty('cdvBuildArch')) {
cdvBuildArch = null
}

// Plugin gradle extensions can append to this to have code run at the end.
cdvPluginPostBuildExtras = []

}

// PLUGIN GRADLE EXTENSIONS START
apply from: "cordova-android-play-services-gradle-release/smartapp-cordova-android-play-services-gradle-release.gradle"
apply from: "cordova-plugin-fcm/smartapp-FCMPlugin.gradle"
// PLUGIN GRADLE EXTENSIONS END

def hasBuildExtras = file('build-extras.gradle').exists()
if (hasBuildExtras) {
apply from: 'build-extras.gradle'
}

// Set property defaults after extension .gradle files.
if (ext.cdvCompileSdkVersion == null) {
ext.cdvCompileSdkVersion = privateHelpers.getProjectTarget()
}
if (ext.cdvBuildToolsVersion == null) {
ext.cdvBuildToolsVersion = privateHelpers.findLatestInstalledBuildTools()
}
if (ext.cdvDebugSigningPropertiesFile == null && file('debug-signing.properties').exists()) {
ext.cdvDebugSigningPropertiesFile = 'debug-signing.properties'
}
if (ext.cdvReleaseSigningPropertiesFile == null && file('release-signing.properties').exists()) {
ext.cdvReleaseSigningPropertiesFile = 'release-signing.properties'
}

// Cast to appropriate types.
ext.cdvBuildMultipleApks = cdvBuildMultipleApks == null ? false : cdvBuildMultipleApks.toBoolean();
ext.cdvMinSdkVersion = cdvMinSdkVersion == null ? null : Integer.parseInt('' + cdvMinSdkVersion)
ext.cdvVersionCode = cdvVersionCode == null ? null : Integer.parseInt('' + cdvVersionCode)

def computeBuildTargetName(debugBuild) {
def ret = 'assemble'
if (cdvBuildMultipleApks && cdvBuildArch) {
def arch = cdvBuildArch == 'arm' ? 'armv7' : cdvBuildArch
ret += '' + arch.toUpperCase().charAt(0) + arch.substring(1);
}
return ret + (debugBuild ? 'Debug' : 'Release')
}

// Make cdvBuild a task that depends on the debug/arch-sepecific task.
task cdvBuildDebug
cdvBuildDebug.dependsOn {
return computeBuildTargetName(true)
}

task cdvBuildRelease
cdvBuildRelease.dependsOn {
return computeBuildTargetName(false)
}

task cdvPrintProps << {
println('cdvCompileSdkVersion=' + cdvCompileSdkVersion)
println('cdvBuildToolsVersion=' + cdvBuildToolsVersion)
println('cdvVersionCode=' + cdvVersionCode)
println('cdvMinSdkVersion=' + cdvMinSdkVersion)
println('cdvBuildMultipleApks=' + cdvBuildMultipleApks)
println('cdvReleaseSigningPropertiesFile=' + cdvReleaseSigningPropertiesFile)
println('cdvDebugSigningPropertiesFile=' + cdvDebugSigningPropertiesFile)
println('cdvBuildArch=' + cdvBuildArch)
println('computedVersionCode=' + android.defaultConfig.versionCode)
android.productFlavors.each { flavor ->
println('computed' + flavor.name.capitalize() + 'VersionCode=' + flavor.versionCode)
}
}

android {
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}

defaultConfig {
    versionCode cdvVersionCode ?: new BigInteger("" + privateHelpers.extractIntFromManifest("versionCode"))
    applicationId privateHelpers.extractStringFromManifest("package")

    if (cdvMinSdkVersion != null) {
        minSdkVersion cdvMinSdkVersion
    }
}

lintOptions {
  abortOnError false;
}

compileSdkVersion cdvCompileSdkVersion
buildToolsVersion cdvBuildToolsVersion

if (Boolean.valueOf(cdvBuildMultipleApks)) {
    productFlavors {
        armv7 {
            versionCode defaultConfig.versionCode*10 + 2
            ndk {
                abiFilters "armeabi-v7a", ""
            }
        }
        x86 {
            versionCode defaultConfig.versionCode*10 + 4
            ndk {
                abiFilters "x86", ""
            }
        }
        all {
            ndk {
                abiFilters "all", ""
            }
        }
    }
}
/*

ELSE NOTHING! DON'T MESS WITH THE VERSION CODE IF YOU DON'T HAVE TO!

else if (!cdvVersionCode) {
  def minSdkVersion = cdvMinSdkVersion ?: privateHelpers.extractIntFromManifest("minSdkVersion")
  // Vary versionCode by the two most common API levels:
  // 14 is ICS, which is the lowest API level for many apps.
  // 20 is Lollipop, which is the lowest API level for the updatable system webview.
  if (minSdkVersion >= 20) {
    defaultConfig.versionCode += 9
  } else if (minSdkVersion >= 14) {
    defaultConfig.versionCode += 8
  }
}
*/

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_6
    targetCompatibility JavaVersion.VERSION_1_6
}

if (cdvReleaseSigningPropertiesFile) {
    signingConfigs {
        release {
            // These must be set or Gradle will complain (even if they are overridden).
            keyAlias = ""
            keyPassword = "__unset" // And these must be set to non-empty in order to have the signing step added to the task graph.
            storeFile = null
            storePassword = "__unset"
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }
    addSigningProps(cdvReleaseSigningPropertiesFile, signingConfigs.release)
}
if (cdvDebugSigningPropertiesFile) {
    addSigningProps(cdvDebugSigningPropertiesFile, signingConfigs.debug)
}

}

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.google.firebase:firebase-core:+"
compile "com.google.firebase:firebase-messaging:+"
compile "com.google.android.gms:play-services-location:10.2.1"
compile "com.android.support:support-v4:25.+"
compile "com.android.support:appcompat-v7:25.+"
// SUB-PROJECT DEPENDENCIES END
}

def promptForReleaseKeyPassword() {
if (!cdvReleaseSigningPropertiesFile) {
return;
}
if ('__unset'.equals(android.signingConfigs.release.storePassword)) {
android.signingConfigs.release.storePassword = privateHelpers.promptForPassword('Enter key store password: ')
}
if ('__unset'.equals(android.signingConfigs.release.keyPassword)) {
android.signingConfigs.release.keyPassword = privateHelpers.promptForPassword('Enter key password: ');
}
}

gradle.taskGraph.whenReady { taskGraph ->
taskGraph.getAllTasks().each() { task ->
if (task.name == 'validateReleaseSigning' || task.name == 'validateSigningRelease') {
promptForReleaseKeyPassword()
}
}
}

def addSigningProps(propsFilePath, signingConfig) {
def propsFile = file(propsFilePath)
def props = new Properties()
propsFile.withReader { reader ->
props.load(reader)
}

def storeFile = new File(props.get('key.store') ?: privateHelpers.ensureValueExists(propsFilePath, props, 'storeFile'))
if (!storeFile.isAbsolute()) {
    storeFile = RelativePath.parse(true, storeFile.toString()).getFile(propsFile.getParentFile())
}
if (!storeFile.exists()) {
    throw new FileNotFoundException('Keystore file does not exist: ' + storeFile.getAbsolutePath())
}
signingConfig.keyAlias = props.get('key.alias') ?: privateHelpers.ensureValueExists(propsFilePath, props, 'keyAlias')
signingConfig.keyPassword = props.get('keyPassword', props.get('key.alias.password', signingConfig.keyPassword))
signingConfig.storeFile = storeFile
signingConfig.storePassword = props.get('storePassword', props.get('key.store.password', signingConfig.storePassword))
def storeType = props.get('storeType', props.get('key.store.type', ''))
if (!storeType) {
    def filename = storeFile.getName().toLowerCase();
    if (filename.endsWith('.p12') || filename.endsWith('.pfx')) {
        storeType = 'pkcs12'
    } else {
        storeType = signingConfig.storeType // "jks"
    }
}
signingConfig.storeType = storeType

}

for (def func : cdvPluginPostBuildExtras) {
func()
}

// This can be defined within build-extras.gradle as:
// ext.postBuildExtras = { ... code here ... }
if (hasProperty('postBuildExtras')) {
postBuildExtras()
}

FCM Gradle:

buildscript {
repositories {
jcenter()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:3.0.0'
}
}
// apply plugin: 'com.google.gms.google-services'
// class must be used instead of id(string) to be able to apply plugin from non-root gradle file
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin

plugin.xml:

<name>Request Location Accuracy</name>
<description>Cordova/Phonegap plugin for Android and iOS to request enabling/changing of Location Services by triggering a native dialog</description>
<author>Dave Alden</author>
<engines>
    <engine name="cordova" version=">=3.0.0" />
</engines>

<repo>https://github.com/dpa99c/cordova-plugin-request-location-accuracy.git</repo>
<issue>https://github.com/dpa99c/cordova-plugin-request-location-accuracy/issues</issue>
<keywords>ecosystem:cordova,cordova,phonegap,android,diagnostic,location,accuracy,high accuracy,fine accuracy,gps,settings</keywords>
<license>MIT</license>

<platform name="android">
    <config-file target="config.xml" parent="/*">
        <feature name="RequestLocationAccuracy" >
            <param name="android-package" value="cordova.plugin.RequestLocationAccuracy"/>
        </feature>
    </config-file>

    <js-module src="www/android/RequestLocationAccuracy.js" name="RequestLocationAccuracy">
        <clobbers target="cordova.plugins.locationAccuracy" />
    </js-module>

    <source-file src="src/android/RequestLocationAccuracy.java" target-dir="src/cordova/plugin" />

    <framework src="com.google.android.gms:play-services-location:10.2.1" />
</platform>

<platform name="ios">

    <js-module src="www/ios/RequestLocationAccuracy.js" name="RequestLocationAccuracy">
        <clobbers target="cordova.plugins.locationAccuracy" />
    </js-module>

    <config-file target="config.xml" parent="/*">
        <feature name="RequestLocationAccuracy">
            <param name="ios-package" value="RequestLocationAccuracy"/>
        </feature>
    </config-file>

    <header-file src="src/ios/RequestLocationAccuracy.h" />
    <source-file src="src/ios/RequestLocationAccuracy.m" />

    <framework src="CoreLocation.framework" />
</platform>

Please check the below url of module settings screenshot:

https://screencast.com/t/XJHX6eUoc

Please help me asap...

@cikcoh
Copy link

cikcoh commented Jul 30, 2018

Hi, i'm using both fcm-plugin and googleplus-plugin
i have installed;

    <plugin name="cordova-android-firebase-gradle-release" spec="^1.0.2">
        <variable name="FIREBASE_VERSION" value="15.+" />
    </plugin>
    <plugin name="cordova-android-play-services-gradle-release" spec="https://github.com/dpa99c/cordova-android-play-services-gradle-release#v9">
        <variable name="PLAY_SERVICES_VERSION" value="15.+" />
    </plugin>

BUT still got ERROR:
Execution failed for task ':processDebugGoogleServices'.

Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 9.0.0.

also this;
Found com.google.android.gms:play-services-auth:11.8.0, but version 9.0.0 is needed for the google-services plugin.
Found com.google.android.gms:play-services-identity:11.8.0, but version 9.0.0 is needed for the google-services plugin.
:processDebugGoogleServices FAILED

UPDATE:
i tried with
cordova plugin add cordova-android-firebase-gradle-release --variable FIREBASE_VERSION=9.0.0
cordova plugin add cordova-android-play-services-gradle-release --variable PLAY_SERVICES_VERSION=9.0.0

BUT play service ver doesnt change,only firebase;
compile "com.google.firebase:firebase-core:9.0.0"
compile "com.google.firebase:firebase-messaging:9.0.0"
compile "com.squareup.okhttp3:okhttp:3.+"
compile "com.android.support:support-v4:24.1.1+"
compile "com.google.android.gms:play-services-auth:11.8.0"
compile "com.google.android.gms:play-services-identity:11.8.0"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants