如何解决启用 ProGuard 的签名 apk 崩溃
我创建了一个用于接收数据的开放类:
open class Event<out T>(private val content: T) {
var hasBeenHandled = false
private set // Allow external read but not write
/**
* Returns the content and prevents its use again.
*/
fun getContentIfNotHandledOrReturnNull(): T? {
return if (hasBeenHandled) {
null
} else {
hasBeenHandled = true
content
}
}
/**
* Returns the content,even if it's already been handled.
*/
fun peekContent(): T = content
}
但是在签名的 apk 在此导入中出错
我的 Proguard
-ignorewarnings
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keep public class com.vslib.base.model.Job { *; }
-keep public class com.google.android.gms.*{ public *; }
-assumenosideeffects class android.util.Log {
public static *** d(...);
}
-keep public class * extends android.app.Service
-keep public class * extends android.content.broadcastReceiver
-keep public class * extends android.provider.Settings
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,EnclosingMethod
-keep class * extends androidx.lifecycle.viewmodel {
<init>();
}
-keep class * extends androidx.lifecycle.Androidviewmodel {
<init>(android.app.Application);
}
-keepattributes *Annotation*
-keepclassmembers enum androidx.lifecycle.Lifecycle$Event {
<fields>;
}
-keep class androidx.lifecycle.* { *; }
Error LOG:
at com.packagename.fragment.a(SourceFile:32)
at g.j.a.c.j.i.j.a(SourceFile:7)
at g.j.a.c.h.i.e.onTransact(SourceFile:3)
at android.os.Binder.transact(Binder.java:504)
at dx.aZ(:com.google.android.gms.dynamite_mapsdynamite@210915051@21.09.15 (040408-0):2)
at com.google.maps.api.android.lib6.impl.bj.run(:com.google.android.gms.dynamite_mapsdynamite@210915051@21.09.15 (040408-0):1)
at android.os.Handler.handleCallback(Handler.java:836)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:203)
使用事件类时出现上述错误。如果我隐藏类它工作正常但如果启用崩溃。任何人都可以帮忙解决这个问题。还需要启用 proguard
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。