Bug 1463376 - Update to latest Google Play Services version r?JanH draft
authorAndrei Lazar <andrei.a.lazar@softvision.ro>
Mon, 09 Jul 2018 17:22:26 +0300
changeset 815608 e39706faca357def7b2e2cd15f8ba57a56d95626
parent 815592 3d20b0701781731e0f9b08e1cd40ac842f385e03
push id115573
push userbmo:andrei.a.lazar@softvision.ro
push dateMon, 09 Jul 2018 14:24:30 +0000
reviewersJanH
bugs1463376
milestone63.0a1
Bug 1463376 - Update to latest Google Play Services version r?JanH Updated google play services version as part of work of the Oreo migration and removed unused libraries from gradle. MozReview-Commit-ID: BKCWs938k3q ***
build.gradle
mobile/android/app/build.gradle
mobile/android/base/java/org/mozilla/gecko/ChromeCastDisplay.java
mobile/android/thirdparty/build.gradle
--- a/build.gradle
+++ b/build.gradle
@@ -26,40 +26,42 @@ allprojects {
         ]
     }
 
     repositories {
         gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
             maven {
                 url repository
             }
+            google()
         }
     }
 }
 
 buildDir "${topobjdir}/gradle/build"
 
 buildscript {
     repositories {
         gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
             maven {
                 url repository
             }
         }
+        google()
         // For in tree plugins.
         maven {
             url "file://${gradle.mozconfig.topsrcdir}/mobile/android/gradle/m2repo"
         }
     }
 
     ext.kotlin_version = '1.2.41'
     ext.support_library_version = '23.4.0'
 
     if (gradle.mozconfig.substs.MOZ_ANDROID_GOOGLE_PLAY_SERVICES) {
-        ext.google_play_services_version = '8.4.0'
+        ext.google_play_services_version = '15.0.0'
     }
 
     dependencies {
         classpath 'com.android.tools.build:gradle:3.0.1'
         classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.2'
         classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
     }
 }
@@ -109,16 +111,26 @@ afterEvaluate {
                     // Deprecation, because we do use deprecated API for compatibility.
                     "-Xlint:-deprecation",
                     // Serial, because we don't use Java serialization.
                     "-Xlint:-serial",
                     // Turn all remaining warnings into errors,
                     // unless marked by @SuppressWarnings.
                     "-Werror"]
             }
+            if (project.name == 'app') {
+                tasks.withType(JavaCompile) {
+                    // Turn off classfile warnings because upon updating to play services 15.0.0
+                    // a warning is being thrown from play-services-base which fails the build
+                    // (com/google/android/gms/common/api/GoogleApiClient.class):
+                    // warning: Cannot find annotation method 'value()' in type 'GuardedBy':
+                    // class file for javax.annotation.concurrent.GuardedBy not found
+                    options.compilerArgs += ["-Xlint:-classfile"]
+                }
+            }
         }
 
         if (!hasProperty('android')) {
             return
         }
         android.applicationVariants.all {
             preBuild.dependsOn rootProject.generateCodeAndResources
         }
--- a/mobile/android/app/build.gradle
+++ b/mobile/android/app/build.gradle
@@ -233,17 +233,16 @@ dependencies {
         implementation "com.google.android.gms:play-services-analytics:$google_play_services_version"
         implementation "com.google.android.gms:play-services-basement:$google_play_services_version"
     }
 
     if (mozconfig.substs.MOZ_ANDROID_GCM) {
         implementation "com.google.android.gms:play-services-basement:$google_play_services_version"
         implementation "com.google.android.gms:play-services-base:$google_play_services_version"
         implementation "com.google.android.gms:play-services-gcm:$google_play_services_version"
-        implementation "com.google.android.gms:play-services-measurement:$google_play_services_version"
     }
 
     // Include LeakCanary in local builds, but not in official builds.  Mach
     // builds target the official audience, so LeakCanary will not be included
     // in any Mach build.
     localImplementation 'com.squareup.leakcanary:leakcanary-android:1.4-beta1'
     officialImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
     testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
@@ -433,16 +432,30 @@ android.applicationVariants.all configur
 
 
 // Bug 1320310 - Hack up the manifest produced by Gradle to match that produced
 // by moz.build.  Per https://bugzilla.mozilla.org/show_bug.cgi?id=1320310#c14,
 // this breaks launching in Android Studio; therefore, we only do this for
 // official automation builds and not for local developer builds.
 import groovy.xml.XmlUtil
 
+// Workaround for fixing sub-dependencies upon gradle error:
+// All gms/firebase libraries must use the exact same version specification (mixing versions can
+// lead to runtime crashes). Found versions 15.0.1, 15.0.0. Examples include
+// com.google.android.gms:play-services-base:15.0.1 and com.google.android.gms:play-services-cast:15.0.0
+configurations.all {
+    resolutionStrategy {
+        eachDependency { DependencyResolveDetails details ->
+            if (details.requested.group == 'com.google.android.gms') {
+                details.useVersion "15.0.0"
+            }
+        }
+    }
+}
+
 android.applicationVariants.all { variant ->
     // Like 'local', 'localOld', or 'official'.
     def audienceDimension = variant.productFlavors[0].name
     if (!audienceDimension.equals('official')) {
         return
     }
 
     variant.outputs.each { output ->
@@ -455,21 +468,16 @@ android.applicationVariants.all { varian
                     // A non-validating, non-namespace aware XML processor.
                     def xml = new XmlSlurper(false, false).parseText(contents)
 
                     // First, reinstate our <activity-alias android:name=".App">.
                     xml.depthFirst()
                         .findAll { it.name() == 'activity-alias' && it.'@android:name' == 'org.mozilla.gecko.App' }
                         .each { it.'@android:name' = '.App' }
 
-                    // Second, cull all manifest entries provided by com.google.android.gms.measurement.
-                    xml.depthFirst()
-                        .findAll { it.'@android:name'.text().contains('AppMeasurement') }
-                        .each { it.replaceNode {} }
-
                     manifestOutFile.write(XmlUtil.serialize(xml), 'UTF-8')
                 }
             })
         }
     }
 }
 
 android.applicationVariants.all { variant ->
--- a/mobile/android/base/java/org/mozilla/gecko/ChromeCastDisplay.java
+++ b/mobile/android/base/java/org/mozilla/gecko/ChromeCastDisplay.java
@@ -1,17 +1,16 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * vim: ts=4 sw=4 expandtab:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko;
 
-import org.mozilla.gecko.R;
 import org.mozilla.gecko.util.EventCallback;
 import org.mozilla.gecko.util.GeckoBundle;
 
 import com.google.android.gms.cast.CastDevice;
 import com.google.android.gms.cast.CastRemoteDisplayLocalService;
 import com.google.android.gms.common.ConnectionResult;
 import com.google.android.gms.common.GooglePlayServicesUtil;
 import com.google.android.gms.common.api.Status;
@@ -91,17 +90,22 @@ public class ChromeCastDisplay implement
                     callback.sendSuccess("Succeed to start presentation.");
                 }
 
                 @Override
                 public void onRemoteDisplaySessionError(Status errorReason) {
                     int code = errorReason.getStatusCode();
                     callback.sendError("Fail to start presentation. Error code: " + code);
                 }
-        });
+
+                @Override
+                public void onRemoteDisplaySessionEnded(CastRemoteDisplayLocalService castRemoteDisplayLocalService) {
+
+                }
+            });
     }
 
     @Override
     public void stop(EventCallback callback) {
         CastRemoteDisplayLocalService.stopService();
         callback.sendSuccess("Succeed to stop presentation.");
     }
 }
--- a/mobile/android/thirdparty/build.gradle
+++ b/mobile/android/thirdparty/build.gradle
@@ -43,16 +43,18 @@ android {
 }
 
 dependencies {
     implementation "com.android.support:support-v4:$support_library_version"
     if (mozconfig.substs.MOZ_ANDROID_MMA) {
         implementation "com.android.support:appcompat-v7:$support_library_version"
         implementation "com.android.support:support-annotations:$support_library_version"
         implementation "com.google.android.gms:play-services-gcm:$google_play_services_version"
+        implementation "com.google.android.gms:play-services-basement:$google_play_services_version"
+        implementation "com.google.android.gms:play-services-ads-identifier:$google_play_services_version"
     }
 }
 
 apply plugin: 'idea'
 
 idea {
     module {
         // This is cosmetic.  See the excludes in the root project.