首页 > 解决方案 > 从 Firebase 存储上传时出现 RuntimeException

问题描述

我试图从 Firebase 存储上传图像,并且 url 已经存在,但是代码在运行时崩溃了。它给出RuntimeExceptioninit()方法。

我的kt代码:

private fun init() {
if (Common.currentUser !=null && Common.currentUser!!.avatar !=null && !TextUtils.isEmpty(Common.currentUser!!.avatar))
{
    Glide.with(this).load(Common.currentUser!!.avatar).into(image_avatar)
    //Toast.makeText(this,"Error "+Common.currentUser!!.avatar,Toast.LENGTH_SHORT).show()
    //Snackbar.make(drawerLayout,"Error "+Common.currentUser!!.avatar,Snackbar.LENGTH_LONG).show()
}}

日志:

 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.crazytaxi/com.example.crazytaxi.DriverHomeActivity}: java.lang.NullPointerException: Argument must not be null
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3782)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3961)

在 com.example.crazytaxi.DriverHomeActivity.init(DriverHomeActivity.kt:118) 在 com.example.crazytaxi.DriverHomeActivity.onCreate(DriverHomeActivity.kt:68)

标签: androidfirebasekotlinruntimeexception

解决方案


推荐阅读