一、前言:
在Kotlin中定义对象,然后通过Retrofit请求,转化成对象的对象,然后操作对象来进行显示UI。
//1、这个是我本地的对象
data class BookLatest(
val book_id: String,
val cover: String,
val description: String,
val last_chapter_time: String,
val last_chapter_title: String,
val name: String
)
//2、使用GlideUtils 去加载cover的图片
GlideUtils.loadRoundedRectangAllUrl(
this@AuthorInfoActivity,
bookLatest.cover,
ivBookPic,
2
)
3、报错
Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter url
二、解决
可以看到,我们自己定义的对象图片字段是:
cover
,后台返回的图片字段是:conver
,所以报错。
1、为什么会报Parameter specified as non-null is null?
因为我们定义了一个cover字段,没有赋值,并且使用了它,所以报错。
2、解决
让后台把conver 字段改为 cover,就此解决了问题。
![](https://img.haomeiwen.com/i11268516/d320f380c894bf18.png)
网友评论