phonegap / phonegap-plugin-push

Register and receive push notifications
MIT License
1.94k stars 1.91k forks source link

Build error - Failed to apply plugin [class 'com.google.gms.googleservices.GoogleServicesPlugin'] #1878

Closed tominou closed 7 years ago

tominou commented 7 years ago

cordova --version 7.0.1 cordova platform version android 6.2.3 cordova plugin version | grep phonegap-plugin-push 2.0.0-rc5

Hi,

Since upgrading cordova, cordova-android and all my plugins, my project doesn't build anymore. If i remove phonegap-plugin-push, build is working fine. I tried removing android platform, but still got the exact same error.

Here is the error i get:

_Error: /home/tom/Development/cordova/xxx/platforms/android/gradlew: Command failed with exit code 1 Error output: FAILURE: Build failed with an exception.

And here is the tt-push.gradle file:

_def doExtractStringFromManifest(name) { def manifestFile = file(android.sourceSets.main.manifest.srcFile) def pattern = Pattern.compile(name + "=\"(.*?)\"") def matcher = pattern.matcher(manifestFile.getText()) matcher.find() return matcher.group(1) }

android { sourceSets { main { manifest.srcFile 'AndroidManifest.xml' } }

defaultConfig {
    multiDexEnabled true
    applicationId = doExtractStringFromManifest("package")
}

}

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 ext.postBuildExtras = { apply plugin: com.google.gms.googleservices.GoogleServicesPlugin }_

Thank you by advance ^^

shahdeep1989 commented 7 years ago

I am facing same issue. Any solution?

macdonst commented 7 years ago

Duplicate of #1718

smadupathi commented 6 years ago

I am also facing the same error as: BUILD FAILED

Total time: 46.453 secs FAILURE: Build failed with an exception.

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

sohandhaindwal commented 6 years ago

@smadupathi , @shahdeep1989 , @tobmaster Hi all I have resolved this issue. please follow following points

  1. please check, Are you use another google service like: map, location, etc? than remove "+" from platforms\android\project.properties files code should be like this cordova.system.library.5=com.google.android.gms:play-services-maps:11.6.0 cordova.system.library.6=com.google.android.gms:play-services-location:11.6.0 And your firebase message service should be like this

cordova.system.library.9=com.google.firebase:firebase-messaging:11.+

and at the end , create a google-services.json from your fiirebase app console. download this google-services.json and paste into your platforms\android and re build your app again. it will work prefect thank you.

MarcosRibeiroJesus commented 6 years ago

Two days ago i did it, but today my project.properties back put the + in these services again...

elbakai commented 6 years ago

@sohandhaindwal thanks, you saved me

ghost commented 6 years ago

Hi. I am having the same issue. Here is my from platforms\android\project.properties files

# Project target. target=android-26 android.library.reference.1=CordovaLib android.library.reference.2=app cordova.system.library.1=com.android.support:support-v13:26. cordova.system.library.2=me.leolin:ShortcutBadger:1.1.17@aar cordova.system.library.3=com.google.firebase:firebase-messaging:11.0.1 cordova.gradle.include.1=phonegap-plugin-push/app-push.gradle cordova.gradle.include.2=cordova-plugin-firebase/app-build.gradle cordova.system.library.4=com.google.gms:google-services: cordova.system.library.5=com.google.android.gms:play-services-tagmanager: cordova.system.library.6=com.google.firebase:firebase-core: cordova.system.library.7=com.google.firebase:firebase-messaging: cordova.system.library.8=com.google.firebase:firebase-crash: cordova.system.library.9=com.google.firebase:firebase-config: cordova.system.library.10=com.google.firebase:firebase-messaging:11.+

gls-labs commented 6 years ago

I just solved it, it is all about version. Take a look at my project.properties. It works perfectly now

target=android-26 android.library.reference.1=CordovaLib cordova.gradle.include.1=com-sarriaroman-photoviewer/app-photoviewer.gradle cordova.system.library.1=com.android.support:support-v4:24.1.1+ cordova.system.library.2=com.facebook.android:facebook-android-sdk:4.+ cordova.system.library.3=com.google.android.gms:play-services-maps:11.8.0 cordova.system.library.4=com.google.android.gms:play-services-location:11.8.0 cordova.system.library.5=com.android.support:support-v4:24.1.1+ cordova.gradle.include.2=cordova-support-google-services/app-build.gradle 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.gradle.include.3=cordova-plugin-fcm/app-FCMPlugin.gradle

senturkhasan commented 6 years ago

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

tominou commented 6 years ago

The solution was to set all to the libraries to the same version as stated by @gls-labs

Set them all to 11.8.0 in platform/android/project.properties then it will build correctly.

Thank you all ^^

senturkhasan commented 6 years ago

not working

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

tominou commented 6 years ago

Please share your platform/android/project.properties

senturkhasan commented 6 years ago

target=android-26 android.library.reference.1=CordovaLib android.library.reference.2=app cordova.system.library.1=com.android.support:customtabs:23.3.0 cordova.gradle.include.1=cordova-plugin-browsertab/app-BrowserTab.gradle cordova.gradle.include.2=cordova-plugin-buildinfo/app-BuildInfo.gradle cordova.system.library.2=com.facebook.android:facebook-android-sdk:4.+ cordova.gradle.include.3=cordova-plugin-firebase/app-build.gradle cordova.system.library.3=com.google.gms:google-services:+ cordova.system.library.4=com.google.android.gms:play-services-tagmanager:+ cordova.system.library.5=com.google.firebase:firebase-core:+ cordova.system.library.6=com.google.firebase:firebase-messaging:+ cordova.system.library.7=com.google.firebase:firebase-crash:+ cordova.system.library.8=com.google.firebase:firebase-config:+ cordova.system.library.9=com.google.android.gms:play-services-auth:+ cordova.system.library.10=com.google.android.gms:play-services-identity:+ cordova.system.library.11=com.android.support:support-v13:26.+ cordova.system.library.12=me.leolin:ShortcutBadger:1.1.17@aar cordova.system.library.13=com.google.firebase:firebase-messaging:11.6.2 cordova.gradle.include.4=phonegap-plugin-push/app-push.gradle @tominou

tominou commented 6 years ago

Of course it is not working because you didn't change anything, try this one:

target=android-26 android.library.reference.1=CordovaLib android.library.reference.2=app cordova.system.library.1=com.android.support:customtabs:23.3.0 cordova.gradle.include.1=cordova-plugin-browsertab/app-BrowserTab.gradle cordova.gradle.include.2=cordova-plugin-buildinfo/app-BuildInfo.gradle cordova.system.library.2=com.facebook.android:facebook-android-sdk:4.+ cordova.gradle.include.3=cordova-plugin-firebase/app-build.gradle cordova.system.library.3=com.google.gms:google-services:+ cordova.system.library.4=com.google.android.gms:play-services-tagmanager:11.8.0 cordova.system.library.5=com.google.firebase:firebase-core:11.8.0 cordova.system.library.6=com.google.firebase:firebase-messaging:11.8.0 cordova.system.library.7=com.google.firebase:firebase-crash:11.8.0 cordova.system.library.8=com.google.firebase:firebase-config:11.8.0 cordova.system.library.9=com.google.android.gms:play-services-auth:11.8.0 cordova.system.library.10=com.google.android.gms:play-services-identity:11.8.0 cordova.system.library.11=com.android.support:support-v13:26.+ cordova.system.library.12=me.leolin:ShortcutBadger:1.1.17@aar cordova.system.library.13=com.google.firebase:firebase-messaging:11.8.0 cordova.gradle.include.4=phonegap-plugin-push/app-push.gradle

senturkhasan commented 6 years ago

BU�LD FAILED in 0s (node:8636) UnhandledPromiseRejectionWarning: Error: cmd: Command failed with exit code 1 Error output: FAILURE: Build failed with an exception.

senturkhasan commented 6 years ago

execution failed for task :"app:processDebugResources" error

senturkhasan commented 6 years ago

unhandled promise rejections are deprecated.In the future, promise rejections that are not handler will terminate the node.js process with a non-zero exit code

geass619 commented 6 years ago

i tried to change the version number, still the error exist target=android-26 android.library.reference.1=CordovaLib cordova.system.library.1=com.facebook.android:facebook-android-sdk:4.+ cordova.system.library.2=com.google.android.gms:play-services-location:11.8.0 cordova.system.library.3=com.google.android.gms:play-services-auth:11.8.0 cordova.system.library.4=com.google.android.gms:play-services-identity:11.8.0 cordova.system.library.5=com.android.support:support-v4:24.1.1+ cordova.gradle.include.1=phonegap-plugin-barcodescanner/fcmtest-barcodescanner.gradle cordova.system.library.6=com.android.support:support-v4:24.1.1+ cordova.system.library.7=com.android.support:support-v4:24.1.1+ cordova.system.library.8=me.leolin:ShortcutBadger:1.1.17@aar cordova.system.library.9=com.google.firebase:firebase-messaging:11.8.0 cordova.gradle.include.2=phonegap-plugin-push/fcmtest-push.gradle

senturkhasan commented 6 years ago

tanks bro geass619

xProgrammer-007 commented 6 years ago

Can anyone help me out ?

android.library.reference.1=CordovaLib cordova.gradle.include.1=cordova-android-play-services-gradle-release/BkAssistant-cordova-android-play-services-gradle-release.gradle cordova.system.library.1=com.squareup.okhttp3:okhttp-urlconnection:3.10.0 cordova.gradle.include.2=cordova-plugin-badge/starter-badge.gradle cordova.system.library.2=com.android.support:support-v4:24.1.1+ cordova.gradle.include.3=cordova-plugin-firebase/starter-build.gradle cordova.system.library.3=com.google.gms:google-services:+ cordova.system.library.4=com.google.android.gms:play-services-tagmanager:11.8.0 cordova.system.library.5=com.google.firebase:firebase-core:11.8.0 cordova.system.library.6=com.google.firebase:firebase-messaging:11.8.0 cordova.system.library.7=com.google.firebase:firebase-crash:11.8.0 cordova.system.library.8=com.google.firebase:firebase-config:11.8.0 cordova.system.library.9=com.android.support:support-v4:26.+ cordova.gradle.include.4=cordova-plugin-local-notification/starter-localnotification.gradle cordova.system.library.10=com.onesignal:OneSignal:3.8.3 cordova.gradle.include.5=onesignal-cordova-plugin/starter-build-extras-onesignal.gradle cordova.system.library.11=com.facebook.android:facebook-android-sdk:4.+ cordova.system.library.12=com.google.android.gms:play-services-auth:11.8.0 cordova.system.library.13=com.google.android.gms:play-services-identity:11.8.0 cordova.system.library.14=com.android.support:support-v4:26.+ cordova.system.library.15=com.android.support:appcompat-v7:26.+ cordova.gradle.include.6=cordova-plugin-fcm/BkAssistant-FCMPlugin.gradle

bharathnallamothu commented 6 years ago

help me

error start

FAILURE: Build failed with an exception.

BUILD FAILED in 4s (node:8312) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: /Users/kalyan/Desktop/untitled folder/livbimmobile_android/platforms/android/gradlew: Command failed with exit code 1 Error output: FAILURE: Build failed with an exception.

error end

Project target.

target=android-27 android.library.reference.1=CordovaLib android.library.reference.2=app cordova.system.library.1=com.android.support:support-v13:27.+ cordova.system.library.2=me.leolin:ShortcutBadger:1.1.17@aar cordova.system.library.3=com.google.firebase:firebase-messaging:11.6.2 cordova.gradle.include.1=phonegap-plugin-push/qa-push.gradle cordova.system.library.4=com.android.support:support-v4:24.1.1+ cordova.gradle.include.2=cordova-support-google-services/qa-build.gradle cordova.system.library.5=com.android.support:support-v4:26.+ cordova.system.library.6=com.android.support:appcompat-v7:26.+ cordova.gradle.include.3=cordova-plugin-firebase/qa-build.gradle cordova.system.library.7=com.google.gms:google-services:+ cordova.system.library.8=com.google.android.gms:play-services-tagmanager:+ cordova.system.library.9=com.google.firebase:firebase-core:+ cordova.system.library.10=com.google.firebase:firebase-messaging:+ cordova.system.library.11=com.google.firebase:firebase-crash:+ cordova.system.library.12=com.google.firebase:firebase-config:+

@tominou @geass619 @gls-labs

Vickypr1902 commented 6 years ago

Any solution?? The Issue still persists. screenshot 151 _li

Ansroid push gradle code: `import java.util.regex.Pattern

def doExtractStringFromManifest(name) { def manifestFile = file("AndroidManifest.xml") if (!manifestFile.exists()) { manifestFile = file("src/main/AndroidManifest.xml") } def pattern = Pattern.compile(name + "=\"(.*?)\"") def matcher = pattern.matcher(manifestFile.getText()) matcher.find() return matcher.group(1) }

android { defaultConfig { multiDexEnabled true applicationId = doExtractStringFromManifest("package") } }

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 ext.postBuildExtras = { // line35 apply plugin: com.google.gms.googleservices.GoogleServicesPlugin //line 35 } `

fagianijunior commented 6 years ago

Same for me :(

hectorggp commented 6 years ago

The same issue here Please help me out I've tried everything

# Project target. target=android-27 android.library.reference.1=CordovaLib android.library.reference.2=app cordova.system.library.1=com.android.support:customtabs:23.3.0 cordova.gradle.include.1=cordova-plugin-browsertab/mobile-BrowserTab.gradle cordova.gradle.include.2=cordova-plugin-buildinfo/mobile-BuildInfo.gradle cordova.system.library.2=com.android.support:support-v4:24.1.1+ cordova.gradle.include.3=cordova-plugin-firebase/mobile-build.gradle cordova.system.library.3=com.google.gms:google-services:11.6.2 cordova.system.library.4=com.google.android.gms:play-services-tagmanager:11.6.2 cordova.system.library.5=com.google.firebase:firebase-core:11.6.2 cordova.system.library.6=com.google.firebase:firebase-messaging:11.6.2 cordova.system.library.7=com.google.firebase:firebase-crash:11.6.2 cordova.system.library.8=com.google.firebase:firebase-config:11.6.2 cordova.gradle.include.4=cordova-support-google-services/mobile-build.gradle cordova.gradle.include.5=phonegap-plugin-multidex/mobile-multidex.gradle cordova.system.library.9=com.android.support:support-v13:27.+ cordova.system.library.10=me.leolin:ShortcutBadger:1.1.17@aar cordova.system.library.11=com.google.firebase:firebase-messaging:11.6.2

macdonst commented 6 years ago

@hectorggp it's probably:

cordova.system.library.2=com.android.support:support-v4:24.1.1+ 
cordova.system.library.9=com.android.support:support-v13:27.+ 

conflicting with each other. They should both match.

hectorggp commented 6 years ago

@macdonst does't works

I have cordova.system.library.2=com.android.support:support-v4:27.1.1 cordova.system.library.9=com.android.support:support-v13:27.1.1

hectorggp commented 6 years ago

I have:

cordova --version 8.0.0 cordova platform version android 7.1.0 cordova plugin versoin|grep phonegap-plugin-push phonegap-plugin-push 2.2.3 "PushPlugin" npm --version 5.6.0 node --version v8.9.4 ionic --version 3.20.0

hectorggp commented 6 years ago

That was a conflict with cordova-plugin-firebase. Sorry, I'm missed

Vickypr1902 commented 6 years ago

Yes there is a plugin conflict, I solved it by removing the firebase plugin, then removing the platform, re-adding the platform and then re-adding the firebase plugin and making the version of google services and firebase same in project properties.

hectorggp commented 6 years ago

I appreciate your help, thank you very much

DanLivassan commented 6 years ago

The same issue is happening with me

Here is my project.propreties file. I changed everything to 11.0.4 version, but still not working.

target=android-27 android.library.reference.1=CordovaLib android.library.reference.2=app cordova.system.library.1=com.google.android.gms:play-services-base:11.0.4 cordova.system.library.2=com.google.android.gms:play-services-ads:11.0.4 cordova.system.library.3=com.android.support:support-v4:24.1.1+ cordova.gradle.include.1=cordova-support-google-services/mobile-build.gradle cordova.gradle.include.2=phonegap-plugin-multidex/mobile-multidex.gradle cordova.system.library.4=com.android.support:support-v13:27.+ cordova.system.library.5=me.leolin:ShortcutBadger:1.1.17@aar cordova.system.library.6=com.google.firebase:firebase-messaging:11.6.2 cordova.gradle.include.3=cordova-plugin-firebase/mobile-build.gradle cordova.system.library.7=com.google.gms:google-services:11.0.4 cordova.system.library.8=com.google.android.gms:play-services-tagmanager:11.0.4 cordova.system.library.9=com.google.firebase:firebase-core:11.0.4 cordova.system.library.10=com.google.firebase:firebase-messaging:11.0.4 cordova.system.library.11=com.google.firebase:firebase-crash:11.0.4 cordova.system.library.12=com.google.firebase:firebase-config:11.0.4 cordova.system.library.13=com.google.firebase:firebase-perf:11.0.4 ` I add 3 plugin in my Ionic Project. 1 - phonegap-plugin-push (works fine) 2 - cordova-plugin-admob-free (works fine) 3 - cordova-plugin-firebase (i got the error)

When i remove the cordova-plugin-firebase, the build is OK. But when i add the plugin i got the error again. Someone can help me?

lock[bot] commented 6 years ago

This thread has been automatically locked.