release 不支持的跳转链接(404)
yz1309 opened this issue · 5 comments
`
buildTypes {
debug {// debug模式运行能够跳转页面
minifyEnabled false
shrinkResources false
signingConfig signingConfigs.dcc
}
release {// release 模式下运行跳转页面提示 404
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.dcc
}
}
`
看下文档,是不是Proguard没有配置好
`
----- Glide BEGIN -----
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.module.AppGlideModule
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
**[] $VALUES;
public *;
}
----- Glide END -----
----- OkHttp BEGIN -----
JSR 305 annotations are for embedding nullability information.
-dontwarn javax.annotation.**
A resource is loaded with a relative path so the package of this class must be preserved.
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase
Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
-dontwarn org.codehaus.mojo.animal_sniffer.*
OkHttp platform used only on JVM and when Conscrypt dependency is available.
-dontwarn okhttp3.internal.platform.ConscryptPlatform
Okio: Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
-dontwarn org.codehaus.mojo.animal_sniffer.*
----- OkHttp END -----
----- Retrofit BEGIN -----
Retrofit does reflection on generic parameters. InnerClasses is required to use Signature and
EnclosingMethod is required to use InnerClasses.
-keepattributes Signature, InnerClasses, EnclosingMethod
Retrofit does reflection on method and parameter annotations.
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations
Retain service method parameters when optimizing.
-keepclassmembers,allowshrinking,allowobfuscation interface * {
@retrofit2.http.* ;
}
Ignore annotation used for build tooling.
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Ignore JSR 305 annotations for embedding nullability information.
-dontwarn javax.annotation.**
Guarded by a NoClassDefFoundError try/catch and only used when on the classpath.
-dontwarn kotlin.Unit
Top-level functions that can only be used by Kotlin.
-dontwarn retrofit2.KotlinExtensions
With R8 full mode, it sees no subtypes of Retrofit interfaces since they are created with a Proxy
and replaces all potential values with null. Explicitly keeping the interfaces prevents this.
-if interface * { @retrofit2.http.* ; }
-keep,allowobfuscation interface <1>
----- Retrofit END -----
The following line is a work around for the 'Value "i" is not a reference value' bug.
See https://stackoverflow.com/questions/32185060/android-proguard-failing-with-value-i-is-not-a-reference-value.
-optimizations !class/unboxing/enum
----- Supress proguard note for descriptors ----
See https://stackoverflow.com/a/36175170/4944176
-dontnote kotlin.jvm.internal.DefaultConstructorMarker
-dontnote kotlin.coroutines.**
-dontnote com.google.android.material.**
-dontnote okhttp3.RequestBody
-dontnote com.baidu.**
-dontnote com.scwang.smartrefresh.**
-dontnote com.viewpagerindicator.**
-dontnote com.contrarywind.**
-dontnote com.lwkandroid.widget.**
----- EventBus BEGIN -----
-keepattributes Annotation
-keepclassmembers class * {
@org.greenrobot.eventbus.Subscribe ;
}
-keep enum org.greenrobot.eventbus.ThreadMode { *; }
----- EventBus END -----
保留ServiceLoaderInit类,需要反射调用
#-keep class com.sankuai.waimai.router.generated.ServiceLoaderInit { *; }
避免注解在shrink阶段就被移除,导致obfuscate阶段注解失效、实现类仍然被混淆
#-keep @interface com.sankuai.waimai.router.annotation.RouterService
使用了RouterService注解的实现类,需要避免Proguard把构造方法、方法等成员移除(shrink)或混淆(obfuscate),导致无法反射调用。实现类的类名可以混淆。
#-keepclassmembers @com.sankuai.waimai.router.annotation.RouterService class * { *; }`
反编译一下apk看看有那些类,然后打断点调试分析下就好了,原理不复杂