无法生成签名的APk

时间:2017-06-12 10:57:13

标签: android-studio google-api-client signed-apk

  1. 这是我的Proguard文件:

    -dontoptimize -dontusemixedcaseclassnames -dontskipnonpubliclibraryclasses -dontskipnonpubliclibraryclassmembers -dontpreverify -verbose -optimizations!code / simplifiedification / arithmetic,!field / ,! class / merge / -dump class_files.txt -printseeds seeds.txt -printusage unused.txt -printmapping mapping.txt -renamesourcefile属性SourceFile -keepattributes SourceFile,LineNumberTable -keepattributes Annotation ,EnclosingMethod -keepattributes签名 -ignorewarnings

    -keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault -keepclassmembers class * {   @ com.google.api.client.util.Key; } -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 *( *);   公共 获取(); }

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

    ---- PRESAGE - 开始

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

    -keepattributes签名

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

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

    ---- 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 - 结束

    ----亚马逊

    -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。 {*; }

    ---------------开始:Fabric ----------

    的配置

    -keep class com.crashlytics。** {*; } -dontwarn com.crashlytics。**

    ---------------结束:Fabric ----------

    的配置

    ---------------开始:mopub配置----------

    -keepclassmembers class com.mopub。** {public *; } -keep public class com.mopub。** -keep public class android.webkit.JavascriptInterface {} -keep class * extends com.mopub.mobileads.CustomEventBanner {} -keepclassmembers类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 {*;}

    ---------------结束:mopub配置----------

    ---------------开始:GLIDER的proguard配置----------

    -keep public class *实现了com.bumptech.glide.module.GlideModule -keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser $ ** {   ** [] $ VALUES;   上市 *; }

    ---------------结束:GLIDE ----------

    的proguard配置

    ---------------开始:okHTTP的proguard配置----------

    -keepattributes签名 -keepattributes Annotation -keep class okhttp3。** {*; } -keep interface okhttp3。** {*; } -dontwarn okhttp3。 -dontwarn okio。**

    ---------------结束:okHTTP的proguard配置----------

    ---------------开始:Gson ----------

    的proguard配置

    Gson在处理字段时使用存储在类文件中的泛型类型信息。 Proguard的

    默认情况下会删除此类信息,因此请将其配置为保留所有信息。

    -keepattributes签名

    使用GSON @Expose注释

    -keepattributes Annotation

    Gson特定类

    -keep class sun.misc.Unsafe {*; } -keep class com.google.gson.stream。** {*; }

    将通过Gson

    序列化/反序列化的应用程序类

    -keep class com.google.gson.examples.android.model。** {*; }

    防止proguard从TypeAdapterFactory

    中删除接口信息

    JsonSerializer,JsonDeserializer实例(因此可以在@JsonAdapter中使用)

    -keep class *实现了com.google.gson.TypeAdapterFactory -keep class *实现了com.google.gson.JsonSerializer -keep class *实现com.google.gson.JsonDeserializer

    添加gson类

    -keep public class com.google.gson

    ---------------结束:Gson ----------

    的proguard配置

    番石榴

    -keep class com.google.common.io.Resources {     公共静态; } -keep class com.google.common.collect.Lists {     public static ** reverse(**); } -keep class com.google.common.base.Charsets {     公共静态; }

    -keep class com.google.common.base.Joiner {     public static Joiner on(String);     公共**加入(...); }

    -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

    番石榴20.0

    -dontwarn com.google.errorprone.annotations.CanIgnoreReturnValue -dontwarn com.google.errorprone.annotations.concurrent.LazyInit -dontwarn com.google.errorprone.annotations.ForOverride

    结束番石榴

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

    保持反射所需的SafeParcelable值。这需要向后支持

    某些类的兼容性。

    -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 *; }

    Parcelable / SafeParcelable Creators不需要剥离

    -keepnames class *实现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

    程序兼容性

    -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 *扩展android.app.Application -keep public class *扩展android.app.Service -keep public class *扩展了android.content.BroadcastReceiver -keep public class *扩展了android.content.ContentProvider -keep public class * extends android.app.backup.BackupAgentHelper -keep public class * extends android.preference.Preference

    -keep public class *扩展了android.view.View -keep public class * extends android.support.v4。** -keep public class * extends android.app.Fragment

    -keep public class custom.components。**

    维护java本机方法

    -keepclasseswithmembernames class * {     原生的 }

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

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

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

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

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

    还保留 - 枚举。保持特殊静态

    枚举类中需要的

    方法。

    -keepclassmembers枚举* {     public static ** [] values();     public static ** valueOf(java.lang.String); }

    保持parcelable类(序列化 - 反序列化通过Intents发送的对象)

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

    保持R

    -keepclassmembers class **。R $ * {     公共静态; }

    -keep public class * {     公共保护*; }

  2. 这是我得到的错误: 警告:处理任务java.io.IOException时出现异常:无法写入[C:\ Users \ Anish \ pokoto \ app \ build \ intermediates \ transforms \ proguard \ release \ jars \ 3 \ 1f \ main.jar] (无法读取[C:\ Users \ Anish.android \ build-cache \ 9a4d2c08e132f2da417ab6ffc3ca37865ea16fd6 \ output \ jars \ classes.jar(;;;;;; ** .class)](重复的zip条目[类别。罐子:COM /谷歌/普通/碱/ FinalizableReference.class])) 错误:任务执行失败':app:transformClassesAndResourcesWithProguardForRelease'。

      

    作业失败,请参阅日志了解详情

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

1 个答案:

答案 0 :(得分:0)

我有类似的错误。 2017年6月15日更新 将Google Repository更新为版本54并使用播放服务的最新版本(11.0.1)而不是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'