Google Play services allow gradle to ignore proguard configuration

I’m working on the "Log in to Google" setting in my application. I used the official documentation for this.

So my configuration does not look like this:

Gradle top level file:

buildscript {
  repositories {
    jcenter()
    mavenCentral()
    maven { url 'https://maven.fabric.io/public' }
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:1.5.0'
    classpath 'io.fabric.tools:gradle:1.+'
    classpath 'com.google.gms:google-services:1.5.0'
  }
}

app.gradle file

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
   buildTypes {
      minifyEnabled true
      shrinkResources true
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
      signingConfig signingConfigs.release
  }
}

dependencies {
    // retrofit, twitter sdk, eventbus, support library, activeandroid
    // Google SignIn
    compile 'com.google.android.gms:play-services-auth:8.3.0'
}

And the problem is that the application does not start now with the exception that the ActiveAndroid classes are not found, and during the build I receive billions of messages (below). It seems that including google play services are ignoring my proguard rules. If I remove these dependencies, the application will work well and start without any errors.

Note: com.google.protobuf.GeneratedMessageLite$SerializedForm accesses a method 'newBuilder()' dynamically
      Maybe this is program method 'bos { bot newBuilder(); }'
      Maybe this is program method 'bov { bow newBuilder(); }'
      Maybe this is program method 'boy { boz newBuilder(); }'
      Maybe this is program method 'bpb { bpc newBuilder(); }'
      Maybe this is program method 'bpe { bpf newBuilder(); }'
      Maybe this is program method 'bph { bpi newBuilder(); }'
      Maybe this is program method 'bpk { bpl newBuilder(); }'
      Maybe this is program method 'ccc { ccd newBuilder(); }'
      Maybe this is program method 'ccg { cch newBuilder(); }'
      Maybe this is program method 'ccj { cck newBuilder(); }'
      Maybe this is program method 'com.google.protobuf.DescriptorProtos$DescriptorProto { com.google.protobuf.DescriptorProtos$DescriptorProto$Builder newBuilder(); }'
      Maybe this is program method 'com.google.protobuf.DescriptorProtos$DescriptorProto$ExtensionRange { com.google.protobuf.DescriptorProtos$DescriptorProto$ExtensionRange$Builder newBuilder(); }'
      Maybe this is program method 'com.google.protobuf.TextFormat$Parser { com.google.protobuf.TextFormat$Parser$Builder newBuilder(); }'
      Maybe this is program method 'com.google.protobuf.UnknownFieldSet { com.google.protobuf.UnknownFieldSet$Builder newBuilder(); }'
      Maybe this is program method 'com.google.protobuf.UnknownFieldSet$Field { com.google.protobuf.UnknownFieldSet$Field$Builder newBuilder(); }'
Note: ctb accesses a method 'isGooglePlayServicesAvailable(android.content.Context)' dynamically
      Maybe this is program method 'com.google.android.gms.common.GooglePlayServicesUtil { int isGooglePlayServicesAvailable(android.content.Context); }'
Note: ctb accesses a method 'getId()' dynamically
      Maybe this is program method 'android.support.v4.app.BackStackRecord { int getId(); }'
      Maybe this is program method 'android.support.v4.app.Fragment { int getId(); }'
      Maybe this is program method 'android.support.v4.app.FragmentManager$BackStackEntry { int getId(); }'
      Maybe this is program method 'android.support.v7.view.menu.BaseMenuPresenter { int getId(); }'
      Maybe this is program method 'android.support.v7.view.menu.ListMenuPresenter { int getId(); }'
      Maybe this is program method 'android.support.v7.view.menu.MenuPopupHelper { int getId(); }'
      Maybe this is program method 'android.support.v7.view.menu.MenuPresenter { int getId(); }'
      Maybe this is program method 'android.support.v7.widget.Toolbar$ExpandedActionViewMenuPresenter { int getId(); }'
      Maybe this is program method 'boy { bxv getId(); }'
      Maybe this is program method 'btf { bxv getId(); }'
      Maybe this is program method 'btg { bxv getId(); }'
      Maybe this is program method 'butterknife.internal.FieldResourceBinding { int getId(); }'
      Maybe this is program method 'butterknife.internal.ViewBindings { int getId(); }'
      Maybe this is program method 'bxb { bxv getId(); }'
      Maybe this is program method 'ccb { bxv getId(); }'
      Maybe this is program method 'ccf { bxv getId(); }'
      Maybe this is program method 'com.activeandroid.Model { java.lang.Long getId(); }'
      Maybe this is program method 'com.facebook.GraphRequestBatch { java.lang.String getId(); }'
      Maybe this is program method 'com.facebook.Profile { java.lang.String getId(); }'
      Maybe this is program method 'com.facebook.share.widget.CreateAppGroupDialog$Result { java.lang.String getId(); }'
      Maybe this is program method 'com.google.android.gms.ads.identifier.AdvertisingIdClient$Info { java.lang.String getId(); }'
      Maybe this is program method 'm { int getId(); }'
Note: ctb accesses a method 'isLimitAdTrackingEnabled()' dynamically
      Maybe this is program method 'com.google.android.gms.ads.identifier.AdvertisingIdClient$Info { boolean isLimitAdTrackingEnabled(); }'
Note: ctb accesses a method 'getAdvertisingIdInfo(android.content.Context)' dynamically
      Maybe this is program method 'com.google.android.gms.ads.identifier.AdvertisingIdClient { com.google.android.gms.ads.identifier.AdvertisingIdClient$Info getAdvertisingIdInfo(android.content.Context); }'
Note: da accesses a method 'apply()' dynamically
Note: dfy accesses a declared field 'os' dynamically
Note: dfy accesses a method 'symlink(java.lang.String,java.lang.String)' dynamically
Note: gv accesses a method 'addLikelySubtags(java.util.Locale)' dynamically
Note: gw accesses a method 'getScript(java.lang.String)' dynamically
Note: gw accesses a method 'addLikelySubtags(java.lang.String)' dynamically
Note: retrofit.RestMethodInfo accesses a method 'value()' dynamically
      Maybe this is program method 'butterknife.Bind { int[] value(); }'
      Maybe this is program method 'butterknife.BindBool { int value(); }'
      Maybe this is program method 'butterknife.BindColor { int value(); }'
      Maybe this is program method 'com.fasterxml.jackson.annotation.JsonFilter { java.lang.String value(); }'
      Maybe this is program method 'com.fasterxml.jackson.annotation.JsonGetter { java.lang.String value(); }'
      Maybe this is program method 'com.fasterxml.jackson.annotation.JsonIgnore { boolean value(); }'
      Maybe this is program method 'com.fasterxml.jackson.annotation.JsonIgnoreProperties { java.lang.String[] value(); }'
      Maybe this is program method 'com.fasterxml.jackson.annotation.JsonIgnoreType { boolean value(); }'
      Maybe this is program method 'com.fasterxml.jackson.annotation.JsonInclude { com.fasterxml.jackson.annotation.JsonInclude$Include value(); }'
      Maybe this is program method 'com.fasterxml.jackson.annotation.JsonManagedReference { java.lang.String value(); }'
      Maybe this is program method 'com.fasterxml.jackson.annotation.JsonProperty { java.lang.String value(); }'
      Maybe this is program method 'com.fasterxml.jackson.annotation.JsonPropertyDescription { java.lang.String value(); }'
      Maybe this is program method 'com.fasterxml.jackson.annotation.JsonPropertyOrder { java.lang.String[] value(); }'
      Maybe this is program method 'com.fasterxml.jackson.databind.annotation.JsonValueInstantiator { java.lang.Class value(); }'
      Maybe this is program method 'com.fasterxml.jackson.databind.util.LinkedNode { java.lang.Object value(); }'
      Maybe this is program method 'retrofit.http.DELETE { java.lang.String value(); }'
      Maybe this is program method 'retrofit.http.EncodedPath { java.lang.String value(); }'
      Maybe this is program method 'retrofit.http.EncodedQuery { java.lang.String value(); }'
      Maybe this is program method 'retrofit.http.Field { java.lang.String value(); }'
      Maybe this is program method 'retrofit.http.GET { java.lang.String value(); }'
      Maybe this is program method 'retrofit.http.HEAD { java.lang.String value(); }'
      Maybe this is program method 'retrofit.http.Header { java.lang.String value(); }'
      Maybe this is program method 'retrofit.http.Headers { java.lang.String[] value(); }'
      Maybe this is program method 'retrofit.http.PATCH { java.lang.String value(); }'
      Maybe this is program method 'retrofit.http.POST { java.lang.String value(); }'
      Maybe this is program method 'retrofit.http.PUT { java.lang.String value(); }'
      Maybe this is program method 'retrofit.http.Part { java.lang.String value(); }'
      Maybe this is program method 'retrofit.http.Path { java.lang.String value(); }'
      Maybe this is program method 'retrofit.http.Query { java.lang.String value(); }'
      Maybe this is program method 'retrofit.http.RestMethod { java.lang.String value(); }'
Note: there were 25 classes trying to access annotations using reflection.
      You should consider keeping the annotation attributes
      (using '-keepattributes *Annotation*').
      (http://proguard.sourceforge.net/manual/troubleshooting.html#attributes)
Note: there were 35 classes trying to access generic signatures using reflection.
      You should consider keeping the signature attributes
      (using '-keepattributes Signature').
      (http://proguard.sourceforge.net/manual/troubleshooting.html#attributes)
Note: there were 6 classes trying to access enclosing classes using reflection.
      You should consider keeping the inner classes attributes
      (using '-keepattributes InnerClasses').
      (http://proguard.sourceforge.net/manual/troubleshooting.html#attributes)
Note: there were 1 classes trying to access enclosing methods using reflection.
      You should consider keeping the enclosing method attributes
      (using '-keepattributes InnerClasses,EnclosingMethod').
      (http://proguard.sourceforge.net/manual/troubleshooting.html#attributes)
Note: there were 24 unresolved dynamic references to classes or interfaces.
      You should check if you need to specify additional program jars.
      (http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass)
Note: there were 42 accesses to class members by means of introspection.
      You should consider explicitly keeping the mentioned class members
      (using '-keep' or '-keepclassmembers').
      (http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclassmember)
Note: you're ignoring all warnings!

Here is my proguard-rules.pro file:

#========================================
# General rules
#========================================
# General
-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
-optimizationpasses 5
-allowaccessmodification
-dontpreverify
-repackageclasses ''

-keepattributes *Annotation*,EnclosingMethod,Signature

-keepclassmembers,allowoptimization enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

#========================================
# ButterKnife
#========================================
-keep class butterknife.** { *; }
-dontwarn butterknife.internal.**
-keep class **$$ViewBinder { *; }

-keepclasseswithmembernames class * {
    @butterknife.* <fields>;
}

-keepclasseswithmembernames class * {
    @butterknife.* <methods>;
}

#========================================
# EventBus
#========================================
-keepclassmembers class ** {
    public void onEvent*(**);
}

#========================================
# Android support libraries
#========================================
-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-dontwarn android.support.v7.**
-keep class android.support.v7.** { *; }
-keep interface android.support.v7.** { *; }

-keep class android.support.v8.renderscript.** {
    native <methods>;
}

#=======================================
# ActiveAndroid
#=======================================
-keep class com.activeandroid.** { *; }
-keep class com.activeandroid.**.** { *; }
-keep,allowobfuscation,allowshrinking,allowoptimization class * extends com.activeandroid.Model
-keep class * extends com.activeandroid.serializer.TypeSerializer

#=======================================
# Facebook SDK
#=======================================
-keep class com.facebook.** {
   *;
}

#=======================================
# Retrofit
#=======================================
-keep class com.squareup.okhttp.** { *; }
-keep interface com.squareup.okhttp.** { *; }
-dontwarn com.squareup.okhttp.**

-dontwarn rx.**
-dontwarn retrofit.**
-dontwarn okio.**
-keep class retrofit.** { *; }
-keepclassmembers class * {
    @retrofit.http.* <methods>;
}

#=======================================
# Jackson JSON Serializer/Deserializer
#=======================================
-dontskipnonpubliclibraryclassmembers

-keepnames class com.fasterxml.jackson.** { *; }
-keepnames class org.codehaus.jackson.** { *; }
#-keep class com.fasterxml.jackson.** { *; }
#-keep interface com.fasterxml.jackson.** { *; }
#-keep @interface com.fasterxml.jackson.** { *; }

-keepclassmembers public final enum org.codehaus.jackson.annotate.JsonAutoDetect$Visibility {
    public static final org.codehaus.jackson.annotate.JsonAutoDetect$Visibility *;
}

-keepclasseswithmembers class * {
    @com.fasterxml.jackson.* <fields>;
}

-dontwarn javax.xml.**
-dontwarn javax.xml.stream.events.**
-dontwarn com.fasterxml.jackson.databind.**

#=====================================
# Glide
#=====================================
-keep public class * implements com.bumptech.glide.module.GlideModule

#=====================================
# Google Play Services library
#=====================================
-keep class * extends java.util.ListResourceBundle {
    protected Object[][] getContents();
}

-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
    public static final *** NULL;
}

-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
   @com.google.android.gms.common.annotation.KeepName *;
}
-keepnames class * implements android.os.Parcelable {
   public static final ** CREATOR;
}
+4
source share

Source: https://habr.com/ru/post/1616512/


All Articles