0
我正在使用Retroft和GSON来解析响应。Retrofit Android:方法调用'getSuccess'可能产生'java.lang.NullPointerException'
我onResponse
代码就像下面
@Override
public void onResponse(@NonNull Call<ResultList> call, @NonNull Response<ResultList> response) {
if (response.isSuccessful()) {
if (response.body() != null &&
response.body().getSuccess() == 1) {
................
我检查response.body() != null
也response.isSuccessful()
。 我仍然在Android工作室上线response.body().getSuccess()
发出警告。
如何避免此警告?
我使用改造:2.3.0和gson:2.8.1。 我已经试过这个问题的解决方案(Retrofit Method invocation may produce 'java.lang.NullPointerException' )。但它不起作用
参考:https://stackoverflow.com/questions/45422911/retrofit-method-invocation-may-produce-java-lang-nullpointerexception –
@ Bapusaheb辛德:我已经尝试过。但它不起作用。显示相同的警告 – Ameer