Bug 1463376 - Update to latest Google Play Services version draft
authorAndrei Lazar <andrei.a.lazar@softvision.ro>
Fri, 13 Jul 2018 15:40:03 +0300
changeset 817970 e7429a79a2e453e0df0364d1e6cb41ee6fd21db2
parent 817842 c044a353f650ff563062d4dcd11544d2ccbbeb9e
child 817971 0bc1f163e9e3118d808a4e4f49479928eff27db6
push id116231
push userplingurar@mozilla.com
push dateFri, 13 Jul 2018 19:23:06 +0000
bugs1463376
milestone63.0a1
Bug 1463376 - Update to latest Google Play Services version 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/config/mozconfigs/android-api-16-frontend/nightly
mobile/android/config/mozconfigs/android-api-16-gradle-dependencies/nightly
mobile/android/thirdparty/build.gradle
--- a/build.gradle
+++ b/build.gradle
@@ -49,17 +49,17 @@ buildscript {
             url "file://${gradle.mozconfig.topsrcdir}/mobile/android/gradle/m2repo"
         }
     }
 
     ext.kotlin_version = '1.2.41'
     ext.support_library_version = '26.1.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.1'
     }
 
     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 +109,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
@@ -239,17 +239,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'
@@ -439,16 +438,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 "$google_play_services_version"
+            }
+        }
+    }
+}
+
 android.applicationVariants.all { variant ->
     // Like 'local', 'localOld', or 'official'.
     def audienceDimension = variant.productFlavors[0].name
     if (!audienceDimension.equals('official')) {
         return
     }
 
     variant.outputs.each { output ->
@@ -461,21 +474,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/config/mozconfigs/android-api-16-frontend/nightly
+++ b/mobile/android/config/mozconfigs/android-api-16-frontend/nightly
@@ -26,11 +26,12 @@ ac_add_options --disable-tests
 # Engineering team.
 ac_add_options --with-android-min-sdk=16
 ac_add_options --target=arm-linux-androideabi
 
 ac_add_options --with-branding=mobile/android/branding/nightly
 
 export MOZILLA_OFFICIAL=1
 export MOZ_TELEMETRY_REPORTING=1
+export MOZ_ANDROID_MMA=1
 export MOZ_ANDROID_POCKET=1
 
 . "$topsrcdir/mobile/android/config/mozconfigs/common.override"
--- a/mobile/android/config/mozconfigs/android-api-16-gradle-dependencies/nightly
+++ b/mobile/android/config/mozconfigs/android-api-16-gradle-dependencies/nightly
@@ -31,16 +31,17 @@ ac_add_options --disable-tests
 # Engineering team.
 ac_add_options --with-android-min-sdk=16
 ac_add_options --target=arm-linux-androideabi
 
 ac_add_options --with-branding=mobile/android/branding/nightly
 
 export MOZILLA_OFFICIAL=1
 export MOZ_TELEMETRY_REPORTING=1
+export MOZ_ANDROID_MMA=1
 export MOZ_ANDROID_POCKET=1
 
 . "$topsrcdir/mobile/android/config/mozconfigs/common.override"
 
 # End ../android-api-16-frontend/nightly.
 
 # Disable Keyfile Loading (and checks) since dependency fetching doesn't need these keys.
 # This overrides the settings in the common android mozconfig
--- 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.