2017-10-10 31 views
-1

我做了我整天的研究。由於發佈SHA1,大多數人都面臨着問題,但我已經檢查過使用所有方法(命令行和Android工作室)。我得到相同的釋放散列鍵,它是工作,如果我在發佈版本中使minifyEnabled false。用於Android的谷歌登錄是不工作在釋放apk後minifyEnabled真

如果我使minifyEnabled true以混淆文件谷歌登錄不起作用。

這裏是我的proguard的文件

-optimizationpasses 5 
-dontusemixedcaseclassnames 
-dontskipnonpubliclibraryclasses 
-dontpreverify 
-verbose 
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* 

# -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 com.android.vending.licensing.ILicensingService 

-keepclasseswithmembernames class * { 
    native <methods>; 
} 

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

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

-keepclassmembers class * extends android.app.Activity { 
    public void *(android.view.View); 
} 

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

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

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

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

-dontwarn com.google.android.gms.** 
-keepattributes SourceFile,LineNumberTable 

-adaptresourcefilenames 

-adaptresourcefilecontents 

-keepdirectories 

#-keepclassmembers class * { 
# public void *(android.view.View); 
#} 

# If your project uses WebView with JS, uncomment the following 
# and specify the fully qualified class name to the JavaScript interface 
# class: 
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { 
# public *; 
#} 
-keep public class com.google.android.gms.ads.** { 
    public *; 
} 

-keep public class com.google.ads.** { 
    public *; 
} 

-dontwarn java.lang.invoke.* 
-dontwarn **$$Lambda$* 

# Platform calls Class.forName on types which do not exist on Android to determine platform. 
-dontnote retrofit2.Platform 
# Platform used when running on Java 8 VMs. Will not be used at runtime. 
-dontwarn retrofit2.Platform$Java8 
# Retain generic type information for use by reflection by converters and adapters. 
-keepattributes Signature 
# Retain declared checked exceptions for use by a Proxy instance. 
-keepattributes Exceptions 

-dontwarn org.xmlpull.v1.** 
-dontwarn okhttp3.** 
-keep class okhttp3.** { *; } 
-dontwarn okio.** 
-dontwarn javax.annotation.Nullable 
-dontwarn javax.annotation.ParametersAreNonnullByDefault 
-dontwarn javax.annotation.** 

-keepclassmembers class * { 
    @com.google.api.client.util.Key <fields>; 
} 

-keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault 
-keep class com.google.** {*;} 

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

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

任何幫助非常感謝,花了整整一天在這個問題上!

+0

定義「不工作」。崩潰?如果是這樣,後崩潰日誌 – Kuffs

+0

它不崩潰,我無法登錄谷歌。 – Krishan

+0

爲什麼-1,我嘗試了人們在其他問題中提出的所有方式,我的問題是不同的。如果你知道答案請提供鏈接。 – Krishan

回答

0

經過2天的努力,我解決了它。問題在於改造和模型類。

我們不應該允許重命名模型類,以便保持

-dontwarn okio.** 
-dontwarn java.lang.invoke.* 
-dontwarn retrofit2.Platform$Java8 
-keep class retrofit.** { *; } 
-keep class retrofit2.** { *; } 
-keepattributes Signature 
-keepattributes Exceptions 
-keepclasseswithmembers class * { 
    @retrofit.http.* <methods>; 
} 
-keepclasseswithmembers interface * { 
    @retrofit.http.* <methods>; 
} 
-keepclasseswithmembers interface * { 
    @retrofit2.* <methods>; 
} 

-keep class com.google.gson.** { *; } 
-keep class com.google.inject.** { *; } 
-keep class javax.inject.** { *; } 
-keep class com.yourproject.YourClass** 
-keepclassmembers class com.yourproject.YourClass** { 
    *; 
} 
相關問題