1

Im using

compile 'com.google.android.gms:play-services-maps:9.4.0'
compile 'com.google.android.gms:play-services-location:9.4.0'
compile 'com.google.android.gms:play-services-places:9.4.0'
compile 'com.google.android.gms:play-services-analytics:9.4.0'

The official docs says:

ProGuard directives are included in the Play services client libraries to preserve the required classes. The Android Plugin for Gradle automatically appends ProGuard configuration files in an AAR (Android ARchive) package and appends that package to your ProGuard configuration. During project creation, Android Studio automatically creates the ProGuard configuration files and build.gradle properties for ProGuard use. To use ProGuard with Android Studio, you must enable the ProGuard setting in your build.gradle buildTypes. For more information, see the ProGuard guide.

However, on using proguard without keeping any classes from play services I get the following exception:

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.location.places.ui.SupportPlaceAutocompleteFragment"

Then I was able to solve this problem by adding:

-keep class com.google.android.gms.** { *; }

It works perfectly but unfortunately the apk size has now increased by 1MB. It's not just about SupportPlaceAutocompleteFragment, if I use those libraries without keeping their classes even GCM and getLocation features stop working.

I feel I am doing something wrong because the official docs insist on not adding proguard rules for play services. Please help.

Timmy Simons
  • 599
  • 8
  • 21
  • So what is the exact problem? – ReyAnthonyRenacia Aug 30 '16 at 10:43
  • @noogui the solution of keeping classes is not acceptable to us because it increases the apk size. The official docs never said anything about adding proguard rules for play services so I guess there must be something Im missing – Timmy Simons Aug 30 '16 at 18:33
  • Google Play Services aars contain proguard.txt with the necessary clauses. So the setting shouldn't really be necessary. You can investigate what happened with the fragment in ProGuard output files. Check app/build/output/mapping/{buildVariant}/usage.txt and mapping.txt. The fragment should be mentioned in one of those. – Tomik Aug 31 '16 at 09:10

0 Answers0