Open franzisk opened 6 years ago
In platforms > android > cordova-plugin-fcm > youapp-FCMPlugin.gradle, remove the lines classpath 'com.google.gms:google-services:3.0.0'
and apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
In platforms > android > build.gradle, add classpath 'com.google.gms:google-services:3.2.1'
in dependencies (around line 32)
In platforms > android > app > build.gradle, add apply plugin: 'com.google.gms.google-services'
at the very end of the file
If this does not work, change lines 68 and 69 (framework tags) of plugins > cordova-plugin-fcm > plugin.xml to <framework src="com.google.firebase:firebase-core:11.8.0" /> <framework src="com.google.firebase:firebase-messaging:11.8.0" />
, remove and add the android platform again and redo the steps above.
In platforms > android > cordova-plugin-fcm > app-FCMPlugin.gradle
In platforms > android > build.gradle
IF REQUIRED :
In plugins > cordova-plugin-fcm > plugin.xml to
@VRZ78 I tried to apply your recommendations but I get this output:
* What went wrong:
A problem occurred evaluating root project 'android'.
> Failed to apply plugin [id 'com.google.gms.google-services']
> For input string: "+"
Cordova plugins I have installed:
branch-cordova-sdk 2.6.24 "branch-cordova-sdk"
cordova-launch-review 3.1.0 "Launch Review"
cordova-plugin-actionsheet 2.3.3 "ActionSheet"
cordova-plugin-advanced-http 1.11.1 "Advanced HTTP plugin"
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-device 2.0.1 "Device"
cordova-plugin-dialogs 2.0.1 "Notification"
cordova-plugin-facebook4 1.9.1 "Facebook Connect"
cordova-plugin-fcm 2.1.2 "FCMPlugin"
cordova-plugin-file 6.0.1 "File"
cordova-plugin-geolocation 4.0.2-dev "Geolocation"
cordova-plugin-googleplus 5.2.1 "Google SignIn"
cordova-plugin-inappbrowser 2.0.2 "InAppBrowser"
cordova-plugin-ionic 4.1.0 "IonicCordova"
cordova-plugin-ionic-webview 1.1.16 "cordova-plugin-ionic-webview"
cordova-plugin-market 1.2.0 "Market"
cordova-plugin-network-information 2.0.1 "Network Information"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.1 "StatusBar"
cordova-plugin-swift-support 3.1.1 "SwiftSupport"
cordova-plugin-whitelist 1.3.3 "Whitelist"
phonegap-plugin-barcodescanner 7.1.0 "BarcodeScanner"
uk.co.workingedge.phonegap.plugin.launchnavigator 4.2.0 "Launch Navigator"
i added this line at the end of /android/build.gradle apply plugin: 'com.google.gms.google-services'
@andreandev I have the same issue when I tried to apply recommendations of @VRZ78
@andreandev Did you put it at the end of android/app/build.gradle or android/build.gradle ? You need to put it in android/app/build.gradle
@VRZ78 this path android/app/build.gradle not exist in ionic project with android cordova 6.4.0, only android/build.gradle.
@VRZ78 thanks for the help, doesn't work for me as well.
This is the error I get after applying your steps:
* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.google.gms.google-services']
> For input string: "11+"
Am using ionic 3.20.0 with Android 7.0 and FCM 2.1.2:
<plugin name="cordova-plugin-fcm" spec="^2.1.2" />
<engine name="android" spec="~7.0.0" />
This is line 68-9 in file plugins/cordova-plugin-fcm/plugin.xml
:
<framework src="com.google.firebase:firebase-core:11.8.0" />
<framework src="com.google.firebase:firebase-messaging:11.8.0" />
@flarco You need to change your dependencies in platforms/android/project.properties from com.google.firebase:firebase-messaging:11.+ or com.google.firebase:firebase-messaging:+
to
com.google.firebase:firebase-messaging:11.8.0 com.google.firebase:firebase-core:11.8.0
You should use phonegap-plugin-push@2.1.3, you only need to have installed cordova android 6.4.0 or 6.3.0 and cordova-android-support-gradle-release.
phonegap-plugin-push can be configured to use FCM o APNS in iOS This plugin is more updated to date than cordova-plugin-fcm
@Juliocbr Did your changes, still didn't work, but funny I tried the phonegap-plugin-push a few hours this morning and some other post said to use plugin-fcm instead :).
I have had no success with phonegap-plugin-push, I am not getting any registrationId nor am I getting any error. It's like nothing happens. The google-services.json
is there, I made sure to run the init after the platform is ready. Any idea on other things I should check for? Thanks in advance.
const options: PushOptions = {
android: {
senderID:'xxxxxxxxx' // I've read that this isn't required, but it hasn't worked with or without
},
ios: {
alert: 'true',
badge: true,
sound: 'false'
},
windows: {},
browser: {
pushServiceURL: 'http://push.api.phonegap.com/v1/push'
}
};
const pushObject: PushObject = this.push.init(options);
pushObject.on('registration').subscribe((registration: RegistrationEventResponse) => {
console.log('Device registered')
console.log(registration.registrationId)
});
pushObject.on('error').subscribe((error: any) => {
console.log('Device error')
console.log(error)
});
@flarco this is my code that I use for receiving the notification:
if (!this.platform.is('cordova')) {
console.warn('Push notifications not initialized. Cordova is not available - Run in physical device');
return;
}
const options: PushOptions = {
android: {
senderID: 'xxxxx' //Just in case it is better to add it.
},
ios: {
alert: 'true',
badge: true,
sound: 'true'
},
windows: {}
};
const pushObject: PushObject = this.push.init(options);
pushObject.on('registration').subscribe(data => {
console.log("device token: " + data.registrationId);
});
pushObject.on('notification').subscribe(data => {
console.log(JSON.stringify(data));
});
pushObject.on('error').subscribe((e) => {
console.error(e.message);
console.error(JSON.stringify(e));
});
in config.xml add the resource file tag (in root project folder add google-services.json file):
<platform name="android">
<resource-file src="google-services.json" target="google-services.json" />
</platform>
You need to install Android Support Repository (Android Studio) https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/INSTALLATION.md check Android Details title.
ionic info:
ionic (Ionic CLI) : 3.20.0 cordova (Cordova CLI) : 7.1.0 Cordova Platforms : android 6.4.0 Android SDK Tools : 26.1.1 phonegap-plugin-push: 2.1.3
installation if you install fcm plugin run cordova plugin rm cordova-plugin-fcm --save before the installation steps.
cordova platform rm android cordova plugin add cordova-android-support-gradle-release --save cordova platform add android@6.4.0 cordova plugin add phonegap-plugin-push@2.1.3 --variable SENDER_ID="xxxxxx" --save
in your config.xml you should see this:
<plugin name="cordova-android-support-gradle-release" spec="^1.4.2">
<variable name="ANDROID_SUPPORT_VERSION" value="27.+" />
</plugin
<plugin name="phonegap-plugin-push" spec="^2.1.3">
<variable name="SENDER_ID" value="xxxxxxxx" />
<variable name="FCM_VERSION" value="11.6.2" />
</plugin>
You could use the Firebase console https://console.firebase.google.com/ after click in your project --> "Grow" --> "Cloud Messaging" for sending notification to device token or package name, this is the fastest way to check if you receive the notification.
Note: it's important add the correct package name to FCM console.
@Juliocbr I appreciate your help very much. I got it to work after toiling for a bit.
hi @flarco ,
Are you using phonegap-plugin-push? Is it really working with both android and ios?
@alvinlee001 Yes I'm using phonegap-plugin-push
. I have only tested with android (not ios).
@flarco Man, i just tried last night to move to phonegap-plugin-push, but my app died upon trying to subscribe to anything, or upon receiving a message i sent from FCM, on android. Do you guys ever faced the same problem?
@alvinlee001 no... When I send a FCM message, it shows up as normal. Try re-installing the platform version? Make sure it's 6.3 or 6.4. Add / remove the plugins? Go through the steps @VRZ78 & @Juliocbr mentioned.
@flarco Somehow I managed to make cordova-plugin-fcm
build success, and it turns out i do not have to change a thing inside ./platforms/android
, all i did is follow @troovers guide https://forum.ionicframework.com/t/google-services-version-conflict-maps-fcm/93695/2
but without changing the build.gradle
file or anything inside ./platforms/android
Comment out these lines in the FCMPlugin.gradle file (inside /plugins/cordova-plugin-fcm/src/android).
classpath 'com.google.gms:google-services:3.0.0'
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
Then change the plugin.xml of the FCM plugin to use a different version, in my situation 11.8.0. (inside /plugins/cordova-plugin-fcm/)
<framework src="com.google.firebase:firebase-core:11.8.0" />
<framework src="com.google.firebase:firebase-messaging:11.8.0" />
Now, remove en add the android platform again, so the changes will have affect. The next step is to change the build.gradle file of the android platform folder just do ionic cordova run android
.
I hope if anyone has this problem on this as well could leave a comment whether it works for you, and hope to help someone who is facing with this as well
@alvinlee001 thanks for your solution. My project has FCM plugin and phonegap push plugin and It is working again.
Regards!!! Thanks a lot.
@aaronyamil You are welcome bro!! =)
@alvinlee001 thanks for your solution. It worked for me too.
@alvinlee001 this trows me a new error :(
`FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
41 actionable tasks: 41 executed
BUILD FAILED in 22s
(node:3175) UnhandledPromiseRejectionWarning: Error: /Users/code/Desktop/myseg/mobile/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.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.`
dependencies {
implementation fileTree(dir: 'libs', include: '*.jar')
// SUB-PROJECT DEPENDENCIES START
implementation(project(path: "CordovaLib"))
compile "com.android.support:support-v4:24.1.1+"
compile "com.soundcloud.android:android-crop:1.0.0@aar"
compile "com.android.support:support-v4:27+"
compile "com.google.firebase:firebase-core:11.8.0"
compile "com.google.firebase:firebase-messaging:11.8.0"
compile "com.android.support:support-v4:+"
compile "com.google.android.gms:play-services-maps:12.0.0"
compile "com.google.android.gms:play-services-location:12.0.0"
compile "com.android.support:support-core-utils:24.1.0"
compile "com.android.support:support-v4:26.+"
compile "org.nanohttpd:nanohttpd:+"
compile "com.android.support:support-v13:23+"
// SUB-PROJECT DEPENDENCIES END
}
@hitmacreed Erm, i am no expert on this, so i am unable to make any comment on this. There are some post which seem to suggest cleaning and rebuilding to solve it though. So sorry.
Try on your build.gradle
defaultConfig {
multiDexEnabled true
...
}
@alvinlee001 do that, build the apk in the device emulator, cause a "the app has been stopped" error :(
@alvinlee001 hi i tried your solution, errors solved but app crashes when launching.
@Omazon @cikcoh I am sorry folks, in this case then maybe there are changes to the library(s) which might require a different solution (yet again). I really hope someone out there who dealt with this problem and found a solution can post their latest solution to share with other folks who suffer the same fate. So sorry
@alvinlee001 hi, it's OK i found a solution that works for me. https://code.i-harness.com/en/q/25fd238
@cikcoh the link you shared is giving 404 not found. @alvinlee001 I am having the same issue, I will share the solution once I have it. Thanks for your solution above.
@alvinlee001 What is missing in your solution is mainly this part: ext.postBuildExtras = { apply plugin: com.google.gms.googleservices.GoogleServicesPlugin }
So for your solution to be complete:
in the FCMPlugin.gradle file (inside /plugins/cordova-plugin-fcm/src/android). classpath 'com.google.gms:google-services:3.0.0' replace: "apply plugin: com.google.gms.googleservices.GoogleServicesPlugin" with: "ext.postBuildExtras = { apply plugin: com.google.gms.googleservices.GoogleServicesPlugin }" Then change the plugin.xml of the FCM plugin to use a different version, in my situation 11.8.0. (inside /plugins/cordova-plugin-fcm/)
Now, remove en add the android platform again, so the changes will have affect. The next step is to change the build.gradle file of the android platform folder just do ionic cordova run android.
@GBR-422777 not sure why the link directed to github when clicked. if you type the displayed url, the page exist.
Facing the same issue for ionic 3 now.
Case 1:
Case 2:
Cordova Build Successful but app not running on device/emulator("App has stopped").
Plugins used in app as shown below
@flarco this is my code that I use for receiving the notification:
if (!this.platform.is('cordova')) { console.warn('Push notifications not initialized. Cordova is not available - Run in physical device'); return; } const options: PushOptions = { android: { senderID: 'xxxxx' //Just in case it is better to add it. }, ios: { alert: 'true', badge: true, sound: 'true' }, windows: {} }; const pushObject: PushObject = this.push.init(options); pushObject.on('registration').subscribe(data => { console.log("device token: " + data.registrationId); }); pushObject.on('notification').subscribe(data => { console.log(JSON.stringify(data)); }); pushObject.on('error').subscribe((e) => { console.error(e.message); console.error(JSON.stringify(e)); });
in config.xml add the resource file tag (in root project folder add google-services.json file):
<platform name="android"> <resource-file src="google-services.json" target="google-services.json" /> </platform>
You need to install Android Support Repository (Android Studio) https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/INSTALLATION.md check Android Details title.
ionic info:
ionic (Ionic CLI) : 3.20.0 cordova (Cordova CLI) : 7.1.0 Cordova Platforms : android 6.4.0 Android SDK Tools : 26.1.1 phonegap-plugin-push: 2.1.3
installation if you install fcm plugin run cordova plugin rm cordova-plugin-fcm --save before the installation steps.
cordova platform rm android cordova plugin add cordova-android-support-gradle-release --save cordova platform add android@6.4.0 cordova plugin add phonegap-plugin-push@2.1.3 --variable SENDER_ID="xxxxxx" --save
in your config.xml you should see this:
<plugin name="cordova-android-support-gradle-release" spec="^1.4.2"> <variable name="ANDROID_SUPPORT_VERSION" value="27.+" /> </plugin <plugin name="phonegap-plugin-push" spec="^2.1.3"> <variable name="SENDER_ID" value="xxxxxxxx" /> <variable name="FCM_VERSION" value="11.6.2" /> </plugin>
You could use the Firebase console https://console.firebase.google.com/ after click in your project --> "Grow" --> "Cloud Messaging" for sending notification to device token or package name, this is the fastest way to check if you receive the notification.
Note: it's important add the correct package name to FCM console.
Hello,
I am facing below error while deploying the build for Android. I tried above steps as well.
Error: Could not find an installed version of Gradle either in Android Studio, or on your system to install the gradle wrapper. Please include gradle in your path, or install Android Studio
Cordova version - 7.1.0 Cordova-android platform - 6.4.0
Please help me out. Facgin from couple of days.
I got same exactly issue. Please help me!!!
Thanks
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 10.+
Facing the same issue for ionic 3 now.
Case 1:
- Added cordova-plugin-fcm-with-dependecy-updated with cordova-google-plus plugin which is causing failed Cordova build as per following screenshot.
Case 2:
- As per above posts commented following lines classpath 'com.android.tools.build:gradle:3.0.0' classpath 'com.google.gms:google-services:4.1.0' apply plugin: 'com.google.gms.googleservices.GoogleServicesPlugin'
- Added following lines into project build.gradle classpath 'com.android.tools.build:gradle:3.0.0' classpath 'com.google.gms:google-services:4.1.0' apply plugin: 'com.google.gms.google-services' at the bottom of build.gradle
Cordova Build Successful but app not running on device/emulator("App has stopped").
Plugins used in app as shown below
I got same issue.
I've used @sirius2013 answer with cordova-plugin-fcm-with-dependecy-updated and a bunch of Google and Firebase plugins:
classpath 'com.google.gms:google-services:4.1.0' compile 'com.google.firebase:firebase-core:11.0.4'
framework src="com.google.firebase:firebase-core:11.0.4" /> framework src="com.google.firebase:firebase-messaging:11.0.4" />
@flarco Somehow I managed to make
cordova-plugin-fcm
build success, and it turns out i do not have to change a thing inside./platforms/android
, all i did is follow @troovers guide https://forum.ionicframework.com/t/google-services-version-conflict-maps-fcm/93695/2 but without changing thebuild.gradle
file or anything inside./platforms/android
My solution:
Comment out these lines in the FCMPlugin.gradle file (inside /plugins/cordova-plugin-fcm/src/android).
classpath 'com.google.gms:google-services:3.0.0'
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
Then change the plugin.xml of the FCM plugin to use a different version, in my situation 11.8.0. (inside /plugins/cordova-plugin-fcm/)
<framework src="com.google.firebase:firebase-core:11.8.0" />
<framework src="com.google.firebase:firebase-messaging:11.8.0" />
Now, remove en add the android platform again, so the changes will have affect. The next step is to change the build.gradle file of the android platform folder just do
ionic cordova run android
.I hope if anyone has this problem on this as well could leave a comment whether it works for you, and hope to help someone who is facing with this as well
I am having same issue but the version are different fmc is 10.+ and com.google.android.gms:play-services-maps:15.0.1 do u have any idea how to reslove this ?
@KishanIos007 ,
It worked for me with following in plugin.xml
<framework src="com.google.firebase:firebase-core:16.0.4" />
<framework src="com.google.firebase:firebase-messaging:17.3.4" />
This fixed it for me after hours of plundering my code.
I am using firebase, FCM, and google-services and they were all doing this:
apply plugin: 'com.google.gms.google-services'
So I removed it from:
portal-build.gradle
in 2 places
in:
platforms->android->cordova-plugin-firebase
platforms->android->cordova-support-google-services
^ to make sure google services was only applied once.
Also I made sure every *.gradle file in platform->android pointed to the same com.google.gms:google-services
version. In my case 4.0.2 works.
Then as a unexpected bonus I had to change the project.properties
file in platform->android
There I made sure
com.android.support:support-v4:27.1.0
was called, and I removed every other reference to com.android.support:support-v4
from it.
This fix for me with this changes
changing the platforms>android>project.properties
line 14
from cordova.system.library.1=com.google.android.gms:play-services-location:11+
to cordova.system.library.1=com.google.android.gms:play-services-location:16.0.0
and...
changing the platforms>android>cordova-plugin-fcm>mx-FCMPlugin.grandle
line 16 and17
from compile 'com.google.firebase:firebase-core:9.4.0' compile 'com.google.firebase:firebase-messaging:9.4.0'
to
compile 'com.google.firebase:firebase-core:16.0.0' compile 'com.google.firebase:firebase-messaging:16.0.0'
i´m currently using
Cordova 8.1.1 Cordova-plugin-mauron85-background-geolocation@3.0.0-alpha.48 cordova-plugin-fcm 1.1.4
i have to run this fix to:
in Ionic 3
Update file from plateform -> android -> project-properties
target=android-27 android.library.reference.1=CordovaLib android.library.reference.2=app cordova.system.library.1=com.squareup.okhttp3:okhttp-urlconnection:3.10.0 cordova.system.library.2=com.android.support:support-v4:24.1.1+ cordova.system.library.3=com.facebook.android:facebook-android-sdk:4.36.0 cordova.system.library.4=com.google.firebase:firebase-core:10.+ cordova.system.library.5=com.google.firebase:firebase-messaging:10.+ cordova.gradle.include.1=cordova-plugin-fcm-with-dependecy-updated/app-FCMPlugin.gradle cordova.system.library.6=com.google.android.gms:play-services-auth:10.+ cordova.system.library.7=com.google.android.gms:play-services-identity:10.+ cordova.system.library.8=com.android.support:support-v4:24.1.1+
and build it once again for android
it working for me
For person who is still facing this issue please install below plugin and it will solve all your error
ionic cordova plugin add cordova-play-services-version-adapter --save
Documentation : - https://www.npmjs.com/package/cordova-play-services-version-adapter
For person who is still facing this issue please install below plugin and it will solve all your error
ionic cordova plugin add cordova-play-services-version-adapter --save
Documentation : - https://www.npmjs.com/package/cordova-play-services-version-adapter
Or not...
'Cordova Play Services Version Adapter' has detected an error. The following dependencies of 'Google Play Services' are not compatible:
You have an incompatibility of versions with the following dependencies of 'Google Play Services':
- 'com.google.firebase:firebase-core:10.+'
- 'com.google.firebase:firebase-messaging:10.+'
- 'com.google.android.gms:play-services-auth:11.8.0'
- 'com.google.android.gms:play-services-identity:11.8.0'
It doesn't exists a version of 'Google Play Services' that includes all these dependencies.
All dependencies of 'Google Play Services' must have the same version.
The application may not compile.
Didn't fix anything. Still forced to manually edit project.properties -file which totally sucks. Googled my ass off with this but yet to found a viable solution :(
In platforms > android > cordova-plugin-fcm > youapp-FCMPlugin.gradle, remove the lines
classpath 'com.google.gms:google-services:3.0.0'
andapply plugin: com.google.gms.googleservices.GoogleServicesPlugin
In platforms > android > build.gradle, add
classpath 'com.google.gms:google-services:3.2.1'
in dependencies (around line 32)In platforms > android > app > build.gradle, add
apply plugin: 'com.google.gms.google-services'
at the very end of the fileIf this does not work, change lines 68 and 69 (framework tags) of plugins > cordova-plugin-fcm > plugin.xml to
<framework src="com.google.firebase:firebase-core:11.8.0" /> <framework src="com.google.firebase:firebase-messaging:11.8.0" />
, remove and add the android platform again and redo the steps above.
Thank you its working
Nothing here works!! So.. Use this!!! Resolve all my problems. https://github.com/arnesson/cordova-plugin-firebase/issues/1103#issuecomment-526790936
i had this problem
remove all plugins > cordova-plugin-fcm-with-dependecy-updated
all above folders and content
then install it again
ionic cordova plugin add cordova-plugin-fcm-with-dependecy-updated
verbose statusCode 404 8 verbose pkgid cordova-plugin-fmc-with-dependecy-updated@latest 9 verbose cwd C:\Users\Hugo Power\Desktop\notificaciones 10 verbose Windows_NT 10.0.17763 11 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "view" "cordova-plugin-fmc-with-dependecy-updated" "--json"
guys i have this issue please how can resolve it
I need do send push notifications in my Ionic 3 app, after adding this FCM plugin I cannot run on Android (first testing only in Android) anymore, that's my situation bellow.
/platforms/android/project.properties
Ionic Info
I just added FCM plugin and when I try to run on Android device with: ionic cordova run android -l -c
Even after I changing those 3 plugins to version 9.0.0 I keep getting errors.
Cordova plugins I have installed:
Any clue how I could solve this issue?
Thanks