Bits missing for a successful installation: update versions, missing repository, missing dependencies
Opened this issue · 4 comments
Hi, great plugin! Thanks a lot!
I found the following steps necessary to successfully cli build with your plugin.
Maybe these steps could be automatised during plugin installation? Unfortunately I know too little about Cordova plugins yet. In any case, it would be helpful to mention them in your README file.
-
Save downloaded google.services.json to platforms/android (i.e. not app or mobile)
-
Check https://developers.google.com/cloud-messaging/android/client for current Versions
com.google.gms:google-services:1.5.0-beta2
com.google.android.gms:play-services:8.3.0 -
Add classpath 'com.google.gms:google-services:1.5.0-beta2' to platforms/android/build.gradle
if (gradle.gradleVersion >= "2.2") {
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0+'
classpath 'com.google.gms:google-services:1.5.0-beta2'
}
} else if (gradle.gradleVersion >= "2.1") {
dependencies {
classpath 'com.android.tools.build:gradle:0.14.0+'
classpath 'com.google.gms:google-services:1.5.0-beta2'
}
} else {
dependencies {
classpath 'com.android.tools.build:gradle:0.12.0+'
classpath 'com.google.gms:google-services:1.5.0-beta2'
}
- Add jcenter to platforms/android/build.gradle
buildscript {
repositories {
jcenter()
mavenCentral()
}
...
- Install plugin https://www.npmjs.com/package/cordova-plugin-gcmpushplugin
cordova plugin add cordova-plugin-gcmpushplugin
- This will create a.o.
platforms/android/cordova-plugin-gcmpushplugin/hello-build-extras.gradle plugins/cordova-plugin-gcmpushplugin/build-extras.gradle
- Edit plugins/cordova-plugin-gcmpushplugin/build-extras.gradle
- to reference the correct versions, e.g.
apply plugin: 'com.google.gms.google-services'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:1.5.0-beta2'
}
}
dependencies {
compile "com.google.android.gms:play-services:8.3.0"
}
- Overwrite other extra file
cp plugins/cordova-plugin-gcmpushplugin/build-extras.gradle platforms/android/cordova-plugin-gcmpushplugin/hello-build-extras.gradle
This is amazing! Thanks a lot! This should be pushed to the main README.md page.
Along with this, I found few more issues
STEP 9:
cp plugins/cordova-plugin-gcmpushplugin/build-extras.gradle platforms/android/cordova-plugin-gcmpushplugin/android-build-extras.gradle
STEP 10: If you get an error like
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;
Then you have to create a separate gradle file by name build-extras.gradle
and place it inside platforms/android
directory. Inside this file you have to add:
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
That's it!. It should build after this.
UPDATE
App crashes as soon as it is launched.
UPDATE
This is because, I was using cordova facebook plugin. If you are doing so, then remove your old cordova plugin and add this: https://github.com/jeduan/cordova-plugin-facebook4/ .
This plugin does not require any change in your UI code. Just replace plugin with your original facebook app name and facebook app id and you are done. Then remove the contents inside build-extras.gradle
. That is it. You are done. It should build.
UPDATE
The build broke again, with the following error:
Found com.google.android.gms:play-services-location:+, but version 8.3.0 is needed for the google-services plugin.
Found com.google.android.gms:play-services-location:+, but version 8.3.0 is needed for the google-services plugin.
Found com.google.android.gms:play-services-location:+, but version 8.3.0 is needed for the google-services plugin.
Found com.google.android.gms:play-services-location:+, but version 8.3.0 is needed for the google-services plugin.
Found com.google.android.gms:play-services-location:+, but version 8.3.0 is needed for the google-services plugin.
:processDebugGoogleServices FAILED
FAILURE: Build failed with an exception.
* What went wrong:
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 8.3.0.
I tried everything, like:
- Updating SDK, Google Repo, Google Play Services and Build Tools
- Replaced my classpath to refer the the version listed in the error
@robert4os @gonzaloaune Any answers for this?
@srameshr , Hey were you able to solve the problem? I am facing the same issue.
Just use phonegap-push
plugin. That is way better and maintained.
ok thanks