2
  1. 这是我的 Proguard 文件:
 -dontoptimize
 -dontusemixedcaseclassnames
 -dontskipnonpubliclibraryclasses
 -dontskipnonpubliclibraryclassmembers
 -dontpreverify
 -verbose
 -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
 -dump class_files.txt
 -printseeds seeds.txt
 -printusage unused.txt
 -printmapping mapping.txt
 -renamesourcefileattribute SourceFile
 -keepattributes SourceFile,LineNumberTable
 -keepattributes *Annotation*,EnclosingMethod
 -keepattributes Signature
 -ignorewarnings


 -keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault
 -keepclassmembers class * {
   @com.google.api.client.util.Key <fields>;
 }
 -dontwarn sun.misc.Unsafe
 -dontwarn com.google.common.collect.MinMaxPriorityQueue
 -dontwarn com.google.api.client.extensions.android.**
 -dontwarn com.google.api.client.googleapis.extensions.android.**

 -keep @interface com.google.gson.annotations.SerializedName
 -keepattributes *Annotation*

 -keep class com.google.inject.** { *; }
 -keep class javax.inject.** { *; }
 -keep class javax.annotation.** { *; }

 -keep public class Pokoto.** {
   public void set*(***);
   public *** get*();
 }

 -keep class com.firebase.** { *; }
 -dontwarn com.fasterxml.**


 # ---- PRESAGE - start

 -dontnote io.presage.**
 -dontwarn shared_presage.**
 -dontwarn org.codehaus.**

 -keepattributes Signature

 -keep class shared_presage.** { *; }
 -keep class io.presage.** { *; }
 -keepclassmembers class io.presage.** {
  *;
 }

 -keepattributes *Annotation*
 -keepattributes JavascriptInterface
 -keepclassmembers class * {
     @android.webkit.JavascriptInterface <methods>;
 }

 # ---- OKHTTP
 -dontnote okhttp3.**
 -dontnote okio.**
 -dontwarn okhttp3.**
 -dontwarn okio.**

 -dontnote sun.misc.Unsafe
 -dontnote android.net.http.*

 -dontnote org.apache.commons.codec.**
 -dontnote org.apache.http.**

 -dontwarn org.apache.commons.collections.BeanMap
 -dontwarn java.beans.**

 # ---- GOOGLE
 -dontnote com.google.gson.**
 -dontnote com.google.android.gms.ads.**
 -dontnote com.google.android.**
 -dontnote com.google.ads.**

 -keepclassmembers class * implements java.io.Serializable {
     static final long serialVersionUID;
     private static final java.io.ObjectStreamField[] serialPersistentFields;
     private void writeObject(java.io.ObjectOutputStream);
     private void readObject(java.io.ObjectInputStream);
     java.lang.Object writeReplace();
     java.lang.Object readResolve();
 }

 # ---- PRESAGE - end

 # ---- amazon

 -dontwarn com.amazon.**

 -keep class com.amazon.** {*;}

 -keepattributes *Annotation*

 -keep public class com.google.android.youtube.player.** { *; }

 #sqlcipher
 -keep class net.sqlcipher.** { *; }
 -keep class net.sqlcipher.database.* { *; }

 ##---------------Begin:  configuration for Fabric  ----------
 -keep class com.crashlytics.** { *; }
 -dontwarn com.crashlytics.**

 ##---------------End: configuration for Fabric  ----------


 ##---------------Begin: mopub configuration  ----------
 -keepclassmembers class com.mopub.** { public *; }
 -keep public class com.mopub.**
 -keep public class android.webkit.JavascriptInterface {}
 -keep class * extends com.mopub.mobileads.CustomEventBanner {}
 -keepclassmembers class com.mopub.mobileads.CustomEventBannerAdapter {!private !public !protected *;}
 -keep class * extends com.mopub.mobileads.CustomEventInterstitial {}
 -keep class * extends com.mopub.mobileads.CustomEventNative {}
 -keep class com.google.android.gms.common.GooglePlayServicesUtil {*;}
 -keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {*;}
 -keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info {*;}
 ##---------------End: mopub configuration   ----------

 ##---------------Begin: proguard configuration for GLIDER  ----------
 -keep public class * implements com.bumptech.glide.module.GlideModule
 -keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
   **[] $VALUES;
   public *;
 }
 ##---------------End: proguard configuration for GLIDE  ----------

 ##---------------Begin: proguard configuration for okHTTP  ----------
 -keepattributes Signature
 -keepattributes Annotation
 -keep class okhttp3.** { *; }
 -keep interface okhttp3.** { *; }
 -dontwarn okhttp3.
 -dontwarn okio.**
 ##---------------End: proguard configuration for okHTTP  ----------


 ##---------------Begin: proguard configuration for Gson  ----------
 # Gson uses generic type information stored in a class file when working with fields. Proguard
 # removes such information by default, so configure it to keep all of it.
 -keepattributes Signature

 # For using GSON @Expose annotation
 -keepattributes *Annotation*

 # Gson specific classes
 -keep class sun.misc.Unsafe { *; }
 -keep class com.google.gson.stream.** { *; }

 # Application classes that will be serialized/deserialized over Gson
 -keep class com.google.gson.examples.android.model.** { *; }

 # Prevent proguard from stripping interface information from TypeAdapterFactory,
 # JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
 -keep class * implements com.google.gson.TypeAdapterFactory
 -keep class * implements com.google.gson.JsonSerializer
 -keep class * implements com.google.gson.JsonDeserializer
 # Add the gson class
 -keep public class com.google.gson

 ##---------------End: proguard configuration for Gson  ----------


 ## guava
 -keep class com.google.common.io.Resources {
     public static <methods>;
 }
 -keep class com.google.common.collect.Lists {
     public static ** reverse(**);
 }
 -keep class com.google.common.base.Charsets {
     public static <fields>;
 }

 -keep class com.google.common.base.Joiner {
     public static Joiner on(String);
     public ** join(...);
 }

 -keep class com.google.common.collect.MapMakerInternalMap$ReferenceEntry
 -keep class com.google.common.cache.LocalCache$ReferenceEntry

 -dontwarn sun.misc.Unsafe
 -dontwarn javax.annotation.**

 -keep class com.google.j2objc.annotations.** { *; }
 -dontwarn   com.google.j2objc.annotations.**
 -keep class java.lang.ClassValue { *; }
 -dontwarn   java.lang.ClassValue
 -keep class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement { *; }
 -dontwarn   org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement

 # Guava 20.0
 -dontwarn com.google.errorprone.annotations.CanIgnoreReturnValue
 -dontwarn com.google.errorprone.annotations.concurrent.LazyInit
 -dontwarn com.google.errorprone.annotations.ForOverride

 ## end guava

 -keep class * extends java.util.ListResourceBundle {
     protected Object[][] getContents();
 }

 # Keep SafeParcelable value, needed for reflection. This is required to support backwards
 # compatibility of some classes.
 -keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
     public static final *** NULL;
 }

 # Keep the names of classes/members we need for client functionality.
 -keepnames @com.google.android.gms.common.annotation.KeepName class *
 -keepclassmembernames class * {
     @com.google.android.gms.common.annotation.KeepName *;
 }

 # Needed for Parcelable/SafeParcelable Creators to not get stripped
 -keepnames class * implements android.os.Parcelable {
     public static final ** CREATOR;
 }

 -dontwarn javax.annotation.**
 -dontwarn javax.inject.**
 -dontwarn sun.misc.Unsafe
 -keep class com.google.android.gms.** { *; }
 -dontwarn com.google.android.gms.**
 -keep class android.webkit.WebSettings
 -dontwarn android.webkit.WebSettings
 -keep class android.content.pm.PackageInstaller
 -keep class android.content.pm.PackageInstaller$SessionInfo
 -keep class android.content.pm.PackageManager
 -dontwarn android.content.pm.PackageInstaller
 -dontwarn android.content.pm.PackageInstaller$SessionInfo
 -dontwarn android.content.pm.PackageManager

 # AppCompat
 -keep class android.support.v7.app.** { *; }
 -keep class android.support.v4.app.** { *; }
 -keep interface android.support.v4.app.** { *; }

 -keep class com.facebook.** {
    *;
 }

 -keep public class * extends android.app.Activity
 -keep public class * extends android.app.Application
 -keep public class * extends android.app.Service
 -keep public class * extends android.content.BroadcastReceiver
 -keep public class * extends android.content.ContentProvider
 -keep public class * extends android.app.backup.BackupAgentHelper
 -keep public class * extends android.preference.Preference

 -keep public class * extends android.view.View
 -keep public class * extends android.support.v4.**
 -keep public class * extends android.app.Fragment

 -keep public class custom.components.**

 #Maintain java native methods
 -keepclasseswithmembernames class * {
     native <methods>;
 }

 -assumenosideeffects class android.util.Log {
     public static *** d(...);
     public static *** v(...);
 }

 -keep public class * extends android.view.View {
 public <init>(android.content.Context);
 public <init>(android.content.Context, android.util.AttributeSet);
 public <init>(android.content.Context, android.util.AttributeSet, int);
 public void set*(...);
 }

 -keepclasseswithmembers class * {
     public <init>(android.content.Context, android.util.AttributeSet);
 }

 -keepclasseswithmembers class * {
     public <init>(android.content.Context, android.util.AttributeSet, int);
 }

 -keep class * implements android.os.Parcelable {
   public static final android.os.Parcelable$Creator *;
 }

 # Also keep - Enumerations. Keep the special static
 # methods that are required in enumeration classes.
 -keepclassmembers enum  * {
     public static **[] values();
     public static ** valueOf(java.lang.String);
 }

 #To keep parcelable classes (to serialize - deserialize objects to sent through Intents)
 -keep class * implements android.os.Parcelable {
   public static final android.os.Parcelable$Creator *;
 }

 #Keep the R
 -keepclassmembers class **.R$* {
     public static <fields>;
 }

 -keep public class * {
     public protected *;
 }
  1. 这是我得到的错误:

    警告:处理任务 java.io.IOException 时出现异常:无法写入 [C:\Users\Anish\pokoto\app\build\intermediates\transforms\proguard\release\jars\3\1f\main.jar](可以't read [C:\Users\Anish.android\build-cache\9a4d2c08e132f2da417ab6ffc3ca37865ea16fd6\output\jars\classes.jar(;;;;;;**.class)] (重复的 zip 条目 [classes.jar:com/ google/common/base/FinalizableReference.class])) 错误:任务“:app:transformClassesAndResourcesWithProguardForRelease”执行失败。

    作业失败,查看日志了解详情

    1. 我每次尝试编译 compile 'com.google.api-client:google-api-client:1.22.0' 它都会给我错误
4

1 回答 1

0

我有类似的错误。2017 年 6 月 15 日更新 将 Google 存储库更新到版本 54,并使用最新版本 (11.0.1) 的 play-service 而不是 11.0.0

compile 'com.google.android.gms:play-services-identity:11.0.1'
compile 'com.google.android.gms:play-services-gcm:11.0.1'
compile 'com.google.android.gms:play-services-location:11.0.1'
compile 'com.google.android.gms:play-services-analytics:11.0.1'

然后将生成签名的APK,没有任何问题。

笔记。无需注释掉,因为它需要由 firebase

apply plugin: 'com.google.gms.google-services'
于 2017-06-13T10:31:42.003 回答