我有一个带有以下构造函数的类:
.child ( "FirstName");
我的proguard文件:
class Configuration @JvmOverloads constructor(val applicationId: String, typesToAutomaticallyLoad: List<AutoLoadableType>,
val isTestMode: Boolean = false, var userId: String? = null,
private var videoNetworks: List<MDNetwork> = MDNetwork.values().toMutableList(),
private var networks: List<MDAdNetwork> = MDNetwork.values().toMutableList(),
var loadingTimeoutMs: Long = 20000)
禁用缩小功能,我得到:
-keep class mypackage.** {
<init>(...);
*;
}
启用缩小功能后,我得到:
@JvmOverloads
public Configuration(@NotNull String applicationId, @NotNull List typesToAutomaticallyLoad, boolean isTestMode, @Nullable String userId, @NotNull List videoNetworks, @NotNull List networks) {
this(applicationId, typesToAutomaticallyLoad, isTestMode, userId, videoNetworks, networks, 0L, 64, (DefaultConstructorMarker)null);
}
@JvmOverloads
public Configuration(@NotNull String applicationId, @NotNull List typesToAutomaticallyLoad, boolean isTestMode, @Nullable String userId, @NotNull List videoNetworks) {
this(applicationId, typesToAutomaticallyLoad, isTestMode, userId, videoNetworks, (List)null, 0L, 96, (DefaultConstructorMarker)null);
}
@JvmOverloads
public Configuration(@NotNull String applicationId, @NotNull List typesToAutomaticallyLoad, boolean isTestMode, @Nullable String userId) {
this(applicationId, typesToAutomaticallyLoad, isTestMode, userId, (List)null, (List)null, 0L, 112, (DefaultConstructorMarker)null);
}
@JvmOverloads
public Configuration(@NotNull String applicationId, @NotNull List typesToAutomaticallyLoad, boolean isTestMode) {
this(applicationId, typesToAutomaticallyLoad, isTestMode, (String)null, (List)null, (List)null, 0L, 120, (DefaultConstructorMarker)null);
}
@JvmOverloads
public Configuration(@NotNull String applicationId, @NotNull List typesToAutomaticallyLoad) {
this(applicationId, typesToAutomaticallyLoad, false, (String)null, (List)null, (List)null, 0L, 124, (DefaultConstructorMarker)null);
}
因此,此proguard配置保留了类名,构造函数名,但不保留参数名。
如何使它也保留参数名称?
答案 0 :(得分:1)
您必须添加带有所有参数的@SerializedName(“ ...”),
数据类SyncUser( @SerializedName(“用户”) val用户:User )