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

Failed to apply plugin [class 'com.google.gms.googleservices.GoogleServicesPlugin'] > For input string: "+", again #742

Closed
rtm opened this issue Jun 18, 2018 · 19 comments

Comments

@rtm
Copy link

rtm commented Jun 18, 2018

Even after installing cordova-android-{firebase,support,play-services}-gradle-release, I still get

Failed to apply plugin [class 'com.google.gms.googleservices.GoogleServicesPlugin']
   > For input string: "+"

I notice the following two lines referring to different versions of com.google.gms:google-servcies:

plugins/cordova-plugin-firebase/src/android/build.gradle:6:        classpath 'com.google.gms:google-services:3.1.0'
plugins/cordova-support-google-services/build.gradle:9:        classpath 'com.google.gms:google-services:3.2.0'

Could this 3.1.0 vs. 3.2.0 be the problem, and if so how would one deal with that?

I am also using cordova-plugin-firebase-dynamiclinks, if that is relevant.
I notice that there is a version 1.2 of the google services plugin, which references v4.0 of com.google.gms:google-services; is there any point in trying that?

@dlaudh
Copy link

dlaudh commented Jun 20, 2018

Hi @rtm for fix this problem go to
/platforms/android/cordova-support-google-services

In this directory find the file {APP}-build.gradle

Open and comment the next line

apply plugin: com.google.gms.googleservices.GoogleServicesPlugin

Next, re run

ionice cordova run android

@vc-hitesh
Copy link

vc-hitesh commented Jun 26, 2018

Hello @rtm rtm,

I have faced similar issue of this. To resolve this issue open that gradle and replace + to a specific version.
classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:+'
change that to:
classpath 'com.android.tools.build:gradle:2.2.1'
classpath 'com.google.gms:google-services:3.1.1'

Also, make same version of firebase in project.properties.
cordova.system.library.1=com.google.android.gms:play-services-base:11.8.0
cordova.system.library.2=com.google.android.gms:play-services-ads:11.8.0
cordova.system.library.5=com.google.android.gms:play-services-tagmanager:11.8.0
cordova.system.library.6=com.google.firebase:firebase-core:11.8.0
cordova.system.library.7=com.google.firebase:firebase-messaging:11.8.0
cordova.system.library.8=com.google.firebase:firebase-crash:11.8.0
cordova.system.library.9=com.google.firebase:firebase-config:11.8.0
cordova.system.library.10=com.google.firebase:firebase-perf:11.8.0

@angemimi
Copy link

angemimi commented Aug 2, 2018

Thank you very much @dualh

@soumak77
Copy link
Contributor

closing as resolved

@mesqueeb
Copy link

mesqueeb commented Jan 17, 2019

Hello everyone (and especially @dualh and @vc-hitesh )

I first had the problem with input string "+". Then when trying some solutions from here:
go to /platforms/android/cordova-support-google-services and change to

  • classpath 'com.android.tools.build:gradle:2.2.1' (which was +)

And then in the same file comment out this line:
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin

But.... I now get a lot of version mismatch errors:

image

I can see that versions are still mismatched in platforms/android/project.properties:

# Project target.
target=android-27
android.library.reference.1=CordovaLib
android.library.reference.2=app
cordova.gradle.include.1=cordova-android-firebase-gradle-release/cinematch-cordova-android-firebase-gradle-release.gradle
cordova.gradle.include.2=cordova-android-play-services-gradle-release/cinematch-cordova-android-play-services-gradle-release.gradle
cordova.gradle.include.3=cordova-plugin-firebase/cinematch-build.gradle
cordova.system.library.1=com.google.android.gms:play-services-tagmanager:+
cordova.system.library.2=com.google.firebase:firebase-core:+
cordova.system.library.3=com.google.firebase:firebase-messaging:+
cordova.system.library.4=com.google.firebase:firebase-config:+
cordova.system.library.5=com.google.firebase:firebase-perf:+
cordova.system.library.6=com.google.android.gms:play-services-auth:11.8.0
cordova.system.library.7=com.google.android.gms:play-services-identity:11.8.0
cordova.system.library.8=com.android.support:support-v4:24.1.1+
cordova.gradle.include.4=cordova-support-google-services/cinematch-build.gradle
cordova.gradle.include.5=phonegap-plugin-multidex/cinematch-multidex.gradle

But my problem is: I don't know which versions to set all these to!

  • I'm not sure about how to align all the instances of the required gradle & firebase versions for my plugins and how to know what should be which version.
  • Also, is this really something that needs to be done manually before every android build?

Would any of you be so kind and see if you can point me in the right direction?
I tried so many things but am really lost and confused about these versions now.

The latest android releases for firebase say core is on v16.0.6, so that's what I filled in the versions of FIREBASE_VERSION and PLAY_SERVICES_VERSION.

This is from my package.json

"plugins": {
            "cordova-plugin-whitelist": {},
            "cordova-plugin-inappbrowser": {},
            "cordova-plugin-wkwebview-engine": {},
            "cordova-plugin-x-socialsharing": {
                "ANDROID_SUPPORT_V4_VERSION": "24.1.1+"
            },
            "cordova-plugin-googleplus": {
                "REVERSED_CLIENT_ID": "com.googleusercontent.apps.1062218916578-",
                "WEB_APPLICATION_CLIENT_ID": "1062218916578-",
                "PLAY_SERVICES_VERSION": "16.0.6"
            },
            "cordova-android-firebase-gradle-release": {
                "FIREBASE_VERSION": "16.0.6"
            },
            "cordova-plugin-firebase": {},
            "cordova-android-play-services-gradle-release": {
                "PLAY_SERVICES_VERSION": "16.0.6"
            }
        },

and from my config.xml

 <plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
    <plugin name="cordova-plugin-inappbrowser" spec="^3.0.0" />
    <plugin name="cordova-plugin-wkwebview-engine" spec="^1.1.4" />
    <feature name="CDVWKWebViewEngine">
        <param name="ios-package" value="CDVWKWebViewEngine" />
    </feature>
    <preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />
    <plugin name="cordova-plugin-x-socialsharing" spec="^5.4.4">
        <variable name="ANDROID_SUPPORT_V4_VERSION" value="24.1.1+" />
    </plugin>
    <plugin name="cordova-plugin-googleplus" spec="7.0.0">
        <variable name="REVERSED_CLIENT_ID" value="com.googleusercontent.apps." />
        <variable name="WEB_APPLICATION_CLIENT_ID" value="1062218916578-" />
        <variable name="PLAY_SERVICES_VERSION" value="16.0.6" />
    </plugin>
    <plugin name="cordova-android-firebase-gradle-release" spec="^2.0.0">
        <variable name="FIREBASE_VERSION" value="16.0.6" />
    </plugin>
    <plugin name="cordova-plugin-firebase" spec="^2.0.5" />
    <plugin name="cordova-android-play-services-gradle-release" spec="^2.0.0">
        <variable name="PLAY_SERVICES_VERSION" value="16.0.6" />
    </plugin>
    <engine name="ios" spec="^4.5.5" />
    <engine name="android" spec="^7.1.4" />

Thank you very much for your help.

PS, lastly, I also wanted to ask, is it really required to make manual changes inside any files of cordova/platforms/android I have the feeling these changes wouldn't stick especially when removing and adding the android platform?

@rtm
Copy link
Author

rtm commented Jan 17, 2019

I've pulled the plug on Cordova and its hot mess of version conflicts between Android, Cordova, Cordova platforms, and Cordova plugins. I wasted far too many hours and days of my life trying to get things to work. I delayed new features because I knew the pain that would be involved. I'm writing PWAs now, and life is sweet. Just say no.

@mesqueeb
Copy link

mesqueeb commented Jan 17, 2019

@rtm well, cordova works beautifully for all plugins for iOS for me. It's just all these android specific gradle versions I think. Firebase android core is on 16.0.6 so I'm guessing that one but...

PS, I can't say no to android app for my client. But don't want to start learning JAVA just to write android apps lol...... I'm a JavaScript dev so.......

PS2: i have updated my post above. I think it’s the versions in /platforms/android/project.properties

@mesqueeb
Copy link

if I try to put all versions of firebase and google play to 16.0.6 I get warning like this:

> Could not find com.google.firebase:firebase-auth:16.0.6.
> Could not find com.google.firebase:firebase-config:16.0.6.
> Could not find com.google.firebase:firebase-common:16.0.6.
> Could not find com.google.firebase:firebase-analytics-impl:16.0.6.
> Could not find com.google.android.gms:play-services-auth:16.0.6.
> Could not find com.google.android.gms:play-services-identity:16.0.6.
> Could not find com.google.android.gms:play-services-ads-identifier:16.0.6.
> Could not find com.google.firebase:firebase-measurement-connector-impl:16.0.6.
> Could not find com.google.android.gms:play-services-basement:16.0.6.
> Could not find com.google.android.gms:play-services-measurement-api:16.0.6.
> Could not find com.google.firebase:firebase-common:16.0.6.

And many more, and for each those lines a bunch of files it "searched" through.

Does anyone know what is the correct firebase & google play version to make this plugin work on Android?

@mesqueeb
Copy link

mesqueeb commented Jan 17, 2019

If I try to put everything on 16.+ i get these errors:

Failed to notify dependency resolution listener.
> The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[16.0.5,16.0.5], [16.0.0,16.0.0]], but resolves to 16.0.5. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
> The library com.google.firebase:firebase-analytics is being requested by various other libraries at [[16.0.6,16.0.6], [16.0.1,16.0.1]], but resolves to 16.0.6. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.

I'm not sure what is trying to access com.google.android.gms:play-services-measurement-base, and firebase analytics is from this package I think!

I guess I'll open a new thread for my problem.

@mesqueeb
Copy link

fixed it!

@rtm don't give up on cordova! you can do it!

@bryanjorgeflores
Copy link

Thank you so much @dualh

@pdelaby
Copy link

pdelaby commented Mar 5, 2019

Thanks @dualh for the solution !
However, this involves changing a generated file. It will be tricky to implement on a automated build (ex: on Ionic AppFlow or Jenkins). Does someone have a solution suitable for continuous integration ?

@OyebisiJemil
Copy link

Hi @rtm for fix this problem go to
/platforms/android/cordova-support-google-services

In this directory find the file {APP}-build.gradle

Open and comment the next line

apply plugin: com.google.gms.googleservices.GoogleServicesPlugin

Next, re run

ionice cordova run android

Thanks, this works for me!

@JerryBels
Copy link

@dualh solution is no good. I implemented it a few weeks ago, thought I was good to go... I just went through many hours of debug not knowing why Google Login wasn't working anymore. Then I remembered about this. Removed the plugin that was giving errors, removed my fix, rebuilt everything... It works again. Be very careful when implementing this solution.

@zto-sbenning
Copy link

Hello, why this is close? What is the fix?
I still encounter this issue:

`
Failed to apply plugin [id 'com.google.gms.google-services']

Cannot add extension with name 'googleServices', as there is an extension already registered with that name.
`

My ionic info:

`
cli packages: (/usr/local/lib/node_modules)

@ionic/cli-utils  : 1.19.2
ionic (Ionic CLI) : 3.20.0

global packages:

cordova (Cordova CLI) : 8.0.0

local packages:

@ionic/app-scripts : 3.2.0
Cordova Platforms  : android 7.1.4
Ionic Framework    : ionic-angular 3.9.2

System:

Android SDK Tools : 26.1.1
Node              : v8.11.4
npm               : 5.6.0
OS                : macOS High Sierra
Xcode             : Xcode 10.1 Build version 10B61

Environment Variables:

ANDROID_HOME : /Users/zento/Library/Android/sdk

Misc:

backend : pro

`

We have to integrate with Jenkins for CI. And as for other the fix from @dualh is resolving the build, but then the plugin won't works.

What is the resolution for this closed issue please?

@darkhorse-coder
Copy link

Hi @dualh I have followed your solution. that's ok. but I have got these error continuously.

BUILD FAILED in 7s
/Volumes/Work/Hybrid/15_SmartBeach/projects/CUSTOMER/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
Failed to capture fingerprint of input files for task ':app:preDebugBuild' property 'compileManifests' during up-to-date check.
> The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[17.0.0,17.0.0], [17.2.2,17.2.2]], but resolves to 17.2.2. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.

Do you have any solution please?

Ionic:

   Ionic CLI          : 5.4.15 (/usr/local/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.4

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 8.1.0
   Cordova Plugins   : cordova-plugin-ionic-webview 4.0.1, (and 23 other plugins)

Utility:

   cordova-res : 0.9.0
   native-run  : not installed

System:

   Android SDK Tools : 26.1.1 (/Users/stormlong/Library/Android/sdk)
   NodeJS            : v10.16.3 (/usr/local/bin/node)
   npm               : 6.13.3
   OS                : macOS Mojave

This is my environment.

Thank you in advance.

@dlaudh
Copy link

dlaudh commented Feb 4, 2020

Hi @dualh I have followed your solution. that's ok. but I have got these error continuously.

BUILD FAILED in 7s
/Volumes/Work/Hybrid/15_SmartBeach/projects/CUSTOMER/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
Failed to capture fingerprint of input files for task ':app:preDebugBuild' property 'compileManifests' during up-to-date check.
> The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[17.0.0,17.0.0], [17.2.2,17.2.2]], but resolves to 17.2.2. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.

Do you have any solution please?

Ionic:

   Ionic CLI          : 5.4.15 (/usr/local/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.4

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 8.1.0
   Cordova Plugins   : cordova-plugin-ionic-webview 4.0.1, (and 23 other plugins)

Utility:

   cordova-res : 0.9.0
   native-run  : not installed

System:

   Android SDK Tools : 26.1.1 (/Users/stormlong/Library/Android/sdk)
   NodeJS            : v10.16.3 (/usr/local/bin/node)
   npm               : 6.13.3
   OS                : macOS Mojave

This is my environment.

Thank you in advance.

Hello @zhiyilee, I migrated to FirebaseX caused the cordova-plugin-firebase is unmaintained currently

Best regards 👋

@darkhorse-coder
Copy link

Thank you @dualh for your kindly reply. FirebaseX will help me. 😘😘😘

@gustavomts20
Copy link

Hi @rtm for fix this problem go to /platforms/android/cordova-support-google-services

In this directory find the file {APP}-build.gradle

Open and comment the next line

apply plugin: com.google.gms.googleservices.GoogleServicesPlugin

Next, re run

ionice cordova run android

I am using capacitor for the build, where would I change that? Thanks!

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

No branches or pull requests