зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1233238 - Compile with play-services-{ads,analytics,appindexing} to support Adjust SDK. r=nalexander
On a CLOSED TREE because this is Android only. When we switched to fine-grained Google Play Services bundling (Bug 1115004), we stopped shipping com.google.android.gms.analytics. That silently breaks Adjust, which queries the Google Ad ID using reflection: now the package isn't present! This patch restores the Play Services libraries that Adjust relies on. (Sadly, this bloats our APK tremendously.) There is some hijinkery, however: the Play Services libraries reference a library (org.apache.http) that is deprecated in Android 23! However, the library is still present on Android 23 devices, which buys Google time to replace the offending code. This compiles just fine, breaks the Proguard global optimization pass. To give Proguard the information, we add the library as a Proguard "library JAR". This is equivalent to the Google-provided Gradle `useLibrary` directive. --HG-- extra : commitid : I4rTyC8lxLd extra : rebase_source : 96f30d735e898cb9853d53f236ac8e2337186814 extra : amend_source : 3e4d68789b3ef980e4e1d7f743e332bdbb6be176
This commit is contained in:
Родитель
07130208f3
Коммит
c48a870a5f
|
@ -356,6 +356,19 @@ fi
|
|||
|
||||
])
|
||||
|
||||
AC_DEFUN([MOZ_ANDROID_INSTALL_TRACKING],
|
||||
[
|
||||
|
||||
if test -n "$MOZ_INSTALL_TRACKING"; then
|
||||
AC_SUBST(MOZ_INSTALL_TRACKING)
|
||||
MOZ_ANDROID_AAR(play-services-ads, 8.1.0, google, com/google/android/gms)
|
||||
MOZ_ANDROID_AAR(play-services-analytics, 8.1.0, google, com/google/android/gms)
|
||||
MOZ_ANDROID_AAR(play-services-appindexing, 8.1.0, google, com/google/android/gms)
|
||||
MOZ_ANDROID_AAR(play-services-basement, 8.1.0, google, com/google/android/gms)
|
||||
fi
|
||||
|
||||
])
|
||||
|
||||
dnl Configure an Android SDK.
|
||||
dnl Arg 1: target SDK version, like 22.
|
||||
dnl Arg 2: build tools version, like 22.0.1.
|
||||
|
|
|
@ -4660,6 +4660,7 @@ dnl ========================================================
|
|||
|
||||
MOZ_ANDROID_GOOGLE_PLAY_SERVICES
|
||||
MOZ_ANDROID_GOOGLE_CLOUD_MESSAGING
|
||||
MOZ_ANDROID_INSTALL_TRACKING
|
||||
|
||||
|
||||
dnl ========================================================
|
||||
|
|
|
@ -116,6 +116,13 @@ dependencies {
|
|||
compile 'com.google.android.gms:play-services-cast:8.1.0'
|
||||
}
|
||||
|
||||
if (mozconfig.substs.MOZ_INSTALL_TRACKING) {
|
||||
compile 'com.google.android.gms:play-services-ads:8.1.0'
|
||||
compile 'com.google.android.gms:play-services-analytics:8.1.0'
|
||||
compile 'com.google.android.gms:play-services-appindexing:8.1.0'
|
||||
compile 'com.google.android.gms:play-services-basement:8.1.0'
|
||||
}
|
||||
|
||||
if (mozconfig.substs.MOZ_ANDROID_GCM) {
|
||||
compile 'com.google.android.gms:play-services-basement:8.1.0'
|
||||
compile 'com.google.android.gms:play-services-base:8.1.0'
|
||||
|
|
|
@ -82,6 +82,15 @@ ifdef MOZ_ANDROID_GCM
|
|||
$(NULL)
|
||||
endif
|
||||
|
||||
ifdef MOZ_INSTALL_TRACKING
|
||||
JAVA_CLASSPATH += \
|
||||
$(ANDROID_PLAY_SERVICES_ADS_AAR_LIB) \
|
||||
$(ANDROID_PLAY_SERVICES_ANALYTICS_AAR_LIB) \
|
||||
$(ANDROID_PLAY_SERVICES_APPINDEXING_AAR_LIB) \
|
||||
$(ANDROID_PLAY_SERVICES_BASEMENT_AAR_LIB) \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
JAVA_CLASSPATH := $(subst $(NULL) ,:,$(strip $(JAVA_CLASSPATH)))
|
||||
|
||||
# Library jars that we're bundling: these are subject to Proguard before inclusion
|
||||
|
@ -112,6 +121,15 @@ ifdef MOZ_ANDROID_GCM
|
|||
$(NULL)
|
||||
endif
|
||||
|
||||
ifdef MOZ_INSTALL_TRACKING
|
||||
java_bundled_libs += \
|
||||
$(ANDROID_PLAY_SERVICES_ADS_AAR_LIB) \
|
||||
$(ANDROID_PLAY_SERVICES_ANALYTICS_AAR_LIB) \
|
||||
$(ANDROID_PLAY_SERVICES_APPINDEXING_AAR_LIB) \
|
||||
$(ANDROID_PLAY_SERVICES_BASEMENT_AAR_LIB) \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
# uniq purloined from http://stackoverflow.com/a/16151140.
|
||||
uniq = $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
|
||||
|
||||
|
@ -157,6 +175,30 @@ library_jars := \
|
|||
$(ANDROID_SDK)/android.jar \
|
||||
$(NULL)
|
||||
|
||||
# Android 23 (Marshmallow) deprecated a part of the Android platform, namely the
|
||||
# org.apache.http package. Fennec removed all code that referenced said package
|
||||
# in order to easily ship to Android 23 devices (and, by extension, all devices
|
||||
# before Android 23).
|
||||
#
|
||||
# Google did not remove all code that referenced said package in their own
|
||||
# com.google.android.gms namespace! It turns out that the org.apache.http
|
||||
# package is not removed, only deprecated and hidden by default. Google added a
|
||||
# a `useLibrary` Gradle directive that allows legacy code to reference the
|
||||
# package, which is still (hidden) in the Android 23 platform.
|
||||
#
|
||||
# Fennec code doesn't need to compile against the deprecated package, since our
|
||||
# code doesn't reference the package anymore. However, we do need to Proguard
|
||||
# against the deprecated package. If we don't, Proguard -- which is a global
|
||||
# optimization -- sees Google libraries referencing "non-existent" libraries and
|
||||
# complains. The solution is to mimic the `useLibraries` directive by declaring
|
||||
# the legacy package as a provided library jar.
|
||||
#
|
||||
# See https://bugzilla.mozilla.org/show_bug.cgi?id=1233238#c19 for symptoms and
|
||||
# more discussion.
|
||||
ifdef MOZ_INSTALL_TRACKING
|
||||
library_jars += $(ANDROID_SDK)/optional/org.apache.http.legacy.jar
|
||||
endif # MOZ_INSTALL_TRACKING
|
||||
|
||||
library_jars := $(subst $(NULL) ,:,$(strip $(library_jars)))
|
||||
|
||||
classes.dex: .proguard.deps
|
||||
|
@ -389,6 +431,9 @@ generated/android/support/design/R.java: .aapt.deps ;
|
|||
generated/android/support/v7/mediarouter/R.java: .aapt.deps ;
|
||||
generated/android/support/v7/recyclerview/R.java: .aapt.deps ;
|
||||
generated/com/google/android/gms/R.java: .aapt.deps ;
|
||||
generated/com/google/android/gms/ads/R.java: .aapt.deps ;
|
||||
generated/com/google/android/gms/analytics/R.java: .aapt.deps ;
|
||||
generated/com/google/android/gms/appindexing/R.java: .aapt.deps ;
|
||||
generated/com/google/android/gms/base/R.java: .aapt.deps ;
|
||||
generated/com/google/android/gms/cast/R.java: .aapt.deps ;
|
||||
generated/com/google/android/gms/gcm/R.java: .aapt.deps ;
|
||||
|
|
|
@ -741,6 +741,35 @@ if CONFIG['MOZ_ANDROID_GCM']:
|
|||
ANDROID_EXTRA_RES_DIRS += ['%' + CONFIG['ANDROID_PLAY_SERVICES_GCM_AAR_RES']]
|
||||
resjar.generated_sources += ['com/google/android/gms/gcm/R.java']
|
||||
|
||||
if CONFIG['MOZ_INSTALL_TRACKING']:
|
||||
gbjar.extra_jars += [
|
||||
CONFIG['ANDROID_PLAY_SERVICES_ADS_AAR_LIB'],
|
||||
CONFIG['ANDROID_PLAY_SERVICES_ANALYTICS_AAR_LIB'],
|
||||
CONFIG['ANDROID_PLAY_SERVICES_APPINDEXING_AAR_LIB'],
|
||||
CONFIG['ANDROID_PLAY_SERVICES_BASEMENT_AAR_LIB'],
|
||||
]
|
||||
|
||||
if CONFIG['ANDROID_PLAY_SERVICES_ADS_AAR']:
|
||||
ANDROID_EXTRA_PACKAGES += ['com.google.android.gms.ads']
|
||||
ANDROID_EXTRA_RES_DIRS += ['%' + CONFIG['ANDROID_PLAY_SERVICES_ADS_AAR_RES']]
|
||||
resjar.generated_sources += ['com/google/android/gms/ads/R.java']
|
||||
|
||||
if CONFIG['ANDROID_PLAY_SERVICES_ANALYTICS_AAR']:
|
||||
ANDROID_EXTRA_PACKAGES += ['com.google.android.gms.analytics']
|
||||
ANDROID_EXTRA_RES_DIRS += ['%' + CONFIG['ANDROID_PLAY_SERVICES_ANALYTICS_AAR_RES']]
|
||||
resjar.generated_sources += ['com/google/android/gms/analytics/R.java']
|
||||
|
||||
if CONFIG['ANDROID_PLAY_SERVICES_APPINDEXING_AAR']:
|
||||
ANDROID_EXTRA_PACKAGES += ['com.google.android.gms.appindexing']
|
||||
ANDROID_EXTRA_RES_DIRS += ['%' + CONFIG['ANDROID_PLAY_SERVICES_APPINDEXING_AAR_RES']]
|
||||
resjar.generated_sources += ['com/google/android/gms/appindexing/R.java']
|
||||
|
||||
|
||||
if CONFIG['ANDROID_PLAY_SERVICES_BASEMENT_AAR']:
|
||||
ANDROID_EXTRA_PACKAGES += ['com.google.android.gms']
|
||||
ANDROID_EXTRA_RES_DIRS += ['%' + CONFIG['ANDROID_PLAY_SERVICES_BASEMENT_AAR_RES']]
|
||||
resjar.generated_sources += ['com/google/android/gms/R.java']
|
||||
|
||||
gbjar.extra_jars += [CONFIG['ANDROID_APPCOMPAT_V7_AAR_LIB']]
|
||||
gbjar.extra_jars += [CONFIG['ANDROID_DESIGN_AAR_LIB']]
|
||||
gbjar.extra_jars += [CONFIG['ANDROID_RECYCLERVIEW_V7_AAR_LIB']]
|
||||
|
|
Загрузка…
Ссылка в новой задаче