3

这是我的 proguard 文件:

-keepattributes *Annotation*
-keepattributes SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception
-printmapping mapping.txt


-keepattributes Signature, InnerClasses, EnclosingMethod


-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations


-keepclassmembers,allowshrinking,allowobfuscation interface * {
    @retrofit2.http.* <methods>;
}


-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement

-dontwarn javax.annotation.**

-dontwarn kotlin.Unit

-dontwarn retrofit2.KotlinExtensions

-if interface * { @retrofit2.http.* <methods>; }
-keep,allowobfuscation interface <1>

-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase

-dontwarn org.codehaus.mojo.animal_sniffer.*

-dontwarn okhttp3.internal.platform.ConscryptPlatform

-keepattributes Signature

-keepattributes Annotation

-dontwarn sun.misc.**

-keep class com.google.gson.examples.android.model.** { <fields>; }

-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer

-keepclassmembers,allowobfuscation class * {
  @com.google.gson.annotations.SerializedName <fields>;

这是我在运行发布应用程序后得到的日志:

 <-- 200 https://api.gobaskt.com/dev-basket/gobaskt/basket (24002ms)
2020-02-20 12:39:57.729 10758-12256/com.gobaskt D/OkHttp: content-type: application/json
2020-02-20 12:39:57.729 10758-12256/com.gobaskt D/OkHttp: content-length: 6769
2020-02-20 12:39:57.730 10758-12256/com.gobaskt D/OkHttp: date: Thu, 20 Feb 2020 07:09:57 GMT
2020-02-20 12:39:57.730 10758-12256/com.gobaskt D/OkHttp: x-amzn-requestid: 2f52af84-0138-45ab-b403-75e2583e4f90
2020-02-20 12:39:57.730 10758-12256/com.gobaskt D/OkHttp: x-amz-apigw-id: ILyLSGD3CYcFlMg=
2020-02-20 12:39:57.730 10758-12256/com.gobaskt D/OkHttp: x-amzn-trace-id: Root=1-5e4e30ae-7893b2e8430ff7b0f0793ae8;Sampled=0
2020-02-20 12:39:57.730 10758-12256/com.gobaskt D/OkHttp: x-cache: Miss from cloudfront
2020-02-20 12:39:57.730 10758-12256/com.gobaskt D/OkHttp: via: 1.1 66f5b63f0d6bfa07c6e6afd2b0f672b2.cloudfront.net (CloudFront)
2020-02-20 12:39:57.730 10758-12256/com.gobaskt D/OkHttp: x-amz-cf-pop: BLR50-C1
2020-02-20 12:39:57.730 10758-12256/com.gobaskt D/OkHttp: x-amz-cf-id: 7o44Q_yEkwYDRH0m-aqsmi6V3hPi1R7R8KOQ0mSd5PnpTkDw5j-BvA==
2020-02-20 12:39:57.730 10758-12256/com.gobaskt D/OkHttp: {"success":true,"message":"found","statusCode":200,"responseData":[{"id":"b3d06745-f030-40af-9704-3d7d51fe0458","basket_userId":null,"offers":{"offerId":"a0936455-f99a-4693-918e-c49356512d21","productName":null,"offerStatus":"saved","save_timeStamp":"2020-02-10 16:42:04.634","redeem_timeStamp":null,"lmname":"PK's bar & grill","lmlocation":null,"applicableProducts":null,"eancode":null,"lmdescription":"Bar & Grill Restaurant","lmid":"LM0003","lmofferSubType":null,"lmofferTitle":null,"lmofferType":"% off","lmofferValue":"20","offerCurrency":"USD","offerExpiryDate":"12/31/2019","offerExpiryTime":"9 pm EST","offerRegion":"Montgomerry VA","offerStartDate":"12/1/2019","offerStartTime":"11 am EST","offerTermsandConditions":"Excludes non dip items","webOfferImage1":"https://d1141hp6d00bvx.cloudfront.net/webImages/Jursey_mikes_image.png","webOfferImage2":"string","mobileOfferImage1":"https://d1141hp6d00bvx.cloudfront.net/2.png","mobileOfferImage2":"https://d1141hp6d00bvx.cloudfront.net/logo_petco_copy.png","upccode":null}},{"id":"9c4eb971-03d3-491d-ab89-cf18c44f6bb3","basket_userId":null,"offers":{"offerId":"bd15effb-36ad-4449-9278-3c37942f7828","productName":null,"offerStatus":"saved","save_timeStamp":"2020-02-05 09:12:24.381","redeem_timeStamp":null,"lmname":"Amelia's Pizzeria & Restaurant","lmlocation":null,"applicableProducts":null,"eancode":null,"lmdescription":"Pizza Restautant","lmid":"LM0002","lmofferSubType":null,"lmofferTitle":null,"lmofferType":"$ off","lmofferValue":"10","offerCurrency":"USD","offerExpiryDate":"12/31/2019","offerExpiryTime":"9 pm EST","offerRegion":"Montgomerry VA","offerStartDate":"12/1/2019","offerStartTime":"11 am EST","offerTermsandConditions":"Excludes non pizza items","webOfferImage1":"https://d1141hp6d00bvx.cloudfront.net/webImages/PKs_bar_grill+(1).png","webOfferImage2":"string","mobileOfferImage1":"https://d1141hp6d00bvx.cloudfront.net/5.png","mobileOfferImage2":"https://d1141hp6d00bvx.cloudfront.net/pk_s_logo_01.png","upccode":null}},{"id":"8ebe77cf-bb2d-468d-bb2f-10d76921c06a","basket_userId":null,"offers":{"offerId":"878b1c26-e721-4b51-8dcf-6887493629c5","productName":null,"offerStatus":"saved","save_timeStamp":"2020-02-10 05:51:40.891","redeem_timeStamp":null,"lmname":"Amelia's Pizzeria & Restaurant","lmlocation":null,"applicableProducts":null,"eancode":null,"lmdescription":"Pizza Restautant","lmid":"LM0002","lmofferSubType":null,"lmofferTitle":null,"lmofferType":"% off","lmofferValue":"20","offerCurrency":"USD","offerExpiryDate":"12/31/2019","offerExpiryTime":"9 pm EST","offerRegion":"Montgomerry VA","offerStartDate":"12/1/2019","offerStartTime":"11 am EST","offerTermsandConditions":"No valid on non pizza items","webOfferImage1":"https://d1141hp6d00bvx.cloudfront.net/webImages/PKs_bar_grill+(1).png","webOfferImage2":"string","mobileOfferImage1":"https://d1141hp6d00bvx.cloudfront.net/5.png","mobileOfferImage2":"https://d1141hp6d00bvx.cloudfront.net/pk_s_logo_01.png","upccode":null}},{"id":"f762e94a-1652-4d86-a79b-4206e837ad29","basket_userId":null,"offers":{"offerId":"4b2e20d1-7ceb-45d8-bbc7-773d21601370","productName":null,"offerStatus":"saved","save_timeStamp":"2020-02-05 08:24:22.048","redeem_timeStamp":null,"lmname":"Jersey Mike's","lmlocation":null,"applicableProducts":null,"eancode":null,"lmdescription":"Subs Restaurant","lmid":"LM0001","lmofferSubType":null,"lmofferTitle":null,"lmofferType":"% off","lmofferValue":"15","offerCurrency":"USD","offerExpiryDate":"12/31/2019","offerExpiryTime":"9 pm EST","offerRegion":"Montgomerry VA","offerStartDate":"12/1/2019","offerStartTime":"11 am EST","offerTermsandConditions":"Valid on hot subs only","webOfferImage1":"https://d1141hp6d00bvx.cloudfront.net/webImages/1602.png","webOfferImage2":"string","mobileOfferImage1":"https://d1141hp6d00bvx.cloudfront.net/4.png","mobileOfferImage2":"https://d1141hp6d00bvx.cloudfront.net/jersey_mikes_1_copy_4.png","upccode":null}},{"id":"c7300b66-a9e4-44cb-a6f8-4c1af104fb11","basket_userId":null,"offers":{"offerId":"8
2020-02-20 12:39:57.730 10758-12256/com.gobaskt D/OkHttp: f40d7ca-2db7-45bb-a26f-fdcde43abb65","productName":null,"offerStatus":"saved","save_timeStamp":"2020-02-17 04:33:05.802","redeem_timeStamp":null,"lmname":"PK's bar & grill","lmlocation":null,"applicableProducts":null,"eancode":null,"lmdescription":"Bar & Grill Restaurant","lmid":"LM0003","lmofferSubType":null,"lmofferTitle":null,"lmofferType":"% off","lmofferValue":"20","offerCurrency":"USD","offerExpiryDate":"12/31/2019","offerExpiryTime":"9 pm EST","offerRegion":"Montgomerry VA","offerStartDate":"12/1/2019","offerStartTime":"11 am EST","offerTermsandConditions":"Excludes non dip items","webOfferImage1":"https://d1141hp6d00bvx.cloudfront.net/webImages/Jursey_mikes_image.png","webOfferImage2":"string","mobileOfferImage1":"https://d1141hp6d00bvx.cloudfront.net/2.png","mobileOfferImage2":"https://d1141hp6d00bvx.cloudfront.net/logo_petco_copy.png","upccode":null}},{"id":"5f97c5a3-043a-4b42-bd21-9747ecbdb4af","basket_userId":null,"offers":{"offerId":"6c0dfbb8-b4bc-4db3-98e1-083ea4353bc5","productName":null,"offerStatus":"saved","save_timeStamp":"2020-02-18 05:38:57.512","redeem_timeStamp":null,"lmname":"Real life dental","lmlocation":null,"applicableProducts":null,"eancode":null,"lmdescription":"Dentist","lmid":"LM0005","lmofferSubType":null,"lmofferTitle":null,"lmofferType":"% off","lmofferValue":"15","offerCurrency":"USD","offerExpiryDate":"1/1/2020","offerExpiryTime":"10 pm EST","offerRegion":"Montgomerry VA","offerStartDate":"12/2/2019","offerStartTime":"12 am EST","offerTermsandConditions":"Applicable only once per customer","webOfferImage1":"https://d1141hp6d00bvx.cloudfront.net/webImages/354.png","webOfferImage2":"string","mobileOfferImage1":"https://d1141hp6d00bvx.cloudfront.net/1.png","mobileOfferImage2":"https://d1141hp6d00bvx.cloudfront.net/1200_px_rite_aid_svg.png","upccode":null}},{"id":"d4f332d4-b4d9-476d-9d92-b8bfb1a3ae2c","basket_userId":null,"offers":{"offerId":"60deb825-fda9-4087-a2c5-59e95782b6f1","productName":null,"offerStatus":"saved","save_timeStamp":"2020-02-11 02:39:22.185","redeem_timeStamp":null,"lmname":"Real life dental","lmlocation":null,"applicableProducts":null,"eancode":null,"lmdescription":"Dentist","lmid":"LM0005","lmofferSubType":null,"lmofferTitle":null,"lmofferType":"% off","lmofferValue":"15","offerCurrency":"USD","offerExpiryDate":"1/1/2020","offerExpiryTime":"10 pm EST","offerRegion":"Montgomerry VA","offerStartDate":"12/2/2019","offerStartTime":"12 am EST","offerTermsandConditions":"Applicable only once per customer","webOfferImage1":"https://d1141hp6d00bvx.cloudfront.net/webImages/354.png","webOfferImage2":"string","mobileOfferImage1":"https://d1141hp6d00bvx.cloudfront.net/1.png","mobileOfferImage2":"https://d1141hp6d00bvx.cloudfront.net/1200_px_rite_aid_svg.png","upccode":null}}]}
2020-02-20 12:39:57.730 10758-12256/com.gobaskt D/OkHttp: <-- END HTTP (6769-byte body)
2020-02-20 12:39:57.731 10758-12256/com.gobaskt W/com.gobaskt: Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
2020-02-20 12:39:57.731 10758-12256/com.gobaskt W/com.gobaskt: Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
2020-02-20 12:39:57.731 10758-12256/com.gobaskt D/FirebasePerformance: Retrieving Max Duration (in minutes) of single Session configuration value.
2020-02-20 12:39:57.731 10758-12264/com.gobaskt D/FirebasePerformance: Retrieving master flag for Firebase Performance SDK enabled configuration value.
2020-02-20 12:39:57.732 10758-12264/com.gobaskt D/FirebasePerformance: Fetched value: 'true' for key: 'fpr_enabled' from Firebase Remote Config.
2020-02-20 12:39:57.732 10758-12256/com.gobaskt W/FirebaseRemoteConfig: No value of type 'FirebaseRemoteConfigValue' exists for parameter key 'fpr_session_max_duration_min'.
2020-02-20 12:39:57.732 10758-12256/com.gobaskt D/FirebasePerformance: Config resolver result for flag: 'f.j.a.b.i.g.r' is: '240'.
2020-02-20 12:39:57.732 10758-12264/com.gobaskt D/FirebasePerformance: Config resolver result for flag: 'f.j.a.b.i.g.q' is: 'true'.
2020-02-20 12:39:57.732 10758-12264/com.gobaskt D/FirebasePerformance: Retrieving Firebase Performance SDK disabled versions configuration value.
2020-02-20 12:39:57.732 10758-12264/com.gobaskt D/FirebasePerformance: Fetched value: '' for key: 'fpr_disabled_android_versions' from Firebase Remote Config.
2020-02-20 12:39:57.732 10758-12264/com.gobaskt D/FirebasePerformance: Config resolver result for flag: 'f.j.a.b.i.g.n' is: ''. Resolving value as 'false'
2020-02-20 12:39:57.732 10758-12264/com.gobaskt D/FirebasePerformance: Logging NetworkRequestMetric - https://api.gobaskt.com/dev-basket/gobaskt/basket 6769b 24010ms,
2020-02-20 12:39:57.733 10758-12264/com.gobaskt W/com.gobaskt: Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
2020-02-20 12:39:57.733 10758-12264/com.gobaskt W/com.gobaskt: Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
2020-02-20 12:39:57.733 10758-12264/com.gobaskt W/com.gobaskt: Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
2020-02-20 12:39:57.733 10758-12264/com.gobaskt W/com.gobaskt: Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
2020-02-20 12:39:57.733 10758-12264/com.gobaskt D/FirebasePerformance: Retrieving master flag for Firebase Performance SDK enabled configuration value.
2020-02-20 12:39:57.733 10758-12264/com.gobaskt D/FirebasePerformance: Fetched value: 'true' for key: 'fpr_enabled' from Firebase Remote Config.
2020-02-20 12:39:57.733 10758-12264/com.gobaskt D/FirebasePerformance: Config resolver result for flag: 'f.j.a.b.i.g.q' is: 'true'.
2020-02-20 12:39:57.733 10758-12264/com.gobaskt D/FirebasePerformance: Retrieving Firebase Performance SDK disabled versions configuration value.
2020-02-20 12:39:57.733 10758-12264/com.gobaskt D/FirebasePerformance: Fetched value: '' for key: 'fpr_disabled_android_versions' from Firebase Remote Config.
2020-02-20 12:39:57.733 10758-12264/com.gobaskt D/FirebasePerformance: Config resolver result for flag: 'f.j.a.b.i.g.n' is: ''. Resolving value as 'false'
2020-02-20 12:39:57.734 10758-12264/com.gobaskt D/FirebasePerformance: Retrieving network request sampling rate configuration value.
2020-02-20 12:39:57.735 10758-12264/com.gobaskt D/FirebasePerformance: Fetched value: '1.0' for key: 'fpr_vc_network_request_sampling_rate' from Firebase Remote Config.
2020-02-20 12:39:57.735 10758-12264/com.gobaskt D/FirebasePerformance: Config resolver result for flag: 'f.j.a.b.i.g.l' is: '1.0'.
2020-02-20 12:39:57.735 10758-12264/com.gobaskt W/com.gobaskt: Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
2020-02-20 12:39:57.735 10758-12244/com.gobaskt E/a$a: java.lang.ClassCastException: f.j.c.z.h cannot be cast to f.i.d.b.c.c.a
        at f.i.d.c.i.b.b(SourceFile:26)
        at f.i.d.c.i.b$b.b(Unknown Source:11)
        at l.z.i.a.a.a(SourceFile:33)
        at m.a.s0.run(SourceFile:241)
        at m.a.l2.a.a(SourceFile:594)
        at m.a.l2.a.a(SourceFile:60)
        at m.a.l2.a$b.run(SourceFile:740)
2020-02-20 12:39:57.735 10758-12264/com.gobaskt W/com.gobaskt: Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
2020-02-20 12:39:57.760 10758-10758/com.gobaskt V/ViewRootImpl: The specified message queue synchronization  barrier token has not been posted or has already been removed
2020-02-20 12:42:00.386 10758-12318/com.gobaskt V/FA: Recording user engagement, ms: 147302
2020-02-20 12:42:00.388 10758-12318/com.gobaskt V/FA: Connecting to remote service
2020-02-20 12:42:00.425 10758-10758/com.gobaskt D/FirebasePerformance: Retrieving Max Duration (in minutes) of single Session configuration value.
2020-02-20 12:42:00.426 10758-10758/com.gobaskt W/FirebaseRemoteConfig: No value of type 'FirebaseRemoteConfigValue' exists for parameter key 'fpr_session_max_duration_min'.
2020-02-20 12:42:00.426 10758-10758/com.gobaskt D/FirebasePerformance: Config resolver result for flag: 'f.j.a.b.i.g.r' is: '240'.
2020-02-20 12:42:00.427 10758-10758/com.gobaskt D/FirebasePerformance: Config resolver result for flag: 'f.j.a.b.i.g.i' is: 'false'.
2020-02-20 12:42:00.428 10758-10758/com.gobaskt D/FirebasePerformance: CollectionEnabled metadata key unknown or value not found in manifest.

以下是构建类型:

release {
        manifestPlaceholders = [crashlyticsCollectionEnabled: "true"]
        minifyEnabled true   // Obfuscate and minify codes
        shrinkResources true // Remove unused resources
        useProguard true     // Remove unused codes
        debuggable true
        signingConfig signingConfigs.release
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), '../proguard-rules.pro'
    }

我还添加了我正在调用 api 的消息的屏幕截图。一切工作正常是调试构建。我仅在发布版本中遇到问题。我已经为我的模型使用了 serializedName。从过去两天尝试了很多来自stackoverflow的答案。如果有人有任何想法,请告诉我。在此处输入图像描述

4

2 回答 2

1

查看fidbcca所指的映射文件,如果它指的是 Model/Pojo,那么您必须处理 GSON 的 proguard 规则,或者您也可以@Keep在模型类之上添加。

于 2020-02-20T07:38:25.077 回答
0

我对发布版本有相同的问题,并且发布调试变体运行良好。

以下是一个错误:

.z.i.a.a.b(:33)
at kotlinx.coroutines.v0.run(:241)
at kotlinx.coroutines.w2.a.a(:594)
at kotlinx.coroutines.w2.a.a(:60)
at kotlinx.coroutines.w2.a$b.run(:740)

只需在 gradle 下面添加:

implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3'

从此链接 在proguard 文件中添加以下内容: coroutines.pro

于 2020-02-20T08:38:59.437 回答