When I am passing image url to Picasso then it shows me error "Target must not be null". When I fetch image from url using Picasso then it shows me error.
my logcat
java.lang.IllegalArgumentException: Target must not be null.
at com.squareup.picasso.RequestCreator.into(RequestCreator.java:682)
at com.squareup.picasso.RequestCreator.into(RequestCreator.java:665)
at com.example.instagramclone.fragment.ProfileFragment$userInfo$1.onDataChange(ProfileFragment.kt:191)
at com.google.firebase.database.core.ValueEventRegistration.fireEvent(com.google.firebase:firebase-database@@19.3.0:75)
at com.google.firebase.database.core.view.DataEvent.fire(com.google.firebase:firebase-database@@19.3.0:63)
at com.google.firebase.database.core.view.EventRaiser$1.run(com.google.firebase:firebase-database@@19.3.0:55)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:169)
at android.app.ActivityThread.main(ActivityThread.java:6595)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
my xml
<com.mikhaellopez.circularimageview.CircularImageView
android:id="@+id/pro_image_profile_frag"
android:layout_width="161dp"
android:layout_height="90dp"
android:src="@drawable/profile1">
</com.mikhaellopez.circularimageview.CircularImageView>
my activity
Picasso.get().load(user!!.getImage()).placeholder(R.drawable.profile1).into(pro_image_profile_frag)
view?.profile_fragment_username?.text = user!!.getFullname()
view?.full_name_profile_frag?.text = user!!.getUsername()
view?.bio_profile_frag?.text = user!!.getBio()
When you call into()
function the variable pro_image_profile_frag
is null. Please check if it has been initialized before calling into()
function. It should be something like this:
val pro_image_profile_frag = findViewById(R.id.view_id)