美文网首页
Parameter specified as non-null

Parameter specified as non-null

作者: 因为我的心 | 来源:发表于2023-04-13 13:15 被阅读0次

    一、前言:

    在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,就此解决了问题。

    图片.png

    相关文章

      网友评论

          本文标题:Parameter specified as non-null

          本文链接:https://www.haomeiwen.com/subject/cgmaddtx.html