Closed JailedBird closed 7 months ago
分支 bugfix/agp8.2.2_runtime_error 实验发现AGP 8.2.2启用混淆minify后,貌似 会把 TypeWrapper的匿名内部类从泛型ParameterizedType混淆为Class,导致类型转换报错;
public class TypeWrapper<T> {
protected final Type type;
protected TypeWrapper() {
Type superClass = getClass().getGenericSuperclass();
type = ((ParameterizedType) superClass).getActualTypeArguments()[0];
}
public Type getType() {
return type;
}
}
导致对象注入时候,类型解析抛出异常;
if(serializationService != null) {
val res = substitute.intent?.extras?.getString("list")
if(!res.isNullOrEmpty()) {
val typeWrapper = object : TypeWrapper<MutableList<String>>(){}
serializationService?.parseObject<MutableList<String>>(res, typeWrapper.type)?.let{
substitute.list = it
}
}
}
报错类似: Caused by: java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType at com.alibaba.android.arouter.facade.model.TypeWrapper.
添加上面的混淆应该就OK!
见README 关于新增混淆规则的说明,如果出现这个问题即可采用如下方案: