Bug 1233238 - (wip) Compile with play-services-analytics. r=nalexander
This will let us properly configure the Adjust SDK.
When running build, I get the following error:
0:24.61 Warning: com.google.android.gms.analytics.internal.zzam: can't find referenced class org.apache.http.NameValuePair
0:24.61 Warning: com.google.android.gms.analytics.internal.zzam: can't find referenced class org.apache.http.client.utils.URLEncodedUtils
...
There is precedent for this in
bug 1197147, where we fixed it by removing the
google play services which caused the errors.
Unfortunately, it's an official error on Google code too:
https://code.google.com/p/android-developer-preview/issues/detail?id=3001
Workarounds from the thread are [1]:
1. Use Proguard:
-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**
2. Or simply add the library back into your app:
android {
useLibrary 'org.apache.http.legacy'
}
---
The official Google response is [2]:
The development team has fixed the issue that you have reported and
it will be available in a future build.
Workaround for time being: Right the issue is that you need to put
the useLibrary element if you need to compile against it. But if
you don't compile your code against it but you have 3rd party libs
that use it and you run through proguard (Which is picky about
wanting to see all the classes that are used), then we need to pass
it to proguard whether you ask for it for compiling or not.
The short term work-around is to ask for the library for compiling
(which will then also add it to the classpath that we give to
proguard).
[1]: https://code.google.com/p/android-developer-preview/issues/detail?id=3001#c31
[2]: https://code.google.com/p/android-developer-preview/issues/detail?id=3001#c35
--- a/build/autoconf/android.m4
+++ b/build/autoconf/android.m4
@@ -351,16 +351,29 @@ if test -n "$MOZ_ANDROID_GCM" ; then
MOZ_ANDROID_AAR(play-services-base, 8.1.0, google, com/google/android/gms)
MOZ_ANDROID_AAR(play-services-basement, 8.1.0, google, com/google/android/gms)
MOZ_ANDROID_AAR(play-services-gcm, 8.1.0, google, com/google/android/gms)
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.
AC_DEFUN([MOZ_ANDROID_SDK],
[
MOZ_ARG_WITH_STRING(android-sdk,
[ --with-android-sdk=DIR
--- a/configure.in
+++ b/configure.in
@@ -4635,16 +4635,17 @@ AC_SUBST(MOZ_DISTRIBUTION_ID)
dnl ========================================================
dnl Google Play Services, placed here so it can depend on
dnl values set by configure.sh above.
dnl ========================================================
MOZ_ANDROID_GOOGLE_PLAY_SERVICES
MOZ_ANDROID_GOOGLE_CLOUD_MESSAGING
+MOZ_ANDROID_INSTALL_TRACKING
dnl ========================================================
dnl = Pango
dnl ========================================================
if test "$MOZ_ENABLE_GTK" -o "$MOZ_ENABLE_QT"
then
PKG_CHECK_MODULES(_PANGOCHK, pango >= $PANGO_VERSION)
--- a/mobile/android/app/base/build.gradle
+++ b/mobile/android/app/base/build.gradle
@@ -111,16 +111,23 @@ dependencies {
if (mozconfig.substs.MOZ_NATIVE_DEVICES) {
compile 'com.android.support:mediarouter-v7:23.0.1'
compile 'com.google.android.gms:play-services-basement:8.1.0'
compile 'com.google.android.gms:play-services-base:8.1.0'
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'
compile 'com.google.android.gms:play-services-gcm:8.1.0'
}
// Gradle based builds include LeakCanary. Mach based builds only include the no-op version of
// this library.
--- a/mobile/android/base/Makefile.in
+++ b/mobile/android/base/Makefile.in
@@ -77,16 +77,25 @@ endif
ifdef MOZ_ANDROID_GCM
JAVA_CLASSPATH += \
$(ANDROID_PLAY_SERVICES_BASE_AAR_LIB) \
$(ANDROID_PLAY_SERVICES_BASEMENT_AAR_LIB) \
$(ANDROID_PLAY_SERVICES_GCM_AAR_LIB) \
$(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
# into classes.dex.
java_bundled_libs := \
$(ANDROID_SUPPORT_V4_AAR_LIB) \
$(ANDROID_SUPPORT_V4_AAR_INTERNAL_LIB) \
$(ANDROID_APPCOMPAT_V7_AAR_LIB) \
@@ -107,16 +116,25 @@ endif
ifdef MOZ_ANDROID_GCM
java_bundled_libs += \
$(ANDROID_PLAY_SERVICES_BASE_AAR_LIB) \
$(ANDROID_PLAY_SERVICES_BASEMENT_AAR_LIB) \
$(ANDROID_PLAY_SERVICES_GCM_AAR_LIB) \
$(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)))
java_bundled_libs := $(call uniq,$(java_bundled_libs))
java_bundled_libs := $(subst $(NULL) ,:,$(strip $(java_bundled_libs)))
# All the jars we're compiling from source. (not to be confused with
# java_bundled_libs, which holds the jars which we're including as binaries).
@@ -384,16 +402,19 @@ generated/org/mozilla/gecko/R.java: .aap
# If native devices are enabled, add Google Play Services, build their resources
generated/android/support/v4/R.java: .aapt.deps ;
generated/android/support/v7/appcompat/R.java: .aapt.deps ;
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 ;
gecko.ap_: .aapt.deps ;
R.txt: .aapt.deps ;
# [Comment 2/3] This tom-foolery provides a target that forces a
--- a/mobile/android/base/moz.build
+++ b/mobile/android/base/moz.build
@@ -735,16 +735,45 @@ if CONFIG['MOZ_ANDROID_GCM']:
ANDROID_EXTRA_RES_DIRS += ['%' + CONFIG['ANDROID_PLAY_SERVICES_BASEMENT_AAR_RES']]
resjar.generated_sources += ['com/google/android/gms/R.java']
if CONFIG['ANDROID_PLAY_SERVICES_GCM_AAR']:
ANDROID_EXTRA_PACKAGES += ['com.google.android.gms.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']]
gbjar.javac_flags += ['-Xlint:all,-deprecation,-fallthrough', '-J-Xmx512m', '-J-Xms128m']
# gecko-thirdparty is a good place to put small independent libraries
gtjar = add_java_jar('gecko-thirdparty')