ostownsville / cordova-plugin-fcm

Google FCM Push Notifications Cordova Plugin
21 stars 17 forks source link

Android Firebase and Google Services - Out Of Date #14

Closed chrisjpalmer closed 6 years ago

chrisjpalmer commented 6 years ago

Hi @ostownsville

I have noticed that when I build using cordova build android, I get the following messages:

google-services plugin could not detect any version for com.google.android.gms or com.google.firebase, default version: 9.0.0 will be used.
please apply google-services plugin at the bottom of the build file.

I checked out out FCMPlugin.gradle under the plugins/cordova-plugin-fcm/android and found this:

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`

Google Services Information for the latest google-services dependancy is found at: https://bintray.com/android/android-tools/com.google.gms.google-services/#read The latest version is 3.1.1.

I tried changing the version to 3.1.1 and running cordova build android but got the following error:

image

Firebase Information on the latest firebase sdk for android is found at: https://developers.google.com/android/guides/releases?authuser=0 The latest version is 11.4.2 however it would appear that my system is picking v9.0.0 as the above warning message says.

If you look in build.gradle under platforms/android, you can find this:

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.google.firebase:firebase-core:+"
    compile "com.google.firebase:firebase-messaging:+"
    // SUB-PROJECT DEPENDENCIES END
}

Cordova generates this whenever cordova build android is invoked.

Attempt new dependencies As an experiment I changed the following in project.properties from:

target=android-25
android.library.reference.1=CordovaLib
cordova.gradle.include.1=cordova-plugin-badge/rmc-badge.gradle
cordova.system.library.1=com.google.firebase:firebase-core:+
cordova.system.library.2=com.google.firebase:firebase-messaging:+
cordova.gradle.include.2=cordova-plugin-fcm/rmc-FCMPlugin.gradle

to this:

target=android-25
android.library.reference.1=CordovaLib
cordova.gradle.include.1=cordova-plugin-badge/rmc-badge.gradle
cordova.system.library.1=com.google.firebase:firebase-core:11.4.2
cordova.system.library.2=com.google.firebase:firebase-messaging:11.4.2
cordova.gradle.include.2=cordova-plugin-fcm/rmc-FCMPlugin.gradle

cordova build android updated the build.gradle file to reflect the newest 11.4.2 BUT got the following error:

image

ostownsville commented 6 years ago

Yeah, I have noticed that, I'll do some testing there as well.

nairbinod commented 6 years ago

how to get this to work with Ionic Pro

CowboyCode commented 6 years ago

Here is some information on this problem, apparently a cordova issue. Build with Android Studio may works, untested. https://github.com/phonegap/phonegap-plugin-push/issues/1718

@chrisjpalmer This is actually a mess, apparently a cordova problem as it doesn't take the versions and defaults always to version 9.0.0, when the build.gradle is generated.

May have to get this running, tried it, didn't work.... https://github.com/transistorsoft/cordova-google-api-version

CowboyCode commented 6 years ago

I close this...