Nativescript-plugin-firebase: Incorrect Google Play Services version check in include.gradle

Created on 5 Sep 2018  路  2Comments  路  Source: EddyVerbruggen/nativescript-plugin-firebase

In the file include.gradle there's a check:

if ( VersionNumber.parse( googlePlayServicesVersion ) < VersionNumber.parse( '15.0.0' ) ) {
    throw new GradleException(" googlePlayServicesVersion set too low, please update to at least 15.0.0 ( currently set to $googlePlayServicesVersion )");
}

Which is wrong, as it will report a version of 15.0.+ as being too low as well. It should rather be:

if ( VersionNumber.parse( googlePlayServicesVersion ) < VersionNumber.parse( '15.0.+' ) ) {
    throw new GradleException(" googlePlayServicesVersion set too low, please update to at least 15.0.0 / 15.0.+ ( currently set to $googlePlayServicesVersion )");
}

I would open a PR myself instead of an Issue, but I can't find that file as it looks like it's being generated. Related to this, there's a broken link to this file in the README, under Google Play Services Version:

The plugin will default to this version of the Android play-services-base...

Android

Most helpful comment

@Danziger
https://github.com/EddyVerbruggen/nativescript-plugin-firebase/blob/master/src/scripts/postinstall.js
That is the file that generates these, I believe.

However, to get around it for now you can also do this in your app.gradle:

dependencies {
    configurations.all {
        exclude group: 'commons-logging', module: 'commons-logging'
        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
            def requested = details.requested
            if (requested.group == 'com.google.android.gms' || requested.group == 'com.google.firebase') {
                details.useVersion '+'
            } else if (requested.group == 'com.android.support' && requested.name != 'multidex') {
                // com.android.support major version should match buildToolsVersion
                details.useVersion '27.+'
            }
        }
    }
    implementation "com.google.android.gms:play-services-tagmanager:15.0.0"
}

project.ext {
  // TODO PR this so that '15.+' can be used
    googlePlayServicesVersion = "15.0.0"
    supportVersion = "27.+"
}

As you can see there, I've also been meaning to PR this, but it needs to be able to handle the + in any of the 3 positions, as well.

But that snippet above will override all gms/firebase stuff to latest (+) as unfortunately there isn't really unified version for those right now and they're sort of all over the place.

In general the best way to override version conflicts in Gradle, as I also use it to force the android.support versions.

All 2 comments

@Danziger
https://github.com/EddyVerbruggen/nativescript-plugin-firebase/blob/master/src/scripts/postinstall.js
That is the file that generates these, I believe.

However, to get around it for now you can also do this in your app.gradle:

dependencies {
    configurations.all {
        exclude group: 'commons-logging', module: 'commons-logging'
        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
            def requested = details.requested
            if (requested.group == 'com.google.android.gms' || requested.group == 'com.google.firebase') {
                details.useVersion '+'
            } else if (requested.group == 'com.android.support' && requested.name != 'multidex') {
                // com.android.support major version should match buildToolsVersion
                details.useVersion '27.+'
            }
        }
    }
    implementation "com.google.android.gms:play-services-tagmanager:15.0.0"
}

project.ext {
  // TODO PR this so that '15.+' can be used
    googlePlayServicesVersion = "15.0.0"
    supportVersion = "27.+"
}

As you can see there, I've also been meaning to PR this, but it needs to be able to handle the + in any of the 3 positions, as well.

But that snippet above will override all gms/firebase stuff to latest (+) as unfortunately there isn't really unified version for those right now and they're sort of all over the place.

In general the best way to override version conflicts in Gradle, as I also use it to force the android.support versions.

Hey guys, thanks for the feedback here. I've changed the implementation to what @Danziger suggested and confirmed that works really well. Included in 7.0.0.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SBD580 picture SBD580  路  3Comments

NNieto picture NNieto  路  4Comments

bunower picture bunower  路  3Comments

andrewexton373 picture andrewexton373  路  4Comments

tsili852 picture tsili852  路  3Comments