启用Proguard时使用Refught2的int java.util.List.size()NullException
每次启用Proguard并使用Reformation时,我都会出现此空异常,为了解决此问题,我将使用Reformation的类添加到Proguard列表中,例如:启用Proguard时使用Refught2的int java.util.List.size()NullException,java,android,retrofit,proguard,Java,Android,Retrofit,Proguard,每次启用Proguard并使用Reformation时,我都会出现此空异常,为了解决此问题,我将使用Reformation的类添加到Proguard列表中,例如: -keep class com.abohani.example.utils.ban { *; } 即使我添加了它,我也有以下错误: java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a n
-keep class com.abohani.example.utils.ban { *; }
即使我添加了它,我也有以下错误:
java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
at com.abohani.example.utils.BanUtil$2.onResponse(BanUtil.java:91)
此错误仅在启用Proguard时发生,禁用Proguard时完全没有错误,错误/代码示例中所述的行:
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(Constants.API_PATH)
.addConverterFactory(GsonConverterFactory.create())
.build();
ReApi Api = retrofit.create(ReApi.class);
Call<Model> Connection = Api.GetList(UID,Key);
Connection.enqueue(new Callback<Model>() {
@Override
public void onResponse(Call<Model> call, Response<Model> response) {
List<BanItem> LatestItems = response.body().GetMain();
for (int i = 0; i < LatestItems.size(); i++) {
}
}
@Override
public void onFailure(Call<Model> call, Throwable t) {
t.printStackTrace();
}
});
reformation-reformation=new-reformation.Builder()
.baseUrl(常量.API_路径)
.addConverterFactory(GsonConverterFactory.create())
.build();
ReApi Api=reformation.create(ReApi.class);
调用连接=Api.GetList(UID,Key);
Connection.enqueue(新回调(){
@凌驾
公共void onResponse(调用、响应){
List LatestItems=response.body().GetMain();
对于(int i=0;i
第91行是“for”循环行,响应是正确的,它根本不是空的,它只是由启用proguard引起的,我已经将它添加到列表中,不知道它为什么不工作
是什么引起的?如何在不向Proguard列表中添加类的情况下解决此错误,因为有些类无法显示其完整代码,我必须使用Proguard对其进行加密
提前谢谢
-keep class com.abohani.example.utils.** { *; }.
尝试将此添加到proguard并检查。确保所有型号都在UTIL软件包下
尝试将此添加到proguard并检查。确保您的所有模型都在UTIL包中。Model和BanItem都是
-keep
指令的目标?我所有的模型都在“Model”包中,它们也在-keep中。我想这两个类的代码可能会有所帮助。确保所有被解析的内容都被正确保存。您希望提供什么类?我可以提供它们,这个“大小”为空的东西让我非常恼火,迫使我公开我的真实代码以供查看。Model和BanItem都是-keep
指令的目标?我所有的模型都在“Model”包中,它们也在-keep中。我想这两个类的代码可能会有所帮助。确保所有被解析的内容都被正确保存。您希望提供什么类?我可以提供它们,这个“大小”为空的东西让我非常恼火,迫使我公开我的真实代码以供查看。“我所有的模型都在“模型”包中,它们也在-keep中”而且我不能设置所有的Util类,因为有些类我不想显示它的代码。“我所有的模型都在“模型”包中,它们也在-keep中”另外,我不能设置所有的Util类,因为有些类我不想显示它的代码。