1

We recently switched from free google maps library to maps for work. I changed all imports from com.google.android.gms.maps to com.google.android.m4b.maps and imported compiled aar library. We have valid licence.

Only thing I haven't found in docs is proguard settings and I'm having troubles with it. After some research I did a "blind guess" configuration with adding lines:

-dontwarn sun.misc.Unsafe
-keep class com.google.android.m4b.common.** { *; }
-keep class com.google.android.m4b.ads.identifier.** { *; }
-keep class com.google.android.m4b.maps.** { *; }
-keep class com.google.android.m4b.** { *; }
-keep class com.google.android.geo.** { *; }
-keep class android.support.v4.** { *; }
-keepattributes InnerClasses
-dontoptimize

It compiles somehow (apk is created), but gradle still returns an error:

AGPBI: {"kind":"error","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]}
AGPBI: {"kind":"error","text":"(com.google.android.m4b.maps.ca.a) that doesn\u0027t come with an","sources":[{}]}
AGPBI: {"kind":"error","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]}
AGPBI: {"kind":"error","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]}
AGPBI: {"kind":"error","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]}
AGPBI: {"kind":"error","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]}
AGPBI: {"kind":"error","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]}
AGPBI: {"kind":"error","text":"indicate that it is *not* an inner class.","sources":[{}]}

Anyway, I don't want to rely on blind guess, and I'm not an proguard expert. Is there an official guide for maps for work?

If not - which lines of above "guessed" proguard configuration do I have to keep, what am I missing, and which lines can I get rid of?

Daniel Dudek
  • 515
  • 7
  • 17

2 Answers2

0

If you're using Android Studio, as noted in Setting Up Google Play Services,

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.

In any other cases, you may also check these additional references:

Teyam
  • 7,686
  • 3
  • 15
  • 22
0

this "error" is actually a warning (as the message reads) ...

you might have to disable optimization, until issue #215748 had been fixed:

 -keepattributes InnerClasses
 -dontoptimize
Martin Zeitler
  • 1
  • 19
  • 155
  • 216